File tree Expand file tree Collapse file tree 3 files changed +37
-0
lines changed Expand file tree Collapse file tree 3 files changed +37
-0
lines changed Original file line number Diff line number Diff line change @@ -558,6 +558,9 @@ Improvements to Clang's diagnostics
558
558
between different Unicode character types (``char8_t ``, ``char16_t ``, ``char32_t ``).
559
559
This warning only triggers in C++ as these types are aliases in C. (#GH138526)
560
560
561
+ - Fixed a crash when checking a ``__thread ``-specified variable declaration
562
+ with a dependent type in C++. (#GH140509)
563
+
561
564
Improvements to Clang's time-trace
562
565
----------------------------------
563
566
Original file line number Diff line number Diff line change @@ -14608,6 +14608,10 @@ void Sema::CheckCompleteVariableDeclaration(VarDecl *var) {
14608
14608
std::optional<bool> CacheHasConstInit;
14609
14609
const Expr *CacheCulprit = nullptr;
14610
14610
auto checkConstInit = [&]() mutable {
14611
+ const Expr *Init = var->getInit();
14612
+ if (Init->isInstantiationDependent())
14613
+ return true;
14614
+
14611
14615
if (!CacheHasConstInit)
14612
14616
CacheHasConstInit = var->getInit()->isConstantInitializer(
14613
14617
Context, var->getType()->isReferenceType(), &CacheCulprit);
Original file line number Diff line number Diff line change
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
You can’t perform that action at this time.
0 commit comments