aboutsummaryrefslogtreecommitdiff
path: root/clang/test/SemaCXX/thread-specifier.cpp
blob: 2b909ecd175d04ed387b5ea83e6ad6ade0c7cd15 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// RUN: %clang_cc1 -fsyntax-only -std=c++23 -verify %s

namespace GH140509 {
template <typename T>
void not_instantiated() {
  static __thread T my_wrapper;
}

template <typename T>
void instantiated() {
  static __thread T my_wrapper = T{}; // expected-error {{initializer for thread-local variable must be a constant expression}} \
                                         expected-note {{use 'thread_local' to allow this}}
}

template <typename T>
void nondependent_var() {
  // Verify that the dependence of the initializer is what really matters.
  static __thread int my_wrapper = T{};
}

struct S {
  S() {}
};

void f() {
  instantiated<int>();
  instantiated<S>(); // expected-note {{in instantiation of function template specialization 'GH140509::instantiated<GH140509::S>' requested here}}
  nondependent_var<int>();
}
} // namespace GH140509