================
@@ -4095,11 +4095,22 @@ void Parser::ParseDeclarationSpecifiers(
case tok::kw_auto:
if (getLangOpts().CPlusPlus11 || getLangOpts().C23) {
if (isKnownToBeTypeSpecifier(GetLookAheadToken(1))) {
- isInvalid = DS.SetStorageClassSpec(Actions, DeclSpec::SCS_auto, Loc,
- PrevSpec, DiagID, Policy);
- if (!isInvalid && !getLangOpts().C23)
- Diag(Tok, diag::ext_auto_storage_class)
- << FixItHint::CreateRemoval(DS.getStorageClassSpecLoc());
+ // In C++ (not C23), 'auto' cannot be combined with a type specifier.
+ // However, OpenCL has its own error handling for this case.
----------------
osamakader wrote:
Without excluding OpenCL, the parser emitted our generic error "'auto' cannot
be combined with a type specifier" instead of the OpenCL-specific one.
The test clang/test/SemaOpenCL/storageclass.cl expects:
expected-error{{C++ for OpenCL version 2021 does not support the 'auto' storage
class specifier}}
or for OpenCL C:
expected-error-re{{OpenCL C version {{1.2|3.0}} does not support the 'auto'
storage class specifier}}
If we don't exclude OpenCL, the parser emits our error and the test fails
because it expects the OpenCL-specific message. Excluding OpenCL
(!getLangOpts().OpenCLCPlusPlus) lets Sema emit the OpenCL-specific error.
https://github.com/llvm/llvm-project/pull/166004
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits