diff options
author | David Blaikie <dblaikie@gmail.com> | 2011-12-14 18:59:02 +0000 |
---|---|---|
committer | David Blaikie <dblaikie@gmail.com> | 2011-12-14 18:59:02 +0000 |
commit | 76178ed0911797175b13ac733c390233f02bb841 (patch) | |
tree | 001ccc49286c856ee67181b66985566ee7dc1721 /lib/Sema/SemaDecl.cpp | |
parent | 86277c5cd80d4f5911945fa207062aa9a44db8ff (diff) |
Move & comment the 'decltype in declarator-id' as suggested by Doug Gregor.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@146576 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaDecl.cpp')
-rw-r--r-- | lib/Sema/SemaDecl.cpp | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index 63a1b8034e..238dbd4679 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -3203,16 +3203,6 @@ Decl *Sema::HandleDeclarator(Scope *S, Declarator &D, (S->getFlags() & Scope::TemplateParamScope) != 0) S = S->getParent(); - if (NestedNameSpecifierLoc SpecLoc = - D.getCXXScopeSpec().getWithLocInContext(Context)) { - while (SpecLoc.getPrefix()) - SpecLoc = SpecLoc.getPrefix(); - if (dyn_cast_or_null<DecltypeType>( - SpecLoc.getNestedNameSpecifier()->getAsType())) - Diag(SpecLoc.getBeginLoc(), diag::err_decltype_in_declarator) - << SpecLoc.getTypeLoc().getSourceRange(); - } - DeclContext *DC = CurContext; if (D.getCXXScopeSpec().isInvalid()) D.setInvalidType(); @@ -3377,6 +3367,20 @@ Decl *Sema::HandleDeclarator(Scope *S, Declarator &D, << Name << cast<NamedDecl>(DC) << R; D.setInvalidType(); } + + // C++11 8.3p1: + // ... "The nested-name-specifier of the qualified declarator-id shall + // not begin with a decltype-specifer" + NestedNameSpecifierLoc SpecLoc = + D.getCXXScopeSpec().getWithLocInContext(Context); + assert(SpecLoc && "A non-empty CXXScopeSpec should have a non-empty " + "NestedNameSpecifierLoc"); + while (SpecLoc.getPrefix()) + SpecLoc = SpecLoc.getPrefix(); + if (dyn_cast_or_null<DecltypeType>( + SpecLoc.getNestedNameSpecifier()->getAsType())) + Diag(SpecLoc.getBeginLoc(), diag::err_decltype_in_declarator) + << SpecLoc.getTypeLoc().getSourceRange(); } } |