https://github.com/AidanGoldfarb updated https://github.com/llvm/llvm-project/pull/123119
>From bc5d1419d94ac492c0fcf62a74844eb43ce17f1a Mon Sep 17 00:00:00 2001 From: Aidan <aidan.goldf...@mail.mcgill.ca> Date: Wed, 15 Jan 2025 15:24:12 -0500 Subject: [PATCH 1/8] __nullptr -> KEYALL, added relevant test --- clang/include/clang/Basic/TokenKinds.def | 2 +- clang/test/Sema/nullptr.c | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/clang/include/clang/Basic/TokenKinds.def b/clang/include/clang/Basic/TokenKinds.def index 2c692c999bdff5..8902a20b07ffa8 100644 --- a/clang/include/clang/Basic/TokenKinds.def +++ b/clang/include/clang/Basic/TokenKinds.def @@ -707,7 +707,7 @@ ALIAS("__decltype" , decltype , KEYCXX) ALIAS("__imag__" , __imag , KEYALL) ALIAS("__inline" , inline , KEYALL) ALIAS("__inline__" , inline , KEYALL) -ALIAS("__nullptr" , nullptr , KEYCXX) +ALIAS("__nullptr" , nullptr , KEYALL) ALIAS("__real__" , __real , KEYALL) ALIAS("__restrict" , restrict , KEYALL) ALIAS("__restrict__" , restrict , KEYALL) diff --git a/clang/test/Sema/nullptr.c b/clang/test/Sema/nullptr.c index d11765a9c881a1..64095fc00691cd 100644 --- a/clang/test/Sema/nullptr.c +++ b/clang/test/Sema/nullptr.c @@ -108,3 +108,6 @@ void test_f1() { int ir = (f1)(nullptr); } +// __nullptr keyword in C +void foo(void *); +void bar() { foo(__nullptr); } \ No newline at end of file >From 7230332a3e9c95f547ffb9eaf76add48666e1e67 Mon Sep 17 00:00:00 2001 From: Aidan Goldfarb <47676355+aidangoldf...@users.noreply.github.com> Date: Fri, 17 Jan 2025 12:00:04 -0500 Subject: [PATCH 2/8] Added additional tests static_assert(nullptr == __nullptr) and static_assert(_Generic(typeof(__nullptr), nullptr_t: true, default: false)) --- clang/test/Sema/nullptr.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/clang/test/Sema/nullptr.c b/clang/test/Sema/nullptr.c index 64095fc00691cd..ca2a8aa064caf3 100644 --- a/clang/test/Sema/nullptr.c +++ b/clang/test/Sema/nullptr.c @@ -110,4 +110,6 @@ void test_f1() { // __nullptr keyword in C void foo(void *); -void bar() { foo(__nullptr); } \ No newline at end of file +void bar() { foo(__nullptr); } +static_assert(nullptr == __nullptr); +static_assert(_Generic(typeof(__nullptr), nullptr_t: true, default: false)); >From ff8bf0dace7912ecb64d8a2114a1b465071908ad Mon Sep 17 00:00:00 2001 From: Aidan Goldfarb <47676355+aidangoldf...@users.noreply.github.com> Date: Sat, 18 Jan 2025 11:56:02 -0500 Subject: [PATCH 3/8] Update nullptr.c --- clang/test/Sema/nullptr.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/clang/test/Sema/nullptr.c b/clang/test/Sema/nullptr.c index ca2a8aa064caf3..bbe3d4c2ece7ff 100644 --- a/clang/test/Sema/nullptr.c +++ b/clang/test/Sema/nullptr.c @@ -113,3 +113,8 @@ void foo(void *); void bar() { foo(__nullptr); } static_assert(nullptr == __nullptr); static_assert(_Generic(typeof(__nullptr), nullptr_t: true, default: false)); + +void foo(struct S *); +void bar() { foo(__nullptr); } // Test that it converts properly to an arbitrary pointer type without warning +_Static_assert(__nullptr == 0); // Test that its value matches that of NULL +_Static_assert(_Generic(__typeof(__nullptr), int : 0, void * : 0, default : 1)); // Test that it's type is not the same as what NULL would generally have. >From 87c8b673863ccc7f17eeb2da02ab1c4a6f64de40 Mon Sep 17 00:00:00 2001 From: Aidan Goldfarb <47676355+aidangoldf...@users.noreply.github.com> Date: Sat, 18 Jan 2025 12:04:37 -0500 Subject: [PATCH 4/8] Update ReleaseNotes.rst --- clang/docs/ReleaseNotes.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 031c5d84e49f97..f234edc7920352 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -387,7 +387,11 @@ C Language Changes ------------------ - Extend clang's ``<limits.h>`` to define ``LONG_LONG_*`` macros for Android's bionic. +<<<<<<< HEAD - Macro ``__STDC_NO_THREADS__`` is no longer necessary for MSVC 2022 1939 and later. +======= +- Added support for the ``__nullptr`` keyword. +>>>>>>> cfda1e8d3bf6 (Update ReleaseNotes.rst) C2y Feature Support ^^^^^^^^^^^^^^^^^^^ >From bb08c09d1a7c2b4ceac6e7868680e0111f531909 Mon Sep 17 00:00:00 2001 From: Aidan Goldfarb <47676355+aidangoldf...@users.noreply.github.com> Date: Sat, 18 Jan 2025 12:20:46 -0500 Subject: [PATCH 5/8] Update nullptr.c Removed duplicate test --- clang/test/Sema/nullptr.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/clang/test/Sema/nullptr.c b/clang/test/Sema/nullptr.c index bbe3d4c2ece7ff..b5d99ab89f5814 100644 --- a/clang/test/Sema/nullptr.c +++ b/clang/test/Sema/nullptr.c @@ -113,8 +113,5 @@ void foo(void *); void bar() { foo(__nullptr); } static_assert(nullptr == __nullptr); static_assert(_Generic(typeof(__nullptr), nullptr_t: true, default: false)); - -void foo(struct S *); -void bar() { foo(__nullptr); } // Test that it converts properly to an arbitrary pointer type without warning _Static_assert(__nullptr == 0); // Test that its value matches that of NULL _Static_assert(_Generic(__typeof(__nullptr), int : 0, void * : 0, default : 1)); // Test that it's type is not the same as what NULL would generally have. >From 514d5d6aa23e80be9059d0a09920c448f2a5b1e6 Mon Sep 17 00:00:00 2001 From: Aidan Goldfarb <agold...@u.rochester.edu> Date: Tue, 21 Jan 2025 10:34:24 -0500 Subject: [PATCH 6/8] Update clang/docs/ReleaseNotes.rst Co-authored-by: Erich Keane <eke...@nvidia.com> --- clang/docs/ReleaseNotes.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index f234edc7920352..3b42e175d1a600 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -388,10 +388,14 @@ C Language Changes - Extend clang's ``<limits.h>`` to define ``LONG_LONG_*`` macros for Android's bionic. <<<<<<< HEAD +<<<<<<< HEAD - Macro ``__STDC_NO_THREADS__`` is no longer necessary for MSVC 2022 1939 and later. ======= - Added support for the ``__nullptr`` keyword. >>>>>>> cfda1e8d3bf6 (Update ReleaseNotes.rst) +======= +- Exposed the the ``__nullptr`` keyword as an alias for ``nullptr`` in all C language modes. +>>>>>>> 8d00a2c3e77a (Update clang/docs/ReleaseNotes.rst) C2y Feature Support ^^^^^^^^^^^^^^^^^^^ >From e9fc782e145902f241239fa1304c07ecca5a3fc5 Mon Sep 17 00:00:00 2001 From: Aidan <aidan.goldf...@mail.mcgill.ca> Date: Fri, 24 Jan 2025 15:38:39 -0500 Subject: [PATCH 7/8] added c17 tests --- clang/test/Sema/nullptr-prec2x.c | 4 ++++ clang/test/Sema/nullptr.c | 2 -- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/clang/test/Sema/nullptr-prec2x.c b/clang/test/Sema/nullptr-prec2x.c index 39479d4343a569..c516c448ca1ab4 100644 --- a/clang/test/Sema/nullptr-prec2x.c +++ b/clang/test/Sema/nullptr-prec2x.c @@ -6,3 +6,7 @@ int nullptr; // expected-warning {{'nullptr' is a keyword in C23}} nullptr_t val; // expected-error {{unknown type name 'nullptr_t'}} +void foo(void *); +void bar() { foo(__nullptr); } // Test that it converts properly to an arbitrary pointer type without warning +_Static_assert(__nullptr == 0, "value of __nullptr"); // Test that its value matches that of NULL +_Static_assert(_Generic(__typeof(__nullptr), int : 0, void * : 0, default : 1), "type of __nullptr"); // Test that it's type is not the same as what NULL would generally have. diff --git a/clang/test/Sema/nullptr.c b/clang/test/Sema/nullptr.c index b5d99ab89f5814..ca2a8aa064caf3 100644 --- a/clang/test/Sema/nullptr.c +++ b/clang/test/Sema/nullptr.c @@ -113,5 +113,3 @@ void foo(void *); void bar() { foo(__nullptr); } static_assert(nullptr == __nullptr); static_assert(_Generic(typeof(__nullptr), nullptr_t: true, default: false)); -_Static_assert(__nullptr == 0); // Test that its value matches that of NULL -_Static_assert(_Generic(__typeof(__nullptr), int : 0, void * : 0, default : 1)); // Test that it's type is not the same as what NULL would generally have. >From 113828317b7221342de5328ef18475a99bcc0e21 Mon Sep 17 00:00:00 2001 From: Aidan <aidan.goldf...@mail.mcgill.ca> Date: Fri, 24 Jan 2025 15:50:20 -0500 Subject: [PATCH 8/8] duplicated c17 tests in c2x --- clang/test/Sema/nullptr.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/clang/test/Sema/nullptr.c b/clang/test/Sema/nullptr.c index ca2a8aa064caf3..b8c371a418e3e0 100644 --- a/clang/test/Sema/nullptr.c +++ b/clang/test/Sema/nullptr.c @@ -112,4 +112,6 @@ void test_f1() { void foo(void *); void bar() { foo(__nullptr); } static_assert(nullptr == __nullptr); +static_assert(__nullptr == 0); // Test that its value matches that of NULL static_assert(_Generic(typeof(__nullptr), nullptr_t: true, default: false)); +static_assert(_Generic(__typeof(__nullptr), int : 0, void * : 0, default : 1)); // Test that it's type is not the same as what NULL would generally have. _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits