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 | 2b680b43e9cfcdc22cbeecaedbe12687169fd744 (patch) | |
tree | 642c9c6055037c6eea7a95c291afc8c53090d145 /clang/test | |
parent | 49936f76ecfe2202393dfd4ea237aff3ba29dbf0 (diff) | |
download | bcm5719-llvm-2b680b43e9cfcdc22cbeecaedbe12687169fd744.tar.gz bcm5719-llvm-2b680b43e9cfcdc22cbeecaedbe12687169fd744.zip |
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.
llvm-svn: 70281
Diffstat (limited to 'clang/test')
-rw-r--r-- | clang/test/CodeGen/inline.c | 20 | ||||
-rw-r--r-- | clang/test/Parser/attributes.c | 46 | ||||
-rw-r--r-- | clang/test/Parser/declarators.c | 2 | ||||
-rw-r--r-- | clang/test/Parser/recovery.c | 2 | ||||
-rw-r--r-- | clang/test/Preprocessor/extension-warning.c | 14 | ||||
-rw-r--r-- | clang/test/Sema/builtins.c | 2 | ||||
-rw-r--r-- | clang/test/Sema/constant-builtins.c | 2 | ||||
-rw-r--r-- | clang/test/Sema/exprs.c | 10 | ||||
-rw-r--r-- | clang/test/Sema/function.c | 4 | ||||
-rw-r--r-- | clang/test/Sema/i-c-e.c | 6 |
10 files changed, 56 insertions, 52 deletions
diff --git a/clang/test/CodeGen/inline.c b/clang/test/CodeGen/inline.c index 6011f42f9cf..7bdf76de19b 100644 --- a/clang/test/CodeGen/inline.c +++ b/clang/test/CodeGen/inline.c @@ -32,34 +32,34 @@ // RUN: grep "define void @_Z10gnu_inlinev()" %t && // RUN: grep "define available_externally void @_Z13gnu_ei_inlinev()" %t -extern inline int ei() { return 123; } +extern __inline int ei() { return 123; } -inline int foo() { +__inline int foo() { return ei(); } int bar() { return foo(); } -inline void unreferenced1() {} -extern inline void unreferenced2() {} +__inline void unreferenced1() {} +extern __inline void unreferenced2() {} __inline __attribute((__gnu_inline__)) void gnu_inline() {} // PR3988 -extern inline __attribute__((gnu_inline)) void gnu_ei_inline() {} +extern __inline __attribute__((gnu_inline)) void gnu_ei_inline() {} void (*P)() = gnu_ei_inline; // <rdar://problem/6818429> int test1(); -inline int test1() { return 4; } -inline int test2() { return 5; } -inline int test2(); +__inline int test1() { return 4; } +__inline int test2() { return 5; } +__inline int test2(); int test2(); void test_test1() { test1(); } void test_test2() { test2(); } // PR3989 -extern inline void test3() __attribute__((gnu_inline)); -inline void test3() {} +extern __inline void test3() __attribute__((gnu_inline)); +__inline void test3() {} diff --git a/clang/test/Parser/attributes.c b/clang/test/Parser/attributes.c index 37fa0ca1d36..dc2bb02670c 100644 --- a/clang/test/Parser/attributes.c +++ b/clang/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); diff --git a/clang/test/Parser/declarators.c b/clang/test/Parser/declarators.c index a4b2aad09d8..26e8027d107 100644 --- a/clang/test/Parser/declarators.c +++ b/clang/test/Parser/declarators.c @@ -63,4 +63,4 @@ struct xyz test8() { return a; } // a should be be marked invalid, no diag. static f; // expected-warning {{type specifier missing, defaults to 'int'}} static g = 4; // expected-warning {{type specifier missing, defaults to 'int'}} static h // expected-warning {{type specifier missing, defaults to 'int'}} - __asm__("foo"); // expected-warning {{extension used}} + __asm__("foo"); diff --git a/clang/test/Parser/recovery.c b/clang/test/Parser/recovery.c index 3f2d48d0f70..89eac564a32 100644 --- a/clang/test/Parser/recovery.c +++ b/clang/test/Parser/recovery.c @@ -11,7 +11,7 @@ float test2241[2] = { static char *f (char * (*g) (char **, int), char **p, ...) { char *s; va_list v; // expected-error {{identifier}} - s = g (p, __builtin_va_arg(v, int)); // expected-error {{identifier}} expected-warning {{extension}} + s = g (p, __builtin_va_arg(v, int)); // expected-error {{identifier}} } diff --git a/clang/test/Preprocessor/extension-warning.c b/clang/test/Preprocessor/extension-warning.c index 00c9b8735f3..7b5095f6e92 100644 --- a/clang/test/Preprocessor/extension-warning.c +++ b/clang/test/Preprocessor/extension-warning.c @@ -2,9 +2,17 @@ // The preprocessor shouldn't warn about extensions within macro bodies that // aren't expanded. -#define __block __attribute__((__blocks__(byref))) +#define TY typeof +#define TY1 typeof(1) -// This warning is entirely valid. -__block int x; // expected-warning{{extension used}} +// But we should warn here +TY1 x; // expected-warning {{extension}} +TY(1) x; // FIXME: And we should warn here + +// Note: this warning intentionally doesn't trigger on keywords like +// __attribute; the standard allows implementation-defined extensions +// prefixed with "__". +// Current list of keywords this can trigger on: +// inline, restrict, asm, typeof, _asm void whatever() {} diff --git a/clang/test/Sema/builtins.c b/clang/test/Sema/builtins.c index 0781abc7b9e..ce7c3484fd8 100644 --- a/clang/test/Sema/builtins.c +++ b/clang/test/Sema/builtins.c @@ -32,7 +32,7 @@ void cfstring() { } -typedef __attribute__(( ext_vector_type(16) )) unsigned char uchar16; // expected-warning {{extension}} +typedef __attribute__(( ext_vector_type(16) )) unsigned char uchar16; // rdar://5905347 unsigned char foo( short v ) { diff --git a/clang/test/Sema/constant-builtins.c b/clang/test/Sema/constant-builtins.c index 3914641751d..f8cea33d676 100644 --- a/clang/test/Sema/constant-builtins.c +++ b/clang/test/Sema/constant-builtins.c @@ -13,7 +13,7 @@ long double g5 = __builtin_infl(); extern int f(); -int h0 = __builtin_types_compatible_p(int,float); // expected-warning {{extension}} +int h0 = __builtin_types_compatible_p(int,float); //int h1 = __builtin_choose_expr(1, 10, f()); //int h2 = __builtin_expect(0, 0); diff --git a/clang/test/Sema/exprs.c b/clang/test/Sema/exprs.c index d92141ce1df..f85e2fc4141 100644 --- a/clang/test/Sema/exprs.c +++ b/clang/test/Sema/exprs.c @@ -51,7 +51,7 @@ void test7(int *P, _Complex float Gamma) { // rdar://6095061 int test8(void) { int i; - __builtin_choose_expr (0, 42, i) = 10; // expected-warning {{extension used}} + __builtin_choose_expr (0, 42, i) = 10; return i; } @@ -60,8 +60,8 @@ int test8(void) { struct f { int x : 4; float y[]; }; int test9(struct f *P) { int R; - R = __alignof(P->x); // expected-error {{invalid application of '__alignof' to bitfield}} expected-warning {{extension used}} - R = __alignof(P->y); // ok. expected-warning {{extension used}} + R = __alignof(P->x); // expected-error {{invalid application of '__alignof' to bitfield}} + R = __alignof(P->y); // ok. R = sizeof(P->x); // expected-error {{invalid application of 'sizeof' to bitfield}} return R; } @@ -98,8 +98,8 @@ void test13( // rdar://6326239 - Vector comparisons are not fully trusted yet, until the // backend is known to work, just unconditionally reject them. void test14() { - typedef long long __m64 __attribute__((__vector_size__(8))); // expected-warning {{extension used}} - typedef short __v4hi __attribute__((__vector_size__(8))); // expected-warning {{extension used}} + typedef long long __m64 __attribute__((__vector_size__(8))); + typedef short __v4hi __attribute__((__vector_size__(8))); __v4hi a; __m64 mask = (__m64)((__v4hi)a > // expected-error {{comparison of vector types ('__v4hi' and '__v4hi') not supported yet}} diff --git a/clang/test/Sema/function.c b/clang/test/Sema/function.c index 8b5c8572076..c9d8630c47f 100644 --- a/clang/test/Sema/function.c +++ b/clang/test/Sema/function.c @@ -64,11 +64,11 @@ struct incomplete_test a(void) {} // expected-error{{incomplete result type 'str extern __inline -__attribute__((__gnu_inline__)) // expected-warning{{extension used}} +__attribute__((__gnu_inline__)) void gnu_inline1() {} void -__attribute__((__gnu_inline__)) // expected-warning {{'gnu_inline' attribute requires function to be marked 'inline', attribute ignored}} expected-warning{{extension used}} +__attribute__((__gnu_inline__)) // expected-warning {{'gnu_inline' attribute requires function to be marked 'inline', attribute ignored}} gnu_inline2() {} diff --git a/clang/test/Sema/i-c-e.c b/clang/test/Sema/i-c-e.c index 6afe035e1cf..de279669922 100644 --- a/clang/test/Sema/i-c-e.c +++ b/clang/test/Sema/i-c-e.c @@ -61,6 +61,6 @@ int illegaldiv1[1 || 1/0]; int illegaldiv2[1/0]; // expected-error {{variable length array declaration not allowed at file scope}} int illegaldiv3[INT_MIN / -1]; // expected-error {{variable length array declaration not allowed at file scope}} -int chooseexpr[__builtin_choose_expr(1, 1, expr)]; // expected-warning {{extension used}} -int realop[(__real__ 4) == 4 ? 1 : -1]; // expected-warning {{extension used}} -int imagop[(__imag__ 4) == 0 ? 1 : -1]; // expected-warning {{extension used}} +int chooseexpr[__builtin_choose_expr(1, 1, expr)]; +int realop[(__real__ 4) == 4 ? 1 : -1]; +int imagop[(__imag__ 4) == 0 ? 1 : -1]; |