[clang] [clang][C23] Delay thread storage recovery for constexpr diagnostics (PR #236758)

Mariya Podchishchaeva via cfe-commits cfe-commits at lists.llvm.org
Mon Nov 2 07:50:42 PST 2026


================
@@ -1398,16 +1400,20 @@ void DeclSpec::CheckTypeSpec(Sema &S, const PrintingPolicy &Policy) {
              diag::err_invalid_decl_spec_combination)
           << DeclSpec::getSpecifierName(getStorageClassSpec())
           << SourceRange(getStorageClassSpecLoc());
-      // Discard the thread storage class specifier to recover.
-      ThreadStorageClassSpec = TSCS_unspecified;
-      ThreadStorageClassSpecLoc = SourceLocation();
+      DiscardThreadStorageClassSpec = true;
     }
     if (S.getLangOpts().C23 &&
         getConstexprSpecifier() == ConstexprSpecKind::Constexpr) {
       S.Diag(ConstexprLoc, diag::err_invalid_decl_spec_combination)
           << DeclSpec::getSpecifierName(getThreadStorageClassSpec())
           << SourceRange(getThreadStorageClassSpecLoc());
     }
+    if (DiscardThreadStorageClassSpec) {
+      // Delay recovery until after diagnosing a possible constexpr conflict.
+      // FIXME: Clear C23ThreadLocalSpelling here when that field is added.
----------------
Fznamznon wrote:

I'm not sure it is great idea to reference nonexistent things yet. What if reviewers of the patch that adds this field won't like the idea or the name?

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


More information about the cfe-commits mailing list