[clang] 226acaf - Fix auto type-specifier conflict crash (#209308)
via cfe-commits
cfe-commits at lists.llvm.org
Tue Jul 14 06:02:45 PDT 2026
Author: Osama Abdelkader
Date: 2026-07-14T15:02:39+02:00
New Revision: 226acaf7aeeda64a6e4e55d21f586ffe97a72fc8
URL: https://github.com/llvm/llvm-project/commit/226acaf7aeeda64a6e4e55d21f586ffe97a72fc8
DIFF: https://github.com/llvm/llvm-project/commit/226acaf7aeeda64a6e4e55d21f586ffe97a72fc8.diff
LOG: Fix auto type-specifier conflict crash (#209308)
Clear owned type state when an invalid C++ auto/type-specifier conflict
is converted to an error so invalid declarations cannot trip DeclSpec
invariants.
Fixes https://github.com/llvm/llvm-project/issues/209000
Added:
Modified:
clang/lib/Sema/DeclSpec.cpp
clang/test/SemaCXX/auto-cxx0x.cpp
Removed:
################################################################################
diff --git a/clang/lib/Sema/DeclSpec.cpp b/clang/lib/Sema/DeclSpec.cpp
index 3c882bc3a1003..4d20657d5e517 100644
--- a/clang/lib/Sema/DeclSpec.cpp
+++ b/clang/lib/Sema/DeclSpec.cpp
@@ -1349,6 +1349,7 @@ void DeclSpec::CheckTypeSpec(Sema &S, const PrintingPolicy &Policy) {
}
// Mark as error to prevent further processing
TypeSpecType = TST_error;
+ TypeSpecOwned = false;
} else if (!S.getLangOpts().CPlusPlus) {
// For C, C23, etc., convert 'auto' to storage class specifier
// (This is already handled above for C23, but keep for other C dialects)
diff --git a/clang/test/SemaCXX/auto-cxx0x.cpp b/clang/test/SemaCXX/auto-cxx0x.cpp
index a51b4798cbcb3..fa953f35723ef 100644
--- a/clang/test/SemaCXX/auto-cxx0x.cpp
+++ b/clang/test/SemaCXX/auto-cxx0x.cpp
@@ -11,6 +11,9 @@ void f() {
auto int arr[10]; // expected-error {{'auto' cannot be combined with a type specifier}}
}
+struct PR209000 {
+} auto; // expected-error {{'auto' cannot be combined with a type specifier}}
+
typedef auto PR25449(); // expected-error {{'auto' not allowed in typedef}}
thread_local auto x; // expected-error {{requires an initializer}}
More information about the cfe-commits
mailing list