[clang] [C++] Fix a crash with __thread and dependent types (PR #140542)

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Mon May 19 07:18:31 PDT 2025


================
@@ -14622,7 +14622,8 @@ void Sema::CheckCompleteVariableDeclaration(VarDecl *var) {
       Diag(var->getLocation(), diag::err_thread_nontrivial_dtor);
       if (getLangOpts().CPlusPlus11)
         Diag(var->getLocation(), diag::note_use_thread_local);
-    } else if (getLangOpts().CPlusPlus && var->hasInit()) {
+    } else if (getLangOpts().CPlusPlus && var->hasInit() &&
+               !var->getType()->isDependentType()) {
----------------
AaronBallman wrote:

Existing uses are fine The one case which could have been problematic is already checking that the initializer is not dependent.

https://github.com/llvm/llvm-project/pull/140542


More information about the cfe-commits mailing list