Repository navigation
diagnose auto deduction from void more specifically, fix for [GH #27] #206
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
nv-cmeerw
merged 10 commits into
edgcpp:main
from
mohitmishra786:gh-27-auto-void-diagnostic
Oct 9, 2026
+238
−62
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
748bb42
diagnose auto deduction from void more specifically. [GH #27]
mohitmishra786 61356ec
report an incomplete type when plain auto is deduced from void. [GH #27]
mohitmishra786 ed026f4
Keep the GH #27 Changes entry above the GH #213 note. [GH #27]
mohitmishra786 bcef7db
Keep the GH #27 Changes entry at the top of version 7.1. [GH #27]
mohitmishra786 90a5e26
Address review comments on the incomplete-auto deduction change. [GH …
mohitmishra786 aef05b9
Update recordings for auto deduction from an incomplete type. [GH #27]
mohitmishra786 3056726
Show why incomplete auto is not diagnosed in a template definition. […
mohitmishra786 a629bee
Place the GH #27 Changes entry above the GH #203 note. [GH #27]
mohitmishra786 d6f5618
Keep incomplete-type errors in template definitions outside GNU and M…
mohitmishra786 4589f92
Add only the GH #27 entry to Changes and record GH27_a for edg_x86_32…
mohitmishra786 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| fe_only -DTEST_NUMBER=1 --c++23 Test_name.c | ||
| "Test_name.c", line 27: error: incomplete type "void" is not allowed | ||
| auto v1 = void(); | ||
| ^ | ||
|
|
||
| "Test_name.c", line 28: error: incomplete type "void" is not allowed | ||
| decltype(auto) v2 = void(); | ||
| ^ | ||
|
|
||
| "Test_name.c", line 29: error: incomplete type "Incomplete" is not allowed | ||
| auto v3 = getIncomplete(); | ||
| ^ | ||
|
|
||
| "Test_name.c", line 30: error: incomplete type "void" is not allowed | ||
| auto opts = Args{}.parse(); | ||
| ^ | ||
|
|
||
| "Test_name.c", line 32: error: cannot deduce "auto" type | ||
| auto *v4 = void(); | ||
| ^ | ||
|
|
||
| "Test_name.c", line 33: error: cannot deduce "auto" type | ||
| auto *v5 = 1; | ||
| ^ | ||
|
|
||
| "Test_name.c", line 34: error: cannot deduce "auto" type | ||
| auto *p = g(); | ||
| ^ | ||
|
|
||
| 7 errors detected in the compilation of "Test_name.c". |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| fe_only -DTEST_NUMBER=1 --c++11 -A Test_name.c | ||
| "Test_name.c", line 14: error: incomplete type "void" is not allowed | ||
| auto v = void(); | ||
| ^ | ||
|
|
||
| "Test_name.c", line 20: error: incomplete type "void" is not allowed | ||
| auto v = void(); | ||
| ^ | ||
|
|
||
| "Test_name.c", line 29: error: incomplete type "Later" is not allowed | ||
| auto x = later_obj; | ||
| ^ | ||
|
|
||
| 3 errors detected in the compilation of "Test_name.c". |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| fe_only -DTEST_NUMBER=2 --c++11 --gnu_version 160200 Test_name.c | ||
| "Test_name.c", line 14: error: incomplete type "void" is not allowed | ||
| auto v = void(); | ||
| ^ | ||
|
|
||
| 1 error detected in the compilation of "Test_name.c". |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| fe_only -DTEST_NUMBER=3 --c++11 --clang_version 230100 Test_name.c | ||
| "Test_name.c", line 14: error: incomplete type "void" is not allowed | ||
| auto v = void(); | ||
| ^ | ||
|
|
||
| 1 error detected in the compilation of "Test_name.c". |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| fe_only -DTEST_NUMBER=4 --ms_c++20 --microsoft_version 1951 Test_name.c | ||
| "Test_name.c", line 14: error: incomplete type "void" is not allowed | ||
| auto v = void(); | ||
| ^ | ||
|
|
||
| 1 error detected in the compilation of "Test_name.c". |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| fe_only -DTEST_NUMBER=3 --c++11 --clang_version 230100 Test_name.c | ||
| "Test_name.c", line 14: error: incomplete type "void" is not allowed | ||
| auto v = void(); | ||
| ^ | ||
|
|
||
| "Test_name.c", line 20: error: incomplete type "void" is not allowed | ||
| auto v = void(); | ||
| ^ | ||
|
|
||
| "Test_name.c", line 29: error: incomplete type "Later" is not allowed | ||
| auto x = later_obj; | ||
| ^ | ||
|
|
||
| 3 errors detected in the compilation of "Test_name.c". |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| fe_only -DTEST_NUMBER=3 --c++11 --clang_version 230100 Test_name.c | ||
| "Test_name.c", line 14: error: incomplete type "void" is not allowed | ||
| auto v = void(); | ||
| ^ | ||
|
|
||
| "Test_name.c", line 20: error: incomplete type "void" is not allowed | ||
| auto v = void(); | ||
| ^ | ||
|
|
||
| "Test_name.c", line 29: error: incomplete type "Later" is not allowed | ||
| auto x = later_obj; | ||
| ^ | ||
|
|
||
| 3 errors detected in the compilation of "Test_name.c". |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| //type:fn | ||
| //options:--c++23 | ||
| //remark:[GH #27] Clearer diagnostic when auto deduces to void | ||
| // 10/9/26 [GH #27] | ||
| // | ||
| // A plain auto deduced from void or another incomplete type gets the | ||
| // incomplete-type diagnostic, matching decltype(auto). auto * still | ||
| // fails deduction. | ||
|
|
||
| struct Incomplete; | ||
|
|
||
| struct Incomplete &getIncomplete(); | ||
|
|
||
| struct Clap { | ||
| template <typename Spec> | ||
| auto parse(this Spec const& spec) { | ||
| } | ||
| }; | ||
|
|
||
| struct Args : Clap { | ||
| }; | ||
|
|
||
| void g(); | ||
|
|
||
| void f() | ||
| { | ||
| auto v1 = void(); | ||
| decltype(auto) v2 = void(); | ||
| auto v3 = getIncomplete(); | ||
| auto opts = Args{}.parse(); | ||
|
|
||
| auto *v4 = void(); | ||
| auto *v5 = 1; | ||
| auto *p = g(); | ||
| } | ||
|
|
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| //type:fn | ||
| //options:--c++11 -A:--c++11 --gnu_version 160200:--c++11 --clang_version 230100:--ms_c++20 --microsoft_version 1951 | ||
| //remark:[GH #27] Incomplete auto deduction in a template definition | ||
| // 10/9/26 [GH #27] | ||
| // | ||
| // In standard and Clang modes, a plain auto deduced from an incomplete | ||
| // type in a template definition gets the incomplete-type diagnostic. GCC | ||
| // and Microsoft don't diagnose that in a template definition, so in GNU and | ||
| // Microsoft modes the definition is still accepted. Outside a template, | ||
| // the incomplete-type diagnostic is issued in every mode. | ||
|
|
||
| void not_a_template() | ||
| { | ||
| auto v = void(); | ||
| } | ||
|
|
||
| template<int> | ||
| void use_void() | ||
| { | ||
| auto v = void(); | ||
| } | ||
|
|
||
| struct Later; | ||
| extern Later later_obj; | ||
|
|
||
| template<int> | ||
| void use_later() | ||
| { | ||
| auto x = later_obj; | ||
| } | ||
|
|
||
| struct Later { int n; }; | ||
|
|
||
| void call_later() | ||
| { | ||
| use_later<0>(); | ||
| } |
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
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
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
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
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
4 changes: 2 additions & 2 deletions
4
tests/tests/imported/clang/cpp/SemaCXX/.PR172001.rto/default.3.1.txt
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| fe_only -DTEST_NUMBER=3 --clang -tused -e 200 --no_wrap_diagnostics --clang_version 999999 --c++20 -DTEST3 Test_name.c | ||
| "Test_name.c", line 46: error: cannot deduce "auto" type | ||
| "Test_name.c", line 46: error: incomplete type "std::partial_ordering" is not allowed | ||
| auto res = a <=> b; | ||
| ^ | ||
| ^ | ||
|
|
||
| 1 error detected in the compilation of "Test_name.c". |
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The need for this change isn't entirely obvious. Was there any test case that would show undesirable results without this change? If so, it might be worth adding one example to your GH27.sft.cpp test to demonstrate the need for this change.
Thanks for your continued work on this issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes. Without that check, a template definition is diagnosed even when the type is completed before instantiation:
A deduction failure in the template definition is already suppressed in GNU and Microsoft modes. Diagnosing an incomplete type there instead turned decomp44 and decomp45 into errors. The check keeps that suppression. GH27 now has a --gnu_version run with this template, and it produces no diagnostic for use_later. The errors outside the template are unchanged.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the explanation.
Unfortunately, it's a bit more complicated. So GCC and MSVC don't diagnose substitution failures and incomplete-type errors in template definition. We are only emulating the substitution failure part, but because we treated an incomplete type deduction as a substitution failure we kind of emulated that part as well.
Your change would mean that for
auto var = void()inside a template definition we wouldn't get the "incomplete type" error in standard or Clang modes any more (but instead get the old deduction failure error).I think for now we'll have to duplicate the condition here:
and run the template definition test not just in GCC mode, but all possible modes, i.e.
--c++11 -A:--c++11 --gnu_version 160200:--c++11 --clang_version 230100:--ms_c++20 --microsoft_version 1951There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, that makes sense. I had folded the incomplete-type case into the GNU/Microsoft suppression, so standard and Clang modes went back to the deduction failure error for
auto var = void()in a template definition.I've used your condition and comment as is, so incomplete-type deduction is only failed in a template definition in GNU and Microsoft modes, where
prescan_initializer_for_auto_type_deductionthen allows it.The template definition test is now a separate test,
changes/GH27_a, becauseGH27needs--c++23for the explicit object parameter.GH27_aruns with--c++11 -A:--c++11 --gnu_version 160200:--c++11 --clang_version 230100:--ms_c++20 --microsoft_version 1951. It also has a non-templateauto v = void()so that every mode has an error, as the test type requires. Results:edg_x86_64_cp.3.1.txt). In the default config, Clang mode reports nothing inside an uninstantiated template body. That isn't specific to this change: a template body with noautoandint x = "s";isn't diagnosed there either.