diff options
author | Michael Han <Michael.Han@autodesk.com> | 2012-11-06 19:34:54 +0000 |
---|---|---|
committer | Michael Han <Michael.Han@autodesk.com> | 2012-11-06 19:34:54 +0000 |
commit | f64231e9f47234826fbcdc3b4fe0370ef6c9961d (patch) | |
tree | 5bf2e20734f073f7ee51d2c152d39c5a83abf442 /lib/Parse/ParseDecl.cpp | |
parent | fd9d0e13a17b915fa6b35e3a3465513d67f1482d (diff) |
Teach Clang parser to reject C++11 attributes that appertain to declaration specifiers.
We don't support any C++11 attributes that appertain to declaration specifiers so reject
the attributes in parser until we support them; this also conforms to what g++ 4.8 is doing.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@167481 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Parse/ParseDecl.cpp')
-rw-r--r-- | lib/Parse/ParseDecl.cpp | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/lib/Parse/ParseDecl.cpp b/lib/Parse/ParseDecl.cpp index d45f038f31..f73907a7c4 100644 --- a/lib/Parse/ParseDecl.cpp +++ b/lib/Parse/ParseDecl.cpp @@ -1142,6 +1142,18 @@ void Parser::DiagnoseProhibitedAttributes(ParsedAttributesWithRange &attrs) { << attrs.Range; } +void Parser::ProhibitCXX11Attributes(ParsedAttributesWithRange &attrs) { + AttributeList *AttrList = attrs.getList(); + while (AttrList) { + if (AttrList->isCXX0XAttribute()) { + Diag(AttrList->getLoc(), diag::warn_attribute_no_decl) + << AttrList->getName(); + AttrList->setInvalid(); + } + AttrList = AttrList->getNext(); + } +} + /// ParseDeclaration - Parse a full 'declaration', which consists of /// declaration-specifiers, some number of declarators, and a semicolon. /// 'Context' should be a Declarator::TheContext value. This returns the @@ -2148,8 +2160,14 @@ void Parser::ParseDeclarationSpecifiers(DeclSpec &DS, DoneWithDeclSpec: if (!AttrsLastTime) ProhibitAttributes(attrs); - else + else { + // Reject C++11 attributes that appertain to decl specifiers as + // we don't support any C++11 attributes that appertain to decl + // specifiers. This also conforms to what g++ 4.8 is doing. + ProhibitCXX11Attributes(attrs); + DS.takeAttributesFrom(attrs); + } // If this is not a declaration specifier token, we're done reading decl // specifiers. First verify that DeclSpec's are consistent. |