[Clang] Fixed auto parsing regression with brace initialization - #210347
Conversation
|
@llvm/pr-subscribers-clang Author: Tony Guillot (to268) ChangesThe PR #208552 has introduced a regression where brace initialization was not taken into account Full diff: https://github.com/llvm/llvm-project/pull/210347.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..5b0079a1ba898
--- /dev/null
+++ b/clang/test/CXX/dcl/dcl.spec/dcl.type/dcl.type.general/p2.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -std=c++2c -verify %s
+
+namespace bug {
+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};
+}
+} // namespace bug
|
🐧 Linux x64 Test Results
Failed Tests(click on a test name to see its output) Profile-x86_64Profile-x86_64.Linux/counter_promo_for.c (Likely Already Failing)This test is already failing at the base commit.Profile-x86_64.Linux/counter_promo_while.c (Likely Already Failing)This test is already failing at the base commit.If these failures are unrelated to your changes (for example tests are broken or flaky at HEAD), please open an issue at https://github.com/llvm/llvm-project/issues and add the |
1 similar comment
🐧 Linux x64 Test Results
Failed Tests(click on a test name to see its output) Profile-x86_64Profile-x86_64.Linux/counter_promo_for.c (Likely Already Failing)This test is already failing at the base commit.Profile-x86_64.Linux/counter_promo_while.c (Likely Already Failing)This test is already failing at the base commit.If these failures are unrelated to your changes (for example tests are broken or flaky at HEAD), please open an issue at https://github.com/llvm/llvm-project/issues and add the |
e4e59fd to
938aec5
Compare
938aec5 to
03d28e3
Compare
|
/cherry-pick d592aa5 |
|
/pull-request #210441 |
|
Thanks @to268 for the fix. |
…#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)
…ion (llvm#210347)" This reverts commit 9aeb3a9.
…on (llvm#210347)" This reverts commit d592aa5.
The PR #208552 has introduced a regression where brace initialization was not taken into account
auto foo{12}. It was also breakingdcl.type.generalp2 rules, which is also now tested.