-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[clang] Add __nullptr as a keyword to C #123119
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
Conversation
@llvm/pr-subscribers-clang Author: Aidan Goldfarb (AidanGoldfarb) ChangesThis PR resolves #121503. I was not sure whether I added my test in the correct place, and if so, if that deprecates nullptr-98.cpp Full diff: https://github.com/llvm/llvm-project/pull/123119.diff 2 Files Affected:
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
|
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.
Looking good overall, but this still needs a release note.
clang/test/Sema/nullptr.c
Outdated
@@ -108,3 +108,6 @@ void test_f1() { | |||
int ir = (f1)(nullptr); | |||
} | |||
|
|||
// __nullptr keyword in C | |||
void foo(void *); | |||
void bar() { foo(__nullptr); } |
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.
nit: missing newline at the end of the file
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.
Please be sure to also update clang/docs/ReleaseNotes.rst
so users know about the new functionality. Also, not signing you up for this work, but we really should document all of these keywords in clang/docs/LanguageExtensions.rst
. Maybe it's worth starting with this one and hopefully we can backfill the rest in the future?
static_assert(nullptr == __nullptr) and static_assert(_Generic(typeof(__nullptr), nullptr_t: true, default: false))
Removed duplicate test
Co-authored-by: Erich Keane <[email protected]>
Updating LanguageExtensions.rst before merge (and final reviews). |
26b0ef9
to
1138283
Compare
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.
LGTM aside from a change to the documentation. Thank you!
Co-authored-by: Aaron Ballman <[email protected]>
This PR resolves #121503.
I was not sure whether I added my test in the correct place, and if so, if that deprecates nullptr-98.cpp