aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/TreeTransform.h
diff options
context:
space:
mode:
authorNick Lewycky <nicholas@mxc.ca>2011-01-24 19:01:04 +0000
committerNick Lewycky <nicholas@mxc.ca>2011-01-24 19:01:04 +0000
commit446e4029c75b651475e9055dc9dd18fbc7b6dabe (patch)
treee752db6a5f293c3ee4724c3834de046c26f938bf /lib/Sema/TreeTransform.h
parent5505c72695161e2fb55391d1453b82b7adbff923 (diff)
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! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@124136 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/TreeTransform.h')
-rw-r--r--lib/Sema/TreeTransform.h25
1 files changed, 22 insertions, 3 deletions
diff --git a/lib/Sema/TreeTransform.h b/lib/Sema/TreeTransform.h
index 1cb24e70bf..3390dd7bad 100644
--- a/lib/Sema/TreeTransform.h
+++ b/lib/Sema/TreeTransform.h
@@ -796,9 +796,28 @@ public:
}
if (!Tag) {
- // FIXME: Would be nice to highlight just the source range.
- SemaRef.Diag(IdLoc, diag::err_not_tag_in_scope)
- << Kind << Id << DC;
+ // Check where the name exists but isn't a tag type and use that to emit
+ // better diagnostics.
+ 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();
}