[llvm-branch-commits] [clang] 9a93aae - [Clang] Fixed auto parsing regression with brace initialization (#210347)
Douglas Yung via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Wed Jul 22 06:51:25 PDT 2026
Author: Tony Guillot
Date: 2026-07-22T13:51:11Z
New Revision: 9a93aaef36ded17830dd27905f2e61dbe322d33c
URL: https://github.com/llvm/llvm-project/commit/9a93aaef36ded17830dd27905f2e61dbe322d33c
DIFF: https://github.com/llvm/llvm-project/commit/9a93aaef36ded17830dd27905f2e61dbe322d33c.diff
LOG: [Clang] Fixed auto parsing regression with brace initialization (#210347)
The PR #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 d592aa5a10f44164cd403257270802eb2a4b123a)
Added:
clang/test/CXX/dcl/dcl.spec/dcl.type/dcl.type.general/p2.cpp
Modified:
clang/lib/Parse/ParseDecl.cpp
Removed:
################################################################################
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
diff erent kind of symbol}}
+}
+
+typedef float bar;
+void func2() {
+ auto bar{16};
+}
More information about the llvm-branch-commits
mailing list