diff options
author | Paolo Carlini <paolo.carlini@oracle.com> | 2019-08-02 08:52:42 +0000 |
---|---|---|
committer | Paolo Carlini <paolo@gcc.gnu.org> | 2019-08-02 08:52:42 +0000 |
commit | c0cc62604f163289afaa37ba45f729ae31a45e71 (patch) | |
tree | 03ffffd8413791dc78564c7280967cb3393692db /gcc | |
parent | a684432bf771bb8b21a9737b50e64d774d9920c9 (diff) | |
download | gcc-c0cc62604f163289afaa37ba45f729ae31a45e71.zip gcc-c0cc62604f163289afaa37ba45f729ae31a45e71.tar.gz gcc-c0cc62604f163289afaa37ba45f729ae31a45e71.tar.bz2 |
tree.c (handle_nodiscard_attribute): Do not warn about nodiscard applied to a constructor.
/cp
2019-08-02 Paolo Carlini <paolo.carlini@oracle.com>
* tree.c (handle_nodiscard_attribute): Do not warn about nodiscard
applied to a constructor.
/testsuite
2019-08-02 Paolo Carlini <paolo.carlini@oracle.com>
* g++.dg/cpp1z/nodiscard6.C: New.
From-SVN: r274002
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/cp/tree.c | 3 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp1z/nodiscard6.C | 11 |
4 files changed, 22 insertions, 1 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index b7183ac..4843537 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2019-08-02 Paolo Carlini <paolo.carlini@oracle.com> + + * tree.c (handle_nodiscard_attribute): Do not warn about nodiscard + applied to a constructor. + 2019-08-02 Martin Liska <mliska@suse.cz> * decl.c (grok_op_properties): diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index 37e24a1..27bc351 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -4361,7 +4361,8 @@ handle_nodiscard_attribute (tree *node, tree name, tree /*args*/, { if (TREE_CODE (*node) == FUNCTION_DECL) { - if (VOID_TYPE_P (TREE_TYPE (TREE_TYPE (*node)))) + if (VOID_TYPE_P (TREE_TYPE (TREE_TYPE (*node))) + && !DECL_CONSTRUCTOR_P (*node)) warning_at (DECL_SOURCE_LOCATION (*node), OPT_Wattributes, "%qE attribute applied to %qD with void " "return type", name, *node); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 8dc95b9..58a26d1 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2019-08-02 Paolo Carlini <paolo.carlini@oracle.com> + + * g++.dg/cpp1z/nodiscard6.C: New. + 2019-08-02 Senthil Kumar Selvaraj <senthilkumar.selvaraj@microchip.com> * gcc.dg/torture/ssa-fre-5.c: Add dg-require-effective-target int32. diff --git a/gcc/testsuite/g++.dg/cpp1z/nodiscard6.C b/gcc/testsuite/g++.dg/cpp1z/nodiscard6.C new file mode 100644 index 0000000..d9813fc --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1z/nodiscard6.C @@ -0,0 +1,11 @@ +// { dg-do compile { target c++11 } } + +struct A +{ + [[nodiscard]] A(); +}; + +void foo() +{ + A(); // { dg-warning "ignoring return value" } +} |