Debian Codegraph @

clang/test/SemaCXX/thread-specifier.cpp

raw
1 // RUN: %clang_cc1 -fsyntax-only -std=c++23 -verify %s
2
3 namespace GH140509 {
4 template <typename T>
5 void not_instantiated() {
6 static __thread T my_wrapper;
7 }
8
9 template <typename T>
10 void 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
15 template <typename T>
16 void nondependent_var() {
17 // Verify that the dependence of the initializer is what really matters.
18 static __thread int my_wrapper = T{};
19 }
20
21 struct S {
22 S() {}
23 };
24
25 void 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 GH140509