r225118 - Parse: __attribute__((keyword)) shouldn't error
David Majnemer
david.majnemer at gmail.com
Sat Jan 3 11:41:00 PST 2015
Author: majnemer
Date: Sat Jan 3 13:41:00 2015
New Revision: 225118
URL: http://llvm.org/viewvc/llvm-project?rev=225118&view=rev
Log:
Parse: __attribute__((keyword)) shouldn't error
Weird constructs like __attribute__((inline)) or
__attibute__((typename)) should result in warnings, not errors.
Modified:
cfe/trunk/lib/Parse/ParseDecl.cpp
cfe/trunk/test/Parser/cxx-attributes.cpp
cfe/trunk/test/Parser/namespace-alias-attr.cpp
Modified: cfe/trunk/lib/Parse/ParseDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=225118&r1=225117&r2=225118&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseDecl.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDecl.cpp Sat Jan 3 13:41:00 2015
@@ -143,11 +143,12 @@ void Parser::ParseGNUAttributes(ParsedAt
continue;
// Expect an identifier or declaration specifier (const, int, etc.)
- if (Tok.isNot(tok::identifier) && !isTypeQualifier() &&
- !isKnownToBeTypeSpecifier(Tok))
+ if (Tok.isAnnotation())
break;
-
IdentifierInfo *AttrName = Tok.getIdentifierInfo();
+ if (!AttrName)
+ break;
+
SourceLocation AttrNameLoc = ConsumeToken();
if (Tok.isNot(tok::l_paren)) {
Modified: cfe/trunk/test/Parser/cxx-attributes.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/cxx-attributes.cpp?rev=225118&r1=225117&r2=225118&view=diff
==============================================================================
--- cfe/trunk/test/Parser/cxx-attributes.cpp (original)
+++ cfe/trunk/test/Parser/cxx-attributes.cpp Sat Jan 3 13:41:00 2015
@@ -21,4 +21,4 @@ namespace PR17666 {
typedef int __attribute__((aligned(int))) T2; // expected-error {{expected '(' for function-style cast}}
}
-__attribute((typename)) int x; // expected-error {{expected ')'}}
+__attribute((typename)) int x; // expected-warning {{unknown attribute 'typename' ignored}}
Modified: cfe/trunk/test/Parser/namespace-alias-attr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/namespace-alias-attr.cpp?rev=225118&r1=225117&r2=225118&view=diff
==============================================================================
--- cfe/trunk/test/Parser/namespace-alias-attr.cpp (original)
+++ cfe/trunk/test/Parser/namespace-alias-attr.cpp Sat Jan 3 13:41:00 2015
@@ -4,5 +4,5 @@ namespace A
{
}
-namespace B __attribute__ (( const )) = A; // expected-error{{attributes cannot be specified on namespace alias}}
+namespace B __attribute__ (( static )) = A; // expected-error{{attributes cannot be specified on namespace alias}}
More information about the cfe-commits
mailing list