c++: robustify testcase [PR109752]
[official-gcc.git] / gcc / testsuite / g++.dg / cpp1y / decltype-auto6.C
blobda53278645c55d7044110a1e31d9ec22a77e7e71
1 // PR c++/101165 - P2266R1 - Simpler implicit move
2 // { dg-do compile { target c++14 } }
3 // A variant of cxx23/elision1.C:eight, just with ().
5 struct Widget {
6   Widget(Widget&&);
7 };
9 Widget val();
11 decltype(auto)
12 foo ()
14   decltype(auto) x = val();  // OK, x is Widget
15   // We deduce the return type to int&&, therefore we're doing something
16   // we ought not to be doing -- returning a reference to a local variable!
17   // In C++20, we deduce to int&, but that has the same problem!
18   return (x); // { dg-warning "reference to local variable" }