From: Richard Smith Date: Tue, 8 Mar 2016 00:44:49 +0000 (+0000) Subject: Move [[nodiscard]] tests into test/CXX tree. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3dc9df61f84a944e7965523f60a817039379ceea;p=clang Move [[nodiscard]] tests into test/CXX tree. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@262888 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/test/SemaCXX/nodiscard.cpp b/test/CXX/dcl.dcl/dcl.attr/dcl.attr.nodiscard/p2.cpp similarity index 73% rename from test/SemaCXX/nodiscard.cpp rename to test/CXX/dcl.dcl/dcl.attr/dcl.attr.nodiscard/p2.cpp index 4eb004c67d..3d4b925188 100644 --- a/test/SemaCXX/nodiscard.cpp +++ b/test/CXX/dcl.dcl/dcl.attr/dcl.attr.nodiscard/p2.cpp @@ -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 index 0000000000..a3543cff7d --- /dev/null +++ b/test/CXX/dcl.dcl/dcl.attr/dcl.attr.nodiscard/p3.cpp @@ -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 +}