| 1 |
// RUN: %clang_cc1 %s -fsyntax-only -verify -std=c++20 |
| 2 |
|
| 3 |
void foo() { |
| 4 |
void fn(int i, int = ({ 1; })); // expected-error {{default argument may not use a GNU statement expression}} |
| 5 |
|
| 6 |
auto a = [](int = ({ 1; })) {}; // expected-error {{default argument may not use a GNU statement expression}} |
| 7 |
|
| 8 |
auto b = []<int = ({ 1; })>(){}; // expected-error {{default non-type template argument may not use a GNU statement expression}} |
| 9 |
|
| 10 |
void fn(int i, int j = ({{}, {}, {,}}), int k = ""); // expected-error {{default argument may not use a GNU statement expression}} expected-error {{cannot initialize a parameter of type 'int' with an lvalue of type 'const char[1]'}} expected-note {{passing argument to parameter 'k' here}} |
| 11 |
} |
| 12 |
|
| 13 |
template <int foo = ({ 1; })> // expected-error {{default non-type template argument may not use a GNU statement expression}} |
| 14 |
void f() {} |
| 15 |
|
| 16 |
template <int bar = ({ 1; })> // expected-error {{default non-type template argument may not use a GNU statement expression}} |
| 17 |
class S {}; |
| 18 |
|
| 19 |
template <typename Callable> |
| 20 |
int bar(Callable &&Call) { |
| 21 |
return Call(); |
| 22 |
} |
| 23 |
|
| 24 |
int baz() { |
| 25 |
auto l = [](int a = ({ int x = 12; x; })) { // expected-error {{default argument may not use a GNU statement expression}} |
| 26 |
return 1; |
| 27 |
}; |
| 28 |
return bar(l); |
| 29 |
} |