r262888 - Move [[nodiscard]] tests into test/CXX tree.

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


Author: rsmith
Date: Mon Mar  7 18:44:49 2016
New Revision: 262888

URL: http://llvm.org/viewvc/llvm-project?rev=262888&view=rev
Log:
Move [[nodiscard]] tests into test/CXX tree.

Added:
    cfe/trunk/test/CXX/dcl.dcl/dcl.attr/dcl.attr.nodiscard/
    cfe/trunk/test/CXX/dcl.dcl/dcl.attr/dcl.attr.nodiscard/p2.cpp
      - copied, changed from r262887, cfe/trunk/test/SemaCXX/nodiscard.cpp
    cfe/trunk/test/CXX/dcl.dcl/dcl.attr/dcl.attr.nodiscard/p3.cpp
Removed:
    cfe/trunk/test/SemaCXX/nodiscard.cpp

Copied: cfe/trunk/test/CXX/dcl.dcl/dcl.attr/dcl.attr.nodiscard/p2.cpp (from r262887, cfe/trunk/test/SemaCXX/nodiscard.cpp)
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/dcl.dcl/dcl.attr/dcl.attr.nodiscard/p2.cpp?p2=cfe/trunk/test/CXX/dcl.dcl/dcl.attr/dcl.attr.nodiscard/p2.cpp&p1=cfe/trunk/test/SemaCXX/nodiscard.cpp&r1=262887&r2=262888&rev=262888&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/nodiscard.cpp (original)
+++ cfe/trunk/test/CXX/dcl.dcl/dcl.attr/dcl.attr.nodiscard/p2.cpp Mon Mar  7 18:44:49 2016
@@ -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 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

Added: cfe/trunk/test/CXX/dcl.dcl/dcl.attr/dcl.attr.nodiscard/p3.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/dcl.dcl/dcl.attr/dcl.attr.nodiscard/p3.cpp?rev=262888&view=auto
==============================================================================
--- cfe/trunk/test/CXX/dcl.dcl/dcl.attr/dcl.attr.nodiscard/p3.cpp (added)
+++ cfe/trunk/test/CXX/dcl.dcl/dcl.attr/dcl.attr.nodiscard/p3.cpp Mon Mar  7 18:44:49 2016
@@ -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
+}

Removed: cfe/trunk/test/SemaCXX/nodiscard.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/nodiscard.cpp?rev=262887&view=auto
==============================================================================
--- cfe/trunk/test/SemaCXX/nodiscard.cpp (original)
+++ cfe/trunk/test/SemaCXX/nodiscard.cpp (removed)
@@ -1,34 +0,0 @@
-// 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
-
-struct [[nodiscard]] S {};
-S get_s();
-S& get_s_ref();
-
-enum [[nodiscard]] E {};
-E get_e();
-
-[[nodiscard]] int get_i();
-
-void f() {
-  get_s(); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
-  get_i(); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
-  get_e(); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
-
-  // Okay, warnings are not encouraged
-  get_s_ref();
-  (void)get_s();
-  (void)get_i();
-  (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 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