gcc/testsuite/g++.dg/cpp2a/constexpr-init5.C
raw| 1 | // PR c++/91353 - P1331R2: Allow trivial default init in constexpr contexts. |
| 2 | // { dg-do compile { target c++20 } } |
| 3 | |
| 4 | struct S { int i; }; |
| 5 | |
| 6 | constexpr void |
| 7 | fn () |
| 8 | { |
| 9 | S s; |
| 10 | |
| 11 | []() constexpr { |
| 12 | int i; |
| 13 | }(); |
| 14 | } |
| 15 | |
| 16 | constexpr int |
| 17 | fn2 () |
| 18 | { |
| 19 | return __extension__ ({ int n; n; }); // { dg-error "not usable in a constant expression" } |
| 20 | } |
| 21 | |
| 22 | constexpr int i = fn2 (); // { dg-message "in .constexpr. expansion of" } |