Commit f4bb5c17 by Jakub Jelinek Committed by Jakub Jelinek

re PR c++/77591 (decltype(auto) and ternary operator allow returning local…

re PR c++/77591 (decltype(auto) and ternary operator allow returning local reference without a warning)

	PR c++/77591
	* typeck.c (maybe_warn_about_returning_address_of_local): Optimize
	whats_returned through fold_for_warn.

	* g++.dg/cpp1y/pr77591.C: New test.

From-SVN: r242924
parent 21b0f96a
2016-11-28 Jakub Jelinek <jakub@redhat.com>
PR c++/77591
* typeck.c (maybe_warn_about_returning_address_of_local): Optimize
whats_returned through fold_for_warn.
2016-11-27 Jason Merrill <jason@redhat.com>
PR c++/77907
......
......@@ -8612,7 +8612,7 @@ static bool
maybe_warn_about_returning_address_of_local (tree retval)
{
tree valtype = TREE_TYPE (DECL_RESULT (current_function_decl));
tree whats_returned = retval;
tree whats_returned = fold_for_warn (retval);
for (;;)
{
......
2016-11-28 Jakub Jelinek <jakub@redhat.com>
PR c++/77591
* g++.dg/cpp1y/pr77591.C: New test.
2016-11-28 David Edelsohn <dje.gcc@gmail.com>
* gcc.dg/torture/pr78515.c: Ignore ABI extension warning.
......
// PR c++/77591
// { dg-do compile { target c++14 } }
// { dg-options "-O0 -Wreturn-local-addr" }
class A { };
decltype(auto)
foo ()
{
A c; // { dg-warning "reference to local variable 'c' returned" }
return (c);
}
decltype(auto)
bar ()
{
A c; // { dg-warning "reference to local variable 'c' returned" }
return 1==1 ? c : c;
}
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