Reject auto combined with type specifiers in C++ - #208552
Merged
Merged
Conversation
This commit fixes several issues related to 'auto' type specifier handling.
Core implementation:
- Add ConflictingTypeSpecifier flag to DeclSpec to track when 'auto' conflicts
with another type specifier (e.g., 'auto int' or 'int auto'). This allows
Finish() to properly handle the conflict based on language mode rather than
immediately emitting an error during parsing.
1. Fix 'auto auto' duplicate detection: Keep TypeSpecType as TST_auto after
emitting error so subsequent checks can emit function-specific errors
(e.g., 'not allowed in function prototype').
2. Fix OpenCL 'auto' and 'register' storage class errors: Reorder checks to
prioritize OpenCL-specific handling before C++11+ checks. Use
SetStorageClassSpec to trigger OpenCL validation and emit version-specific
error messages.
3. Fix C23 'int auto' and 'constexpr int auto' handling:
- For 'constexpr int auto': Treat 'auto' as type specifier conflict (don't
convert to storage class), emit single error message.
- For 'int auto' without constexpr: Convert 'auto' to storage class specifier
(no type conflict error), only emit 'illegal storage class' if applicable.
4. Fix template parameter parsing: Skip type name lookup when 'auto' is set
in template parameter context to avoid false ambiguity errors for
placeholder variables.
5. Fix concept constraint syntax: Detect 'C<T> auto' pattern and skip type
conflict detection for concept constraints.
6. Update test expectations: Align error messages and line numbers with
actual diagnostic locations and behavior.
Signed-off-by: Osama Abdelkader <osama.abdelkader@gmail.com>
Signed-off-by: Osama Abdelkader <osama.abdelkader@gmail.com>
Signed-off-by: Osama Abdelkader <osama.abdelkader@gmail.com>
Signed-off-by: Osama Abdelkader <osama.abdelkader@gmail.com>
Signed-off-by: Osama Abdelkader <osama.abdelkader@gmail.com>
Signed-off-by: Osama Abdelkader <osama.abdelkader@gmail.com>
Signed-off-by: Osama Abdelkader <osama.abdelkader@gmail.com>
Signed-off-by: Osama Abdelkader <osama.abdelkader@gmail.com>
Signed-off-by: Osama Abdelkader <osama.abdelkader@gmail.com>
Signed-off-by: Osama Abdelkader <osama.abdelkader@gmail.com>
Signed-off-by: Osama Abdelkader <osama.abdelkader@gmail.com>
Signed-off-by: Osama Abdelkader <osama.abdelkader@gmail.com>
to268
reviewed
Jul 9, 2026
Endilll
reviewed
Jul 10, 2026
Endilll
left a comment
Contributor
There was a problem hiding this comment.
Can you make PR title and description more... descriptive?
Signed-off-by: Osama Abdelkader <osama.abdelkader@gmail.com>
Contributor
Author
|
Done. |
Endilll
reviewed
Jul 10, 2026
Endilll
left a comment
Contributor
There was a problem hiding this comment.
Changes to C++ DR tests LGTM
to268
approved these changes
Jul 10, 2026
to268
left a comment
Contributor
There was a problem hiding this comment.
The regression fix LGTM.
I will try to reland the PR probably this weekend.
Contributor
|
The PR looks like to have passed post CI checks (I have merged the PR when the buildbot was offline this morning). |
pedroMVicente
pushed a commit
to pedroMVicente/llvm-project
that referenced
this pull request
Jul 15, 2026
Follow-up of llvm#166004 - Diagnose C++ declarations that combine `auto` with another type specifier, such as `auto int` . - Preserve C/C23 handling where `auto` can still be interpreted as a storage-class specifier in valid combinations. - Fix parser disambiguation so `auto Use = 0` treats `Use` as the declarator name before type lookup, avoiding ambiguous lookup regressions. --------- Signed-off-by: Osama Abdelkader <osama.abdelkader@gmail.com>
vangthao95
reviewed
Jul 16, 2026
to268
added a commit
that referenced
this pull request
Jul 17, 2026
) 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.
dyung
pushed a commit
to llvmbot/llvm-project
that referenced
this pull request
Jul 22, 2026
…#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)
to268
added a commit
to to268/llvm-project
that referenced
this pull request
Aug 10, 2026
This reverts commit 72af746.
to268
added a commit
to to268/llvm-project
that referenced
this pull request
Aug 10, 2026
This reverts commit 72af746.
to268
added a commit
to to268/llvm-project
that referenced
this pull request
Aug 10, 2026
This reverts commit 72af746.
to268
added a commit
to to268/llvm-project
that referenced
this pull request
Aug 10, 2026
This reverts commit 25a419f.
to268
added a commit
to to268/llvm-project
that referenced
this pull request
Aug 10, 2026
This reverts commit 72af746.
to268
added a commit
that referenced
this pull request
Aug 11, 2026
…8552)" and follow-ups commits (#215320) The initial fix for #164273 had several follow up commits to fix the initial implementation. This fix induces a lot of regressions and a refactoring of the area is required in order to fix the issue in a later release. This reverts the following commits (from oldest to latest): 72af746 226acaf d592aa5 34436db de4b1f5
hulxv
pushed a commit
that referenced
this pull request
Aug 12, 2026
…8552)" and follow-ups commits (#215320) The initial fix for #164273 had several follow up commits to fix the initial implementation. This fix induces a lot of regressions and a refactoring of the area is required in order to fix the issue in a later release. This reverts the following commits (from oldest to latest): 72af746 226acaf d592aa5 34436db de4b1f5
dyung
pushed a commit
to to268/llvm-project
that referenced
this pull request
Aug 15, 2026
…m#208552)" and follow-ups commits (llvm#215320) The initial fix for llvm#164273 had several follow up commits to fix the initial implementation. This fix induces a lot of regressions and a refactoring of the area is required in order to fix the issue in a later release. This reverts the following commits (from oldest to latest): 72af746 226acaf d592aa5 34436db de4b1f5
zhangweize9-cyber
pushed a commit
to zhangweize9-cyber/llvm-project
that referenced
this pull request
Aug 16, 2026
…m#208552)" and follow-ups commits (llvm#215320) The initial fix for llvm#164273 had several follow up commits to fix the initial implementation. This fix induces a lot of regressions and a refactoring of the area is required in order to fix the issue in a later release. This reverts the following commits (from oldest to latest): 72af746 226acaf d592aa5 34436db de4b1f5
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up of #166004
autowith another type specifier, such asauto int.autocan still be interpreted as a storage-class specifier in valid combinations.auto Use = 0treatsUseas the declarator name before type lookup, avoiding ambiguous lookup regressions.