]> granicus.if.org Git - clang/commitdiff
Support GNU attributes in alias-declarations now that GCC has implemented them
authorRichard Smith <richard-llvm@metafoo.co.uk>
Thu, 24 Oct 2013 01:21:09 +0000 (01:21 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Thu, 24 Oct 2013 01:21:09 +0000 (01:21 +0000)
and we know where they go.

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

lib/Parse/ParseDeclCXX.cpp
test/Parser/cxx0x-decl.cpp

index 4625745c5e2f33e1e787f98c3b255c3936ec457e..000d0768f8d9362757876e6bc7485cbf47249492 100644 (file)
@@ -508,6 +508,7 @@ Decl *Parser::ParseUsingDeclaration(unsigned Context,
   }
 
   ParsedAttributesWithRange Attrs(AttrFactory);
+  MaybeParseGNUAttributes(Attrs);
   MaybeParseCXX11Attributes(Attrs);
 
   // Maybe this is an alias-declaration.
@@ -525,7 +526,6 @@ Decl *Parser::ParseUsingDeclaration(unsigned Context,
       Attrs.takeAllFrom(MisplacedAttrs);
     }
 
-    // TODO: Can GNU attributes appear here?
     ConsumeToken();
 
     Diag(Tok.getLocation(), getLangOpts().CPlusPlus11 ?
@@ -1159,8 +1159,7 @@ void Parser::ParseClassSpecifier(tok::TokenKind TagTokKind,
 
   ParsedAttributesWithRange attrs(AttrFactory);
   // If attributes exist after tag, parse them.
-  if (Tok.is(tok::kw___attribute))
-    ParseGNUAttributes(attrs);
+  MaybeParseGNUAttributes(attrs);
 
   // If declspecs exist after tag, parse them.
   while (Tok.is(tok::kw___declspec))
@@ -1170,7 +1169,7 @@ void Parser::ParseClassSpecifier(tok::TokenKind TagTokKind,
   if (Tok.is(tok::kw___single_inheritance) ||
       Tok.is(tok::kw___multiple_inheritance) ||
       Tok.is(tok::kw___virtual_inheritance))
-      ParseMicrosoftInheritanceClassAttributes(attrs);
+    ParseMicrosoftInheritanceClassAttributes(attrs);
 
   // If C++0x attributes exist here, parse them.
   // FIXME: Are we consistent with the ordering of parsing of different
index 961896d8fc8a0ec36877abce8338a0b76a1cbdc4..257c56c9ce98146143956bf061583fcf2d18a519 100644 (file)
@@ -95,3 +95,12 @@ namespace FinalOverride {
     virtual auto i() -> void *override final;
   };
 }
+
+namespace UsingDeclAttrs {
+  using T __attribute__((aligned(1))) = int;
+  using T [[gnu::aligned(1)]] = int;
+  static_assert(alignof(T) == 1, "");
+
+  using [[gnu::aligned(1)]] T = int; // expected-error {{an attribute list cannot appear here}}
+  using T = int [[gnu::aligned(1)]]; // expected-error {{'aligned' attribute cannot be applied to types}}
+}