145
|
1 // PR c++/84374 - diagnose invalid uses of decltype(auto).
|
|
2 // { dg-do compile { target c++14 } }
|
|
3
|
|
4 auto l = [](auto* r)->decltype(auto)* { return r; }; // { dg-error "as type rather than plain" }
|
|
5 auto m = [](auto* r)->decltype(auto)& { return *r; }; // { dg-error "as type rather than plain" }
|
|
6
|
|
7 decltype(auto)* f(); // { dg-error "as type rather than plain" }
|
|
8 decltype(auto)& f2(); // { dg-error "as type rather than plain" }
|
|
9 decltype(auto)* f3() { return 42; } // { dg-error "as type rather than plain" }
|
|
10 decltype(auto)& f4() { return 42; } // { dg-error "as type rather than plain" }
|
|
11
|
|
12
|
|
13 class C {
|
|
14 decltype(auto)* g(); // { dg-error "as type rather than plain" }
|
|
15 decltype(auto)& g2(); // { dg-error "as type rather than plain" }
|
|
16 decltype(auto)* g3() { } // { dg-error "as type rather than plain" }
|
|
17 decltype(auto)& g4() { } // { dg-error "as type rather than plain" }
|
|
18 };
|