summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/cpp1z/nodiscard2.C
diff options
context:
space:
mode:
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>2016-04-28 19:01:19 +0000
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>2016-04-28 19:01:19 +0000
commitddd2a3d49aa496309f7ab3eebe1ded20da121b24 (patch)
tree0f443efe47d371ec7fe124b59afcaef0d9fe8d67 /gcc/testsuite/g++.dg/cpp1z/nodiscard2.C
parent3ae3cb42eba0091e719425ce61d3010b5cdbd430 (diff)
downloadgcc-ddd2a3d49aa496309f7ab3eebe1ded20da121b24.tar.gz
Implement C++17 [[nodiscard]] attribute.
PR c++/38172 PR c++/54379 gcc/c-family/ * c-lex.c (c_common_has_attribute): Handle nodiscard. gcc/cp/ * parser.c (cp_parser_std_attribute): Handle [[nodiscard]]. * tree.c (handle_nodiscard_attribute): New. (cxx_attribute_table): Add [[nodiscard]]. * cvt.c (cp_get_fndecl_from_callee, cp_get_callee_fndecl): New. (maybe_warn_nodiscard): New. (convert_to_void): Call it. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@235597 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/testsuite/g++.dg/cpp1z/nodiscard2.C')
-rw-r--r--gcc/testsuite/g++.dg/cpp1z/nodiscard2.C10
1 files changed, 10 insertions, 0 deletions
diff --git a/gcc/testsuite/g++.dg/cpp1z/nodiscard2.C b/gcc/testsuite/g++.dg/cpp1z/nodiscard2.C
new file mode 100644
index 00000000000..56022c3157a
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp1z/nodiscard2.C
@@ -0,0 +1,10 @@
+// { dg-do compile { target c++11 } }
+
+struct [[nodiscard]] A { }; // { dg-message "" }
+
+A f(); // { dg-message "" }
+
+int main()
+{
+ f(); // { dg-warning "Wunused-result" }
+}