Fix auto type-specifier conflict crash - #209308
Merged
Merged
Conversation
Clear owned type state when an invalid C++ auto/type-specifier conflict is converted to an error so invalid declarations cannot trip DeclSpec invariants. Signed-off-by: Osama Abdelkader <osama.abdelkader@gmail.com>
|
@llvm/pr-subscribers-clang Author: Osama Abdelkader (osamakader) ChangesClear owned type state when an invalid C++ auto/type-specifier conflict is converted to an error so invalid declarations cannot trip DeclSpec invariants. Fixes #209000 Full diff: https://github.com/llvm/llvm-project/pull/209308.diff 2 Files Affected:
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}}
|
cor3ntin
approved these changes
Jul 14, 2026
Contributor
Author
|
Thanks @cor3ntin for the review. Can you please merge it when it's suitable, since I don't have a permission to do so. |
pedroMVicente
pushed a commit
to pedroMVicente/llvm-project
that referenced
this pull request
Jul 15, 2026
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 llvm#209000
to268
added a commit
to to268/llvm-project
that referenced
this pull request
Aug 10, 2026
This reverts commit f71a5cc.
to268
added a commit
to to268/llvm-project
that referenced
this pull request
Aug 10, 2026
This reverts commit 226acaf.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 #209000