Support the standards-based dates for __has_c_attribute
WG14 N2481 was adopted with minor modifications at the latest WG14 meetings.
The only modification to the paper was to correct the date for the deprecated
attribute to be 201904L (the corrected date value will be present in WG14
N2553 when it gets published).
diff --git a/clang/test/Preprocessor/has_c_attribute.c b/clang/test/Preprocessor/has_c_attribute.c
index f8b0b36..670e42a 100644
--- a/clang/test/Preprocessor/has_c_attribute.c
+++ b/clang/test/Preprocessor/has_c_attribute.c
@@ -1,22 +1,44 @@
-// RUN: %clang_cc1 -fdouble-square-bracket-attributes -std=c11 -E %s -o - | FileCheck %s
-// RUN: %clang_cc1 -std=c2x -E %s -o - | FileCheck %s
+// RUN: %clang_cc1 -fdouble-square-bracket-attributes -std=c11 -E -P %s -o - | FileCheck %s
+// RUN: %clang_cc1 -std=c2x -E -P %s -o - | FileCheck %s
-// CHECK: has_fallthrough
-#if __has_c_attribute(fallthrough)
- int has_fallthrough();
-#endif
+#define C2x(x) x: __has_c_attribute(x)
-// CHECK: does_not_have_selectany
-#if !__has_c_attribute(selectany)
- int does_not_have_selectany();
-#endif
+// CHECK: fallthrough: 201904L
+C2x(fallthrough)
-// CHECK: has_nodiscard_underscore
-#if __has_c_attribute(__nodiscard__)
- int has_nodiscard_underscore();
-#endif
+// CHECK: __nodiscard__: 201904L
+C2x(__nodiscard__)
-// CHECK: has_clang_annotate
-#if __has_c_attribute(clang::annotate)
- int has_clang_annotate();
-#endif
+// CHECK: selectany: 0
+C2x(selectany); // Known attribute not supported in C mode
+
+// CHECK: frobble: 0
+C2x(frobble) // Unknown attribute
+
+// CHECK: frobble::frobble: 0
+C2x(frobble::frobble) // Unknown vendor namespace
+
+// CHECK: clang::annotate: 1
+C2x(clang::annotate)
+
+// CHECK: deprecated: 201904L
+C2x(deprecated)
+
+// CHECK: maybe_unused: 201904L
+C2x(maybe_unused)
+
+// CHECK: __gnu__::warn_unused_result: 201904L
+C2x(__gnu__::warn_unused_result)
+
+// CHECK: gnu::__warn_unused_result__: 201904L
+C2x(gnu::__warn_unused_result__)
+
+// We do somewhat support the __clang__ vendor namespace, but it is a
+// predefined macro and thus we encourage users to use _Clang instead.
+// Because of this, we do not support __has_c_attribute for that
+// vendor namespace.
+//
+// Note, we can't use C2x here because it will expand __clang__ to 1
+// too early.
+// CHECK: 1::fallthrough: 0
+__clang__::fallthrough: __has_c_attribute(__clang__::fallthrough)