diff options
author | Douglas Gregor <dgregor@apple.com> | 2009-08-26 00:04:55 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2009-08-26 00:04:55 +0000 |
commit | dacd434c49658286c380c7b4c357d76d53cb4aa1 (patch) | |
tree | 96445b18410c013f21aabb19f3fe17348fbfb225 /lib/Sema/SemaDecl.cpp | |
parent | ec7738776ba68576db5d8316af399d1f983245ee (diff) |
Improve diagnostics and recovery when the nested-name-specifier of a
qualified name does not actually refer into a class/class
template/class template partial specialization.
Improve printing of nested-name-specifiers to eliminate redudant
qualifiers. Also, make it possible to output a nested-name-specifier
through a DiagnosticBuilder, although there are relatively few places
that will use this leeway.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80056 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaDecl.cpp')
-rw-r--r-- | lib/Sema/SemaDecl.cpp | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index d478c048b8..fec9a075ec 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -1633,7 +1633,7 @@ Sema::HandleDeclarator(Scope *S, Declarator &D, << D.getDeclSpec().getSourceRange() << D.getSourceRange(); return DeclPtrTy(); } - + // The scope passed in may not be a decl scope. Zip up the scope tree until // we find one that is. while ((S->getFlags() & Scope::DeclScope) == 0 || @@ -1701,7 +1701,19 @@ Sema::HandleDeclarator(Scope *S, Declarator &D, D.getIdentifierLoc()); } else { // Something like "int foo::x;" DC = computeDeclContext(D.getCXXScopeSpec(), true); - // FIXME: RequireCompleteDeclContext(D.getCXXScopeSpec()); ? + + if (!DC) { + // If we could not compute the declaration context, it's because the + // declaration context is dependent but does not refer to a class, + // class template, or class template partial specialization. Complain + // and return early, to avoid the coming semantic disaster. + Diag(D.getIdentifierLoc(), + diag::err_template_qualified_declarator_no_match) + << (NestedNameSpecifier*)D.getCXXScopeSpec().getScopeRep() + << D.getCXXScopeSpec().getRange(); + return DeclPtrTy(); + } + PrevDecl = LookupQualifiedName(DC, Name, LookupOrdinaryName, true); // C++ 7.3.1.2p2: |