]> granicus.if.org Git - clang/commitdiff
Parse: __attribute__((keyword)) shouldn't error
authorDavid Majnemer <david.majnemer@gmail.com>
Sat, 3 Jan 2015 19:41:00 +0000 (19:41 +0000)
committerDavid Majnemer <david.majnemer@gmail.com>
Sat, 3 Jan 2015 19:41:00 +0000 (19:41 +0000)
Weird constructs like __attribute__((inline)) or
__attibute__((typename)) should result in warnings, not errors.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225118 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Parse/ParseDecl.cpp
test/Parser/cxx-attributes.cpp
test/Parser/namespace-alias-attr.cpp

index c0c0d59c7c4d763888571bebf21f1ec8abbf64d2..7ff39aabeb1ca7be13fc57b4e7be7fce80412104 100644 (file)
@@ -143,11 +143,12 @@ void Parser::ParseGNUAttributes(ParsedAttributes &attrs,
         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)) {
index 8cba5bc2a178e9c2d2732434d1a78400a6922e69..6591532a91a2082751a1af0c359c87ef7b0547e0 100644 (file)
@@ -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}}
index 141a96c5ebeb10c386e187f0135c5419272c5bda..0baba8493d0fda59188defd75c7c41521d4df0a6 100644 (file)
@@ -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}}