https://github.com/osamakader created 
https://github.com/llvm/llvm-project/pull/210085

Guard hasTagDefinition() against invalid type-specifier state so recovery from 
invalid auto/tag combinations does not assert.
Fixes #210014 

>From ae6df644f97e3f2347ec992194385949324e55e0 Mon Sep 17 00:00:00 2001
From: Osama Abdelkader <[email protected]>
Date: Thu, 16 Jul 2026 17:38:30 +0200
Subject: [PATCH] [Clang] Avoid querying tag definitions for invalid DeclSpecs

Guard hasTagDefinition() against invalid type-specifier state so recovery from 
invalid auto/tag combinations does not assert.

Signed-off-by: Osama Abdelkader <[email protected]>
---
 clang/lib/Sema/DeclSpec.cpp       | 2 +-
 clang/test/SemaCXX/auto-cxx0x.cpp | 3 +++
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/clang/lib/Sema/DeclSpec.cpp b/clang/lib/Sema/DeclSpec.cpp
index 4d20657d5e517..9df12d0c4ce75 100644
--- a/clang/lib/Sema/DeclSpec.cpp
+++ b/clang/lib/Sema/DeclSpec.cpp
@@ -431,7 +431,7 @@ void DeclSpec::forEachQualifier(
 }
 
 bool DeclSpec::hasTagDefinition() const {
-  if (!TypeSpecOwned)
+  if (!TypeSpecOwned || !isDeclRep((TST)TypeSpecType))
     return false;
   return cast<TagDecl>(getRepAsDecl())->isCompleteDefinition();
 }
diff --git a/clang/test/SemaCXX/auto-cxx0x.cpp 
b/clang/test/SemaCXX/auto-cxx0x.cpp
index fa953f35723ef..ff2c98fce7523 100644
--- a/clang/test/SemaCXX/auto-cxx0x.cpp
+++ b/clang/test/SemaCXX/auto-cxx0x.cpp
@@ -14,6 +14,9 @@ void f() {
 struct PR209000 {
 } auto; // expected-error {{'auto' cannot be combined with a type specifier}}
 
+auto union { // expected-error {{cannot combine with previous 'auto' 
declaration specifier}}
+} foo<>; // expected-error {{no template named 'foo'}}
+
 typedef auto PR25449(); // expected-error {{'auto' not allowed in typedef}}
 
 thread_local auto x; // expected-error {{requires an initializer}}

_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to