r225118 - Parse: __attribute__((keyword)) shouldn't error
Aaron Ballman
aaron at aaronballman.com
Sat Jan 3 11:44:11 PST 2015
On Sat, Jan 3, 2015 at 2:41 PM, David Majnemer <david.majnemer at gmail.com> wrote:
> 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;
Thanks for taking care of this!
Is there a way to get a raw identifier here? getIdentifierInfo asserts
on that as well as annotations, which is why I ask. We may want a
comment here explaining why we break as well.
~Aaron
> -
> 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}}
>
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
More information about the cfe-commits
mailing list