]> granicus.if.org Git - clang/commitdiff
Move [[nodiscard]] tests into test/CXX tree.
authorRichard Smith <richard-llvm@metafoo.co.uk>
Tue, 8 Mar 2016 00:44:49 +0000 (00:44 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Tue, 8 Mar 2016 00:44:49 +0000 (00:44 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@262888 91177308-0d34-0410-b5e6-96231b3b80d8

test/CXX/dcl.dcl/dcl.attr/dcl.attr.nodiscard/p2.cpp [moved from test/SemaCXX/nodiscard.cpp with 73% similarity]
test/CXX/dcl.dcl/dcl.attr/dcl.attr.nodiscard/p3.cpp [new file with mode: 0644]

similarity index 73%
rename from test/SemaCXX/nodiscard.cpp
rename to test/CXX/dcl.dcl/dcl.attr/dcl.attr.nodiscard/p2.cpp
index 4eb004c67dfeedd5f406318bea74df6e91a69d96..3d4b92518810bcbe9f6c9680c091bed62500b52f 100644 (file)
@@ -22,13 +22,8 @@ void f() {
   (void)get_e();
 }
 
-[[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}}
-
 #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
diff --git a/test/CXX/dcl.dcl/dcl.attr/dcl.attr.nodiscard/p3.cpp b/test/CXX/dcl.dcl/dcl.attr/dcl.attr.nodiscard/p3.cpp
new file mode 100644 (file)
index 0000000..a3543cf
--- /dev/null
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -std=c++1z -verify %s
+
+namespace std_example {
+  struct [[nodiscard]] error_info{
+    // ...
+  };
+
+  error_info enable_missile_safety_mode();
+  void launch_missiles();
+  void test_missiles() {
+    enable_missile_safety_mode(); // expected-warning {{ignoring return value of function declared with 'nodiscard'}}
+    launch_missiles();
+  }
+
+  error_info &foo();
+  void f() { foo(); } // no warning
+}