-
Notifications
You must be signed in to change notification settings - Fork 15.5k
[clang] Accept empty enum in MSVC compatible C #159981
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
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
77fc06c
[clang] Accept empty enum in MSVC compatible C
yicuixi 191eacf
Fix test
yicuixi e153bf2
Merge branch 'main' into ms-ext
yicuixi c106aaa
address comments
yicuixi 6bb40da
correct format
yicuixi d9ab0fe
Merge branch 'main' into ms-ext
yicuixi f573438
Merge branch 'main' into ms-ext
yicuixi b1cbba5
Update clang/docs/ReleaseNotes.rst
yicuixi 4dfd0fd
Merge branch 'main' into ms-ext
yicuixi 259e58d
[clang] Add CodeGen test to check the ABI compatibility
yicuixi 394ae9c
Fix test
yicuixi 5db9747
Update clang/docs/LanguageExtensions.rst
yicuixi 475b498
Update clang/docs/LanguageExtensions.rst
yicuixi a1232cd
Merge branch 'main' into ms-ext
yicuixi e515d11
Merge branch 'main' into ms-ext
yicuixi 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
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
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,7 @@ | ||
| // RUN: %clang_cc1 -fms-extensions -triple x86_64-windows-msvc -Wno-implicit-function-declaration -emit-llvm %s -o - | FileCheck %s | ||
| // RUN: %clang_cc1 -fms-extensions -triple i386-windows-msvc -Wno-implicit-function-declaration -emit-llvm %s -o - | FileCheck %s | ||
|
|
||
| typedef enum tag1 {} A; | ||
|
|
||
| // CHECK: void @empty_enum(i32 noundef %a) | ||
| void empty_enum(A a) {} |
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 @@ | ||
| // RUN: %clang_cc1 %s -fsyntax-only -Wmicrosoft -verify -fms-extensions | ||
|
|
||
| typedef enum tag1 { } A; // expected-warning {{empty enumeration types are a Microsoft extension}} | ||
| typedef enum tag2 { } B; // expected-warning {{empty enumeration types are a Microsoft extension}} | ||
| typedef enum : unsigned { } C; // expected-warning {{enumeration types with a fixed underlying type are a Microsoft extension}}\ | ||
| // expected-warning {{empty enumeration types are a Microsoft extension}} | ||
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.
This shouldn't warn 2x, the 'with a fixed underlying type' version is sufficient.
Also, isn't this a C23 extension, not a microsoft extension (or at least, as well)? See:
ext_c23_enum_fixed_underlying_type.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 review!
In microsoft-extension mode, it's
ext_ms_c_enum_fixed_underlying_typebut notext_ms_c_enum_fixed_underlying_type.Should we suppress the 2nd
empty enumeration types are a Microsoft extensionwarning? Seems they are 2 different 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.
I'm a little confused here as to the order of warnings/what we should do. I suspect @AaronBallman and I need to spend some time figuring out/discussing what we're looking for.
I'm not sure about the suppressing the 2nd warning, there is perhaps a 'we should do both' kinda thing since one might be disabled, but it also looks silly.
Ping this in another ~week and a half, and Aaron and I can discuss it (he should be back by then!).
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.
I think emitting two diagnostics is fine (one for the underlying type and one for the empty enum) because they are separate extensions. But I think it's a bit odd that we claim the underlying type is a Microsoft extension rather than a C23 extension -- that seems to be a preexisting issue which could be handled in a separate PR: https://godbolt.org/z/sMhGoE3qq