brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.9 KiB · 8cb37ae Raw
55 lines · cpp
1// RUN: %clang_cc1 -verify -std=c++23 -Wpre-c++23-compat %s2 3constexpr 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 10constexpr 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 17constexpr int g() {18  goto test; // expected-warning {{use of this statement in a constexpr function is incompatible with C++ standards before C++23}}19test:20  return 0;21}22 23constexpr void h() {24label:; // expected-warning {{use of this statement in a constexpr function is incompatible with C++ standards before C++23}}25}26 27struct NonLiteral { // expected-note 2 {{'NonLiteral' is not literal}}28  NonLiteral() {}29};30 31constexpr 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 35constexpr 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 40constexpr 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 48constexpr 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}55