-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[clang][sema] Add support and documentation for __has_extension(c_fixed_enum)
#117507
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
Changes from 7 commits
a6c9b5c
d9e0615
9fd4a25
53ba18d
8722c53
3a10186
7925096
e06f739
4a467b9
728a2d9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -156,13 +156,15 @@ FEATURE(objc_class_property, LangOpts.ObjC) | |||||
| FEATURE(objc_c_static_assert, LangOpts.C11) | ||||||
| FEATURE(objc_cxx_static_assert, LangOpts.CPlusPlus11) | ||||||
| EXTENSION(objc_c_static_assert, true) | ||||||
| // C11 features | ||||||
| // C11 features | ||||||
|
||||||
| FEATURE(c_alignas, LangOpts.C11) | ||||||
| FEATURE(c_alignof, LangOpts.C11) | ||||||
| FEATURE(c_atomic, LangOpts.C11) | ||||||
| FEATURE(c_generic_selections, LangOpts.C11) | ||||||
| FEATURE(c_static_assert, LangOpts.C11) | ||||||
| FEATURE(c_thread_local, LangOpts.C11 &&PP.getTargetInfo().isTLSSupported()) | ||||||
| // C23 features | ||||||
| FEATURE(c_fixed_enum, true) | ||||||
|
||||||
| FEATURE(c_fixed_enum, true) | |
| FEATURE(c_fixed_enum, LangOpts.C23) |
This is only a feature of C23, it's an extension in other modes.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -121,6 +121,16 @@ int NegativeShortTest[NegativeShort == -1 ? 1 : -1]; | |
| enum Color { Red, Green, Blue }; // expected-note{{previous use is here}} | ||
| typedef struct Color NewColor; // expected-error {{use of 'Color' with tag type that does not match previous declaration}} | ||
|
|
||
| // Enumerations with a fixed underlying type. | ||
| // https://github.com/llvm/llvm-project/issues/116880 | ||
| #if __STDC_VERSION__ >= 202311L && !__has_feature(c_fixed_enum) | ||
| #error c_fixed_enum should be set a feature in C23 mode | ||
| #elif __STDC_VERSION__ < 202311L && !__has_extension(c_fixed_enum) | ||
| #error c_fixed_enum should be a language extension in <C23 mode | ||
| #else | ||
| typedef enum : unsigned char { Pink, Black, Cyan } Color; // pre-c23-warning {{enumeration types with a fixed underlying type are a C23 extension}} | ||
| #endif | ||
|
||
|
|
||
| // PR28903 | ||
| // In C it is valid to define tags inside enums. | ||
| struct PR28903 { | ||
|
|
||
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.
We should probably update the wording here to mention
__has_featureand language version behavior.