From 96b4874b5097136a48c7fe5ff2b62534ef837e5f Mon Sep 17 00:00:00 2001 From: David Blaikie Date: Wed, 14 Dec 2011 18:59:02 +0000 Subject: Move & comment the 'decltype in declarator-id' as suggested by Doug Gregor. llvm-svn: 146576 --- clang/lib/Sema/SemaDecl.cpp | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) (limited to 'clang/lib/Sema/SemaDecl.cpp') diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index 63a1b8034e9..238dbd46792 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/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( - 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(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( + SpecLoc.getNestedNameSpecifier()->getAsType())) + Diag(SpecLoc.getBeginLoc(), diag::err_decltype_in_declarator) + << SpecLoc.getTypeLoc().getSourceRange(); } } -- cgit v1.2.3