r262887 - Define __has_cpp_attribute(fallthrough) to a more reasonable value. (What year is it?!)

Richard Smith via cfe-commits cfe-commits at lists.llvm.org
Mon Mar 7 16:40:32 PST 2016


Author: rsmith
Date: Mon Mar  7 18:40:32 2016
New Revision: 262887

URL: http://llvm.org/viewvc/llvm-project?rev=262887&view=rev
Log:
Define __has_cpp_attribute(fallthrough) to a more reasonable value. (What year is it?!)

Modified:
    cfe/trunk/include/clang/Basic/Attr.td
    cfe/trunk/test/Preprocessor/has_attribute.cpp
    cfe/trunk/test/SemaCXX/nodiscard.cpp

Modified: cfe/trunk/include/clang/Basic/Attr.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=262887&r1=262886&r2=262887&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/Attr.td (original)
+++ cfe/trunk/include/clang/Basic/Attr.td Mon Mar  7 18:40:32 2016
@@ -742,7 +742,7 @@ def ExtVectorType : Attr {
 }
 
 def FallThrough : StmtAttr {
-  let Spellings = [CXX11<"", "fallthrough", 201503>,
+  let Spellings = [CXX11<"", "fallthrough", 201603>,
                    CXX11<"clang", "fallthrough">];
 //  let Subjects = [NullStmt];
   let Documentation = [FallthroughDocs];

Modified: cfe/trunk/test/Preprocessor/has_attribute.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/has_attribute.cpp?rev=262887&r1=262886&r2=262887&view=diff
==============================================================================
--- cfe/trunk/test/Preprocessor/has_attribute.cpp (original)
+++ cfe/trunk/test/Preprocessor/has_attribute.cpp Mon Mar  7 18:40:32 2016
@@ -52,6 +52,16 @@
   int has_cxx14_deprecated_vers();
 #endif
 
+// CHECK: has_cxx1z_nodiscard
+#if __has_cpp_attribute(nodiscard) == 201603
+  int has_cxx1z_nodiscard();
+#endif
+
+// CHECK: has_cxx1z_fallthrough
+#if __has_cpp_attribute(fallthrough) == 201603
+  int has_cxx1z_fallthrough();
+#endif
+
 // CHECK: has_declspec_uuid
 #if __has_declspec_attribute(uuid)
   int has_declspec_uuid();

Modified: cfe/trunk/test/SemaCXX/nodiscard.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/nodiscard.cpp?rev=262887&r1=262886&r2=262887&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/nodiscard.cpp (original)
+++ cfe/trunk/test/SemaCXX/nodiscard.cpp Mon Mar  7 18:40:32 2016
@@ -1,9 +1,6 @@
 // RUN: %clang_cc1 -fsyntax-only -std=c++1z -verify -Wc++1z-extensions %s
 // RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify -DEXT -Wc++1z-extensions %s
 
-#if !defined(EXT)
-static_assert(__has_cpp_attribute(nodiscard) == 201603);
-
 struct [[nodiscard]] S {};
 S get_s();
 S& get_s_ref();
@@ -28,6 +25,10 @@ void f() {
 [[nodiscard nodiscard]] int wrong1(); // expected-error {{attribute 'nodiscard' cannot appear multiple times in an attribute specifier}}
 
 namespace [[nodiscard]] N {} // expected-warning {{'nodiscard' attribute only applies to functions, methods, enums, and classes}}
-#else
-struct [[nodiscard]] S {}; // expected-warning {{use of the 'nodiscard' attribute is a C++1z extension}}
-#endif // EXT
+
+#ifdef EXT
+// expected-warning at 4 {{use of the 'nodiscard' attribute is a C++1z extension}}
+// expected-warning at 8 {{use of the 'nodiscard' attribute is a C++1z extension}}
+// expected-warning at 11 {{use of the 'nodiscard' attribute is a C++1z extension}}
+// expected-warning at 25 2{{use of the 'nodiscard' attribute is a C++1z extension}}
+#endif




More information about the cfe-commits mailing list