================
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++14 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++17 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++20 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++23 %s
+
+// Test that 'auto' cannot be combined with a type specifier in C++.
+void f() {
+ auto int x = 1; // expected-error {{'auto' cannot be combined with a
type specifier}}
----------------
osamakader wrote:
wait until `DeclSpec::Finish()` approach doesn't work because:
1. When SetTypeSpecType fails due to a conflict, it returns an error but
doesn't change TypeSpecType, so we can't detect the conflict in `Finish()`
2. We don't have access to the diagnostic ID or previous specifier in `Finish()`
3. The parser needs to emit the diagnostic, not `Finish()`
I tried that approach and it fails:
When SetTypeSpecType(int) is called after auto is set:
It returns an error, TypeSpecType remains TST_auto, so we can't tell in
`Finish()` that int was attempted.
https://github.com/llvm/llvm-project/pull/166004
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits