r193297 - Support GNU attributes in alias-declarations now that GCC has implemented them
Richard Smith
richard-llvm at metafoo.co.uk
Wed Oct 23 18:21:09 PDT 2013
Author: rsmith
Date: Wed Oct 23 20:21:09 2013
New Revision: 193297
URL: http://llvm.org/viewvc/llvm-project?rev=193297&view=rev
Log:
Support GNU attributes in alias-declarations now that GCC has implemented them
and we know where they go.
Modified:
cfe/trunk/lib/Parse/ParseDeclCXX.cpp
cfe/trunk/test/Parser/cxx0x-decl.cpp
Modified: cfe/trunk/lib/Parse/ParseDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDeclCXX.cpp?rev=193297&r1=193296&r2=193297&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseDeclCXX.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDeclCXX.cpp Wed Oct 23 20:21:09 2013
@@ -508,6 +508,7 @@ Decl *Parser::ParseUsingDeclaration(unsi
}
ParsedAttributesWithRange Attrs(AttrFactory);
+ MaybeParseGNUAttributes(Attrs);
MaybeParseCXX11Attributes(Attrs);
// Maybe this is an alias-declaration.
@@ -525,7 +526,6 @@ Decl *Parser::ParseUsingDeclaration(unsi
Attrs.takeAllFrom(MisplacedAttrs);
}
- // TODO: Can GNU attributes appear here?
ConsumeToken();
Diag(Tok.getLocation(), getLangOpts().CPlusPlus11 ?
@@ -1159,8 +1159,7 @@ void Parser::ParseClassSpecifier(tok::To
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::To
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
Modified: cfe/trunk/test/Parser/cxx0x-decl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/cxx0x-decl.cpp?rev=193297&r1=193296&r2=193297&view=diff
==============================================================================
--- cfe/trunk/test/Parser/cxx0x-decl.cpp (original)
+++ cfe/trunk/test/Parser/cxx0x-decl.cpp Wed Oct 23 20:21:09 2013
@@ -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}}
+}
More information about the cfe-commits
mailing list