[mlir][acc] Introduce MappableType interface (#122146)
[llvm-project.git] / clang / test / CXX / dcl.dcl / dcl.spec / dcl.constexpr / p3-2b.cpp
blob8cb37ae6d1cdece52f94e0ced7643fa35fcb95a4
1 // RUN: %clang_cc1 -verify -std=c++23 -Wpre-c++23-compat %s
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;
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;
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;
23 constexpr void h() {
24 label:; // expected-warning {{use of this statement in a constexpr function is incompatible with C++ standards before C++23}}
27 struct NonLiteral { // expected-note 2 {{'NonLiteral' is not literal}}
28 NonLiteral() {}
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}}
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}}
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;
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;