brintos

brintos / llvm-project-archived public Read only

0
0
Text · 854 B · 2b909ec Raw
31 lines · cpp
1// RUN: %clang_cc1 -fsyntax-only -std=c++23 -verify %s2 3namespace GH140509 {4template <typename T>5void not_instantiated() {6  static __thread T my_wrapper;7}8 9template <typename T>10void instantiated() {11  static __thread T my_wrapper = T{}; // expected-error {{initializer for thread-local variable must be a constant expression}} \12                                         expected-note {{use 'thread_local' to allow this}}13}14 15template <typename T>16void nondependent_var() {17  // Verify that the dependence of the initializer is what really matters.18  static __thread int my_wrapper = T{};19}20 21struct S {22  S() {}23};24 25void f() {26  instantiated<int>();27  instantiated<S>(); // expected-note {{in instantiation of function template specialization 'GH140509::instantiated<GH140509::S>' requested here}}28  nondependent_var<int>();29}30} // namespace GH14050931