blob: 151418f3c320a6dcda269a4507a6bcdc0853fc2d [file] [log] [blame]
/* { dg-do compile }
{ dg-options "-O1 -Wall -Wno-class-memaccess" } */
struct A { A (); };
const A& return_arg (const A &a)
{
return a;
}
void sink (const void*);
void nowarn_ref (int i)
{
const A &a = return_arg (A ()); // { dg-note "unnamed temporary" }
sink (&a); // { dg-warning "-Wdangling-pointer" }
}
void warn_dangling_ref (int i)
{
const A &a = return_arg (A ()); // { dg-note "unnamed temporary" }
sink (&a); // { dg-warning "-Wdangling-pointer" }
}