Commit c0cc6260 by Paolo Carlini Committed by Paolo Carlini

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
parent a684432b
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):
......
......@@ -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);
......
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.
......
// { dg-do compile { target c++11 } }
struct A
{
[[nodiscard]] A();
};
void foo()
{
A(); // { dg-warning "ignoring return value" }
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment