r224945 - Parse: Ignore '::' in 'struct :: {'
David Majnemer
david.majnemer at gmail.com
Mon Dec 29 11:19:18 PST 2014
Author: majnemer
Date: Mon Dec 29 13:19:18 2014
New Revision: 224945
URL: http://llvm.org/viewvc/llvm-project?rev=224945&view=rev
Log:
Parse: Ignore '::' in 'struct :: {'
Let's pretend that we didn't see the '::' instead of go on believing
that we've got some anonymous, but globally qualified, struct.
Modified:
cfe/trunk/include/clang/AST/Decl.h
cfe/trunk/lib/Parse/ParseExprCXX.cpp
cfe/trunk/test/CXX/dcl.decl/dcl.meaning/p1.cpp
Modified: cfe/trunk/include/clang/AST/Decl.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=224945&r1=224944&r2=224945&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/trunk/include/clang/AST/Decl.h Mon Dec 29 13:19:18 2014
@@ -2823,18 +2823,16 @@ public:
bool hasDeclaratorForAnonDecl() const {
return dyn_cast_or_null<DeclaratorDecl>(
- NamedDeclOrQualifier.dyn_cast<NamedDecl *>());
+ NamedDeclOrQualifier.get<NamedDecl *>());
}
DeclaratorDecl *getDeclaratorForAnonDecl() const {
- return hasExtInfo() ? nullptr
- : dyn_cast_or_null<DeclaratorDecl>(
- NamedDeclOrQualifier.dyn_cast<NamedDecl *>());
+ return hasExtInfo() ? nullptr : dyn_cast_or_null<DeclaratorDecl>(
+ NamedDeclOrQualifier.get<NamedDecl *>());
}
TypedefNameDecl *getTypedefNameForAnonDecl() const {
- return hasExtInfo() ? nullptr
- : dyn_cast_or_null<TypedefNameDecl>(
- NamedDeclOrQualifier.dyn_cast<NamedDecl *>());
+ return hasExtInfo() ? nullptr : dyn_cast_or_null<TypedefNameDecl>(
+ NamedDeclOrQualifier.get<NamedDecl *>());
}
void setDeclaratorForAnonDecl(DeclaratorDecl *DD) { NamedDeclOrQualifier = DD; }
Modified: cfe/trunk/lib/Parse/ParseExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseExprCXX.cpp?rev=224945&r1=224944&r2=224945&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseExprCXX.cpp (original)
+++ cfe/trunk/lib/Parse/ParseExprCXX.cpp Mon Dec 29 13:19:18 2014
@@ -219,13 +219,19 @@ bool Parser::ParseOptionalCXXScopeSpecif
if (NextKind == tok::kw_new || NextKind == tok::kw_delete)
return false;
- // '::' - Global scope qualifier.
- if (Actions.ActOnCXXGlobalScopeSpecifier(ConsumeToken(), SS))
- return true;
+ if (NextKind == tok::l_brace) {
+ // It is invalid to have :: {, consume the scope qualifier and pretend
+ // like we never saw it.
+ Diag(ConsumeToken(), diag::err_expected) << tok::identifier;
+ } else {
+ // '::' - Global scope qualifier.
+ if (Actions.ActOnCXXGlobalScopeSpecifier(ConsumeToken(), SS))
+ return true;
- CheckForLParenAfterColonColon();
+ CheckForLParenAfterColonColon();
- HasScopeSpecifier = true;
+ HasScopeSpecifier = true;
+ }
}
if (Tok.is(tok::kw___super)) {
Modified: cfe/trunk/test/CXX/dcl.decl/dcl.meaning/p1.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/dcl.decl/dcl.meaning/p1.cpp?rev=224945&r1=224944&r2=224945&view=diff
==============================================================================
--- cfe/trunk/test/CXX/dcl.decl/dcl.meaning/p1.cpp (original)
+++ cfe/trunk/test/CXX/dcl.decl/dcl.meaning/p1.cpp Mon Dec 29 13:19:18 2014
@@ -44,5 +44,4 @@ namespace NS {
template<typename T> void NS::wibble(T) { } // expected-warning{{extra qualification on member 'wibble'}}
}
-// expected-warning at +1{{extra qualification on member}}
struct ::{} a; // expected-error{{expected identifier}}
More information about the cfe-commits
mailing list