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
diff --git a/test/CodeGen/inline.c b/test/CodeGen/inline.c
index 6011f42..7bdf76d 100644
--- a/test/CodeGen/inline.c
+++ b/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/test/Parser/attributes.c b/test/Parser/attributes.c
index 37fa0ca..dc2bb02 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);
 
diff --git a/test/Parser/declarators.c b/test/Parser/declarators.c
index a4b2aad..26e8027 100644
--- a/test/Parser/declarators.c
+++ b/test/Parser/declarators.c
@@ -63,4 +63,4 @@
 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/test/Parser/recovery.c b/test/Parser/recovery.c
index 3f2d48d..89eac56 100644
--- a/test/Parser/recovery.c
+++ b/test/Parser/recovery.c
@@ -11,7 +11,7 @@
 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/test/Preprocessor/extension-warning.c b/test/Preprocessor/extension-warning.c
index 00c9b87..7b5095f 100644
--- a/test/Preprocessor/extension-warning.c
+++ b/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/test/Sema/builtins.c b/test/Sema/builtins.c
index 0781abc..ce7c348 100644
--- a/test/Sema/builtins.c
+++ b/test/Sema/builtins.c
@@ -32,7 +32,7 @@
 }
 
 
-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/test/Sema/constant-builtins.c b/test/Sema/constant-builtins.c
index 3914641..f8cea33 100644
--- a/test/Sema/constant-builtins.c
+++ b/test/Sema/constant-builtins.c
@@ -13,7 +13,7 @@
 
 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/test/Sema/exprs.c b/test/Sema/exprs.c
index d92141c..f85e2fc 100644
--- a/test/Sema/exprs.c
+++ b/test/Sema/exprs.c
@@ -51,7 +51,7 @@
 // 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 @@
 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 @@
 // 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/test/Sema/function.c b/test/Sema/function.c
index 8b5c857..c9d8630 100644
--- a/test/Sema/function.c
+++ b/test/Sema/function.c
@@ -64,11 +64,11 @@
 
 
 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/test/Sema/i-c-e.c b/test/Sema/i-c-e.c
index 6afe035..de27966 100644
--- a/test/Sema/i-c-e.c
+++ b/test/Sema/i-c-e.c
@@ -61,6 +61,6 @@
 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];