-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[Clang] [C23] Implement N2653: u8 strings are char8_t[] #97208
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
12 commits
Select commit
Hold shift + click to select a range
ef0072d
[Clang] [C23] Implement N2653: u8 strings are char8_t[]
MitalAshok d2594ad
Char array initialized from u8 string was fixed in C++20 as a DR
MitalAshok 6816f7f
Define ATOMIC_CHAR8_T_LOCK_FREE only when available
MitalAshok 63d4e4c
Merge branch 'main' into u8_uchar
MitalAshok 2480d5a
[Headers] Gate atomic_char8_t behind C23/C++20[-fchar8_t]
MitalAshok 8c6b2d0
Add __CHAR8_TYPE__ predefined macro to be compatible with GCC
MitalAshok 9253467
Tentatively remove macros/atomic_char8_t typedef in C++
MitalAshok e4f8055
Merge branch 'main' into u8_uchar
MitalAshok 5472f15
Use Clang header in test
MitalAshok 9cd683a
Remove test for <stdatomic.h> in C23/n2653.c
MitalAshok bda0aa8
Oops
MitalAshok c2528de
Merge branch 'main' into u8_uchar
cor3ntin 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,34 @@ | ||
// RUN: %clang_cc1 -ffreestanding -verify=c23 -std=c23 %s | ||
// RUN: %clang_cc1 -ffreestanding -verify=c17 -std=c17 %s | ||
|
||
// c23-no-diagnostics | ||
|
||
#include <stdatomic.h> | ||
|
||
#define __enable_constant_folding(x) (__builtin_constant_p(x) ? (x) : (x)) | ||
#define __is_same(a, b) (__extension__ _Generic(a, b: 1, default: 0) && __extension__ _Generic(b, a: 1, default: 0)) | ||
|
||
#ifndef ATOMIC_CHAR8_T_LOCK_FREE | ||
#error missing | ||
#endif | ||
// c17-error@-2 {{missing}} | ||
|
||
_Static_assert(__is_same(atomic_char8_t, unsigned char _Atomic), ""); | ||
// c17-error@-1 {{use of undeclared identifier 'atomic_char8_t'}} | ||
// c17-error@-2 {{unknown type name 'atomic_char8_t'}} | ||
|
||
_Static_assert(_Generic(u8"", unsigned char*: 1, char*: 0), ""); | ||
// c17-error@-1 {{static assertion failed}} | ||
|
||
// -fsigned-char is the default | ||
#define M(X) __enable_constant_folding((X) >= 0x80) | ||
|
||
_Static_assert(M(u8"\U000000E9"[0]), ""); | ||
// c17-error@-1 {{static assertion failed}} | ||
#if __STDC_VERSION__ >= 202311L | ||
_Static_assert(M(u8'\xC3'), ""); | ||
#endif | ||
|
||
const char cu8[] = u8"text"; | ||
const signed char scu8[] = u8"text"; | ||
const unsigned char ucu8[] = u8"text"; |
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.
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.
Uh oh!
There was an error while loading. Please reload this page.