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 01/11] __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 02/11] 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 03/11] 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 04/11] 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 05/11] 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 06/11] 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 07/11] 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 08/11] 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. >From 7535e9ac239911cef2c3d40f93ae2c1c34095fe1 Mon Sep 17 00:00:00 2001 From: Aidan <aidan.goldf...@mail.mcgill.ca> Date: Mon, 27 Jan 2025 13:03:56 -0500 Subject: [PATCH 09/11] updated LanguageExtension.rst --- clang/docs/LanguageExtensions.rst | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/clang/docs/LanguageExtensions.rst b/clang/docs/LanguageExtensions.rst index c42b88015e2695..9fe66cfef79103 100644 --- a/clang/docs/LanguageExtensions.rst +++ b/clang/docs/LanguageExtensions.rst @@ -515,8 +515,7 @@ __nullptr --------- ``__nullptr`` is an alternate spelling for ``nullptr``, but is also available in -C++ modes prior to C++11. Note that it's currently not availbale in C despite -C23 having support for ``nullptr``. +C++ modes prior to C++11. It is available in C++ modes prior to C++11 and is available in C as of C23. __signed, __signed__ -------------------- >From 66dd17709cbc69cf5e36f3b4ace0e051fa71cf0b Mon Sep 17 00:00:00 2001 From: Aidan <aidan.goldf...@mail.mcgill.ca> Date: Mon, 27 Jan 2025 13:06:35 -0500 Subject: [PATCH 10/11] updated LanguageExtension.rst --- clang/docs/LanguageExtensions.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clang/docs/LanguageExtensions.rst b/clang/docs/LanguageExtensions.rst index 9fe66cfef79103..2059bfd7eddeb2 100644 --- a/clang/docs/LanguageExtensions.rst +++ b/clang/docs/LanguageExtensions.rst @@ -515,7 +515,7 @@ __nullptr --------- ``__nullptr`` is an alternate spelling for ``nullptr``, but is also available in -C++ modes prior to C++11. It is available in C++ modes prior to C++11 and is available in C as of C23. +C++ modes prior to C++11. It is available since C++98 and C23. __signed, __signed__ -------------------- >From 7433e81a7c034ab6523df8611fb7303c3613fdf5 Mon Sep 17 00:00:00 2001 From: Aidan <aidan.goldf...@mail.mcgill.ca> Date: Mon, 27 Jan 2025 13:07:50 -0500 Subject: [PATCH 11/11] updated LanguageExtension.rst --- clang/docs/LanguageExtensions.rst | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/clang/docs/LanguageExtensions.rst b/clang/docs/LanguageExtensions.rst index 2059bfd7eddeb2..7c92b0a98126e0 100644 --- a/clang/docs/LanguageExtensions.rst +++ b/clang/docs/LanguageExtensions.rst @@ -514,8 +514,7 @@ available in all language modes. __nullptr --------- -``__nullptr`` is an alternate spelling for ``nullptr``, but is also available in -C++ modes prior to C++11. It is available since C++98 and C23. +``__nullptr`` is an alternate spelling for ``nullptr``, it is available since C++98 and C23. __signed, __signed__ -------------------- _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits