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
+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
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.
--- /dev/null
+// 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;
+}