diff options
author | Eli Friedman <eli.friedman@gmail.com> | 2009-04-28 03:13:54 +0000 |
---|---|---|
committer | Eli Friedman <eli.friedman@gmail.com> | 2009-04-28 03:13:54 +0000 |
commit | eb32fde032a250091134db56a3aeaea6b09f6594 (patch) | |
tree | bbb99eb60c56a700149545eb821b579870bd883d /test/Parser/attributes.c | |
parent | f6e8541dd884029b85483a319ce7d32f3e476dcc (diff) |
Simplify the scheme used for keywords, and change the classification
scheme to be more useful.
The new scheme introduces a set of categories that should be more
readable, and also reflects what we want to consider as an extension
more accurately. Specifically, it makes the "what is a keyword"
determination accurately reflect whether the keyword is a GNU or
Microsoft extension.
I also introduced separate flags for keyword aliases; this is useful
because the classification of the aliases is mostly unrelated to the
classification of the original keyword.
This patch treats anything that's in the implementation
namespace (prefixed with "__", or "_X" where "X" is any upper-case
letter) as a keyword without marking it as an extension. This is
consistent with the standards in that an implementation is allowed to define
arbitrary extensions in the implementation namespace without violating
the standard. This gets rid of all the nasty "extension used" warnings
for stuff like __attribute__ in -pedantic mode. We still warn for
extensions outside of the the implementation namespace, like typeof.
If someone wants to implement -Wextensions or something like that, we
could add additional information to the keyword table.
This also removes processing for the unused "Boolean" language option;
such an extension isn't supported on any other C implementation, so I
don't see any point to adding it.
The changes to test/CodeGen/inline.c are required because previously, we
weren't actually disabling the "inline" keyword in -std=c89 mode.
I'll remove Boolean and NoExtensions from LangOptions in a follow-up
commit.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70281 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Parser/attributes.c')
-rw-r--r-- | test/Parser/attributes.c | 46 |
1 files changed, 21 insertions, 25 deletions
diff --git a/test/Parser/attributes.c b/test/Parser/attributes.c index 37fa0ca1d3..dc2bb02670 100644 --- a/test/Parser/attributes.c +++ b/test/Parser/attributes.c @@ -1,57 +1,53 @@ // RUN: clang-cc -fsyntax-only -verify %s -pedantic -std=c99 -int __attribute__(()) x; // expected-warning {{extension used}} +int __attribute__(()) x; -// Hide __attribute__ behind a macro, to silence extension warnings about -// "__attribute__ being an extension". -#define attribute __attribute__ - -__inline void attribute((__always_inline__, __nodebug__)) +__inline void __attribute__((__always_inline__, __nodebug__)) foo(void) { } -attribute(()) y; // expected-warning {{defaults to 'int'}} +__attribute__(()) y; // expected-warning {{defaults to 'int'}} // PR2796 -int (attribute(()) *z)(long y); +int (__attribute__(()) *z)(long y); -void f1(attribute(()) int x); +void f1(__attribute__(()) int x); -int f2(y, attribute(()) x); // expected-error {{expected identifier}} +int f2(y, __attribute__(()) x); // expected-error {{expected identifier}} // This is parsed as a normal argument list (with two args that are implicit -// int) because the attribute is a declspec. -void f3(attribute(()) x, // expected-warning {{defaults to 'int'}} +// int) because the __attribute__ is a declspec. +void f3(__attribute__(()) x, // expected-warning {{defaults to 'int'}} y); // expected-warning {{defaults to 'int'}} -void f4(attribute(())); // expected-error {{expected parameter declarator}} +void f4(__attribute__(())); // expected-error {{expected parameter declarator}} -// This is ok, the attribute applies to the pointer. -int baz(int (attribute(()) *x)(long y)); +// This is ok, the __attribute__ applies to the pointer. +int baz(int (__attribute__(()) *x)(long y)); -void g1(void (*f1)(attribute(()) int x)); -void g2(int (*f2)(y, attribute(()) x)); // expected-error {{expected identifier}} -void g3(void (*f3)(attribute(()) x, int y)); // expected-warning {{defaults to 'int'}} -void g4(void (*f4)(attribute(()))); // expected-error {{expected parameter declarator}} +void g1(void (*f1)(__attribute__(()) int x)); +void g2(int (*f2)(y, __attribute__(()) x)); // expected-error {{expected identifier}} +void g3(void (*f3)(__attribute__(()) x, int y)); // expected-warning {{defaults to 'int'}} +void g4(void (*f4)(__attribute__(()))); // expected-error {{expected parameter declarator}} -void (*h1)(void (*f1)(attribute(()) int x)); -void (*h2)(int (*f2)(y, attribute(()) x)); // expected-error {{expected identifier}} +void (*h1)(void (*f1)(__attribute__(()) int x)); +void (*h2)(int (*f2)(y, __attribute__(()) x)); // expected-error {{expected identifier}} -void (*h3)(void (*f3)(attribute(()) x)); // expected-warning {{defaults to 'int'}} -void (*h4)(void (*f4)(attribute(()))); // expected-error {{expected parameter declarator}} +void (*h3)(void (*f3)(__attribute__(()) x)); // expected-warning {{defaults to 'int'}} +void (*h4)(void (*f4)(__attribute__(()))); // expected-error {{expected parameter declarator}} // rdar://6131260 int foo42(void) { - int x, attribute((unused)) y, z; + int x, __attribute__((unused)) y, z; return 0; } // rdar://6096491 -void attribute((noreturn)) d0(void), attribute((noreturn)) d1(void); +void __attribute__((noreturn)) d0(void), __attribute__((noreturn)) d1(void); |