forked from OSchip/llvm-project
Enhance the diagnostic for referring to a typedef with an elaborated name to be
as useful in a templated context as it is without templates. Fixes PR8755! llvm-svn: 124136
This commit is contained in:
parent
a5f6f9c7a1
commit
0c4380856b
|
@ -796,9 +796,28 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Tag) {
|
if (!Tag) {
|
||||||
// FIXME: Would be nice to highlight just the source range.
|
// Check where the name exists but isn't a tag type and use that to emit
|
||||||
SemaRef.Diag(IdLoc, diag::err_not_tag_in_scope)
|
// better diagnostics.
|
||||||
<< Kind << Id << DC;
|
LookupResult Result(SemaRef, Id, IdLoc, Sema::LookupTagName);
|
||||||
|
SemaRef.LookupQualifiedName(Result, DC);
|
||||||
|
switch (Result.getResultKind()) {
|
||||||
|
case LookupResult::Found:
|
||||||
|
case LookupResult::FoundOverloaded:
|
||||||
|
case LookupResult::FoundUnresolvedValue: {
|
||||||
|
NamedDecl *SomeDecl = Result.getRepresentativeDecl();
|
||||||
|
unsigned Kind = 0;
|
||||||
|
if (isa<TypedefDecl>(SomeDecl)) Kind = 1;
|
||||||
|
else if (isa<ClassTemplateDecl>(SomeDecl)) Kind = 2;
|
||||||
|
SemaRef.Diag(IdLoc, diag::err_tag_reference_non_tag) << Kind;
|
||||||
|
SemaRef.Diag(SomeDecl->getLocation(), diag::note_declared_at);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
// FIXME: Would be nice to highlight just the source range.
|
||||||
|
SemaRef.Diag(IdLoc, diag::err_not_tag_in_scope)
|
||||||
|
<< Kind << Id << DC;
|
||||||
|
break;
|
||||||
|
}
|
||||||
return QualType();
|
return QualType();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
// RUN: %clang_cc1 -fsyntax-only -verify %s
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
struct A {
|
||||||
|
typedef int iterator; // expected-note{{declared here}}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
void f() {
|
||||||
|
class A <T> ::iterator foo; // expected-error{{elaborated type refers to a typedef}}
|
||||||
|
}
|
||||||
|
|
||||||
|
void g() {
|
||||||
|
f<int>(); // expected-note{{in instantiation of function template}}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue