release/23.x: [Clang] Fixed auto parsing regression with brace initialization (#210347) - #210441
Merged
Conversation
Member
Author
|
@cor3ntin @AaronBallman What do you think about merging this PR to the release branch? |
|
@llvm/pr-subscribers-clang Author: llvmbot ChangesBackport d592aa5 Requested by: @to268 Full diff: https://github.com/llvm/llvm-project/pull/210441.diff 2 Files Affected:
diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp
index 88f07bb104fcb..0825678acaf60 100644
--- a/clang/lib/Parse/ParseDecl.cpp
+++ b/clang/lib/Parse/ParseDecl.cpp
@@ -3879,10 +3879,10 @@ void Parser::ParseDeclarationSpecifiers(
// when a variable name matches a type brought in by a using-directive.
if (DS.getTypeSpecType() == DeclSpec::TST_auto) {
Token Next = NextToken();
- if (Next.isOneOf(tok::equal, tok::l_paren, tok::l_square, tok::amp,
- tok::ampamp, tok::star, tok::coloncolon, tok::comma,
- tok::semi, tok::colon, tok::greater, tok::r_paren,
- tok::arrow))
+ if (Next.isOneOf(tok::equal, tok::l_paren, tok::l_square, tok::l_brace,
+ tok::amp, tok::ampamp, tok::star, tok::coloncolon,
+ tok::comma, tok::semi, tok::colon, tok::greater,
+ tok::r_paren, tok::arrow))
goto DoneWithDeclSpec;
}
diff --git a/clang/test/CXX/dcl/dcl.spec/dcl.type/dcl.type.general/p2.cpp b/clang/test/CXX/dcl/dcl.spec/dcl.type/dcl.type.general/p2.cpp
new file mode 100644
index 0000000000000..2255cdf11309c
--- /dev/null
+++ b/clang/test/CXX/dcl/dcl.spec/dcl.type/dcl.type.general/p2.cpp
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -std=c++2c -verify %s
+
+void func1() {
+ typedef float foo; // expected-note {{previous definition is here}}
+ auto foo{16}; // expected-error {{redefinition of 'foo' as different kind of symbol}}
+}
+
+typedef float bar;
+void func2() {
+ auto bar{16};
+}
|
llvmbot
force-pushed
the
issue210347
branch
2 times, most recently
from
July 17, 2026 21:35
b726d3e to
065200a
Compare
cor3ntin
approved these changes
Jul 20, 2026
…#210347) The PR llvm#208552 has introduced a regression where brace initialization was not taken into account `auto foo{12}`. It was also breaking `dcl.type.general` p2 rules, which is also now tested. (cherry picked from commit d592aa5)
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.
Backport d592aa5
Requested by: @to268