]> granicus.if.org Git - clang/commitdiff
Define __has_cpp_attribute(fallthrough) to a more reasonable value. (What year is...
authorRichard Smith <richard-llvm@metafoo.co.uk>
Tue, 8 Mar 2016 00:40:32 +0000 (00:40 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Tue, 8 Mar 2016 00:40:32 +0000 (00:40 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@262887 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Basic/Attr.td
test/Preprocessor/has_attribute.cpp
test/SemaCXX/nodiscard.cpp

index 391d042681604093d077e1862d3accaeb881f05c..496e3951971f611dcc396d747cacbcda1698da9c 100644 (file)
@@ -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];
index 1ab45020b4443aaed9ccbc15d99853f7705990f5..2cfa005fb09faefe293e88cc3d4b150f827eb8de 100644 (file)
   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();
index e53cf9bb06fdcbf911f85b7819d1d0446822409a..4eb004c67dfeedd5f406318bea74df6e91a69d96 100644 (file)
@@ -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@4 {{use of the 'nodiscard' attribute is a C++1z extension}}
+// expected-warning@8 {{use of the 'nodiscard' attribute is a C++1z extension}}
+// expected-warning@11 {{use of the 'nodiscard' attribute is a C++1z extension}}
+// expected-warning@25 2{{use of the 'nodiscard' attribute is a C++1z extension}}
+#endif