================
@@ -3775,7 +3775,9 @@ void Parser::ParseDeclarationSpecifiers(
// This identifier can only be a typedef name if we haven't already seen
// a type-specifier. Without this check we misparse:
// typedef int X; struct Y { short X; }; as 'short int'.
- if (DS.hasTypeSpecifier())
+ // However, if 'auto' is set, we need to check if this identifier is a
+ // type name to detect conflicts (e.g., "auto MyInt").
+ if (DS.hasTypeSpecifier() && DS.getTypeSpecType() != DeclSpec::TST_auto)
----------------
osamakader wrote:
This parser change exists to let Sema see auto combined with a following
typedef-name type specifier.
Previously, once auto was already parsed as a type specifier, this early exit
stopped parsing declaration specifiers before looking up the next identifier.
That meant cases like
```
typedef int MyInt;
auto MyInt x;
```
would stop at MyInt as if it were the declarator-id, instead of recognizing
MyInt as a second type specifier and letting DeclSpec::Finish() diagnose auto
plus another type specifier.
https://github.com/llvm/llvm-project/pull/166004
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits