https://github.com/AidanGoldfarb updated https://github.com/llvm/llvm-project/pull/123119
>From 51372333df218cfb4fa8dcc0cebee03c0e3ebc5f 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/3] __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 bd9fe6016717b805c37e7fce5ee70dddc6c42eb7 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/3] 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 7ec48387c8a3e9b831fd3c5b1400ad5e5ee32e21 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/3] 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. _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits