| 1 |
// RUN: %clang_cc1 -verify -std=c++23 -Wpre-c++23-compat %s |
| 2 |
|
| 3 |
constexpr int h(int n) { |
| 4 |
if (!n) |
| 5 |
return 0; |
| 6 |
static const int m = n; // expected-warning {{definition of a static variable in a constexpr function is incompatible with C++ standards before C++23}} |
| 7 |
return m; |
| 8 |
} |
| 9 |
|
| 10 |
constexpr int i(int n) { |
| 11 |
if (!n) |
| 12 |
return 0; |
| 13 |
thread_local const int m = n; // expected-warning {{definition of a thread_local variable in a constexpr function is incompatible with C++ standards before C++23}} |
| 14 |
return m; |
| 15 |
} |
| 16 |
|
| 17 |
constexpr int g() { |
| 18 |
goto test; // expected-warning {{use of this statement in a constexpr function is incompatible with C++ standards before C++23}} |
| 19 |
test: |
| 20 |
return 0; |
| 21 |
} |
| 22 |
|
| 23 |
constexpr void h() { |
| 24 |
label:; // expected-warning {{use of this statement in a constexpr function is incompatible with C++ standards before C++23}} |
| 25 |
} |
| 26 |
|
| 27 |
struct NonLiteral { // expected-note 2 {{'NonLiteral' is not literal}} |
| 28 |
NonLiteral() {} |
| 29 |
}; |
| 30 |
|
| 31 |
constexpr void non_literal() { |
| 32 |
NonLiteral n; // expected-warning {{definition of a variable of non-literal type in a constexpr function is incompatible with C++ standards before C++23}} |
| 33 |
} |
| 34 |
|
| 35 |
constexpr void non_literal2(bool b) { |
| 36 |
if (!b) |
| 37 |
NonLiteral n; // expected-warning {{definition of a variable of non-literal type in a constexpr function is incompatible with C++ standards before C++23}} |
| 38 |
} |
| 39 |
|
| 40 |
constexpr int c_thread_local(int n) { |
| 41 |
if (!n) |
| 42 |
return 0; |
| 43 |
static _Thread_local int a; // expected-warning {{definition of a static variable in a constexpr function is incompatible with C++ standards before C++23}} |
| 44 |
_Thread_local int b; // // expected-error {{'_Thread_local' variables must have global storage}} |
| 45 |
return 0; |
| 46 |
} |
| 47 |
|
| 48 |
constexpr int gnu_thread_local(int n) { |
| 49 |
if (!n) |
| 50 |
return 0; |
| 51 |
static __thread int a; // expected-warning {{definition of a static variable in a constexpr function is incompatible with C++ standards before C++23}} |
| 52 |
__thread int b; // expected-error {{'__thread' variables must have global storage}} |
| 53 |
return 0; |
| 54 |
} |