Skip to content

Commit be96277

Browse files
git merge main
2 parents d569eff + e98b202 commit be96277

File tree

18 files changed

+68
-89
lines changed

18 files changed

+68
-89
lines changed

clang/docs/LanguageExtensions.rst

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -514,9 +514,7 @@ available in all language modes.
514514
__nullptr
515515
---------
516516

517-
``__nullptr`` is an alternate spelling for ``nullptr``, but is also available in
518-
C++ modes prior to C++11. Note that it's currently not availbale in C despite
519-
C23 having support for ``nullptr``.
517+
``__nullptr`` is an alternate spelling for ``nullptr``. It is available in all C and C++ language modes.
520518

521519
__signed, __signed__
522520
--------------------

clang/docs/ReleaseNotes.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,7 @@ C Language Changes
388388

389389
- Extend clang's ``<limits.h>`` to define ``LONG_LONG_*`` macros for Android's bionic.
390390
- Macro ``__STDC_NO_THREADS__`` is no longer necessary for MSVC 2022 1939 and later.
391+
- Exposed the the ``__nullptr`` keyword as an alias for ``nullptr`` in all C language modes.
391392

392393
C2y Feature Support
393394
^^^^^^^^^^^^^^^^^^^
@@ -1003,7 +1004,6 @@ Bug Fixes to C++ Support
10031004
- Fixed assertions or false compiler diagnostics in the case of C++ modules for
10041005
lambda functions or inline friend functions defined inside templates (#GH122493).
10051006
- Clang now rejects declaring an alias template with the same name as its template parameter. (#GH123423)
1006-
- Fix that some dependent immediate expressions did not cause immediate escalation (#GH119046)
10071007
- Fixed the rejection of valid code when referencing an enumerator of an unscoped enum member with a prior declaration. (#GH124405)
10081008
- Fixed immediate escalation of non-dependent expressions. (#GH123405)
10091009
- Fix type of expression when calling a template which returns an ``__array_rank`` querying a type depending on a

clang/include/clang/Basic/TokenKinds.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -707,7 +707,7 @@ ALIAS("__decltype" , decltype , KEYCXX)
707707
ALIAS("__imag__" , __imag , KEYALL)
708708
ALIAS("__inline" , inline , KEYALL)
709709
ALIAS("__inline__" , inline , KEYALL)
710-
ALIAS("__nullptr" , nullptr , KEYCXX)
710+
ALIAS("__nullptr" , nullptr , KEYALL)
711711
ALIAS("__real__" , __real , KEYALL)
712712
ALIAS("__restrict" , restrict , KEYALL)
713713
ALIAS("__restrict__" , restrict , KEYALL)

clang/include/clang/Sema/Sema.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13139,10 +13139,10 @@ class Sema final : public SemaBase {
1313913139
~SynthesizedFunctionScope() {
1314013140
if (PushedCodeSynthesisContext)
1314113141
S.popCodeSynthesisContext();
13142-
13143-
if (auto *FD = dyn_cast<FunctionDecl>(S.CurContext))
13142+
if (auto *FD = dyn_cast<FunctionDecl>(S.CurContext)) {
1314413143
FD->setWillHaveBody(false);
13145-
13144+
S.CheckImmediateEscalatingFunctionDefinition(FD, S.getCurFunction());
13145+
}
1314613146
S.PopExpressionEvaluationContext();
1314713147
S.PopFunctionScopeInfo();
1314813148
}

clang/lib/Sema/SemaDecl.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16019,6 +16019,7 @@ Decl *Sema::ActOnFinishFunctionBody(Decl *dcl, Stmt *Body,
1601916019
if (!FD->isDeletedAsWritten())
1602016020
FD->setBody(Body);
1602116021
FD->setWillHaveBody(false);
16022+
CheckImmediateEscalatingFunctionDefinition(FD, FSI);
1602216023

1602316024
if (getLangOpts().CPlusPlus14) {
1602416025
if (!FD->isInvalidDecl() && Body && !FD->isDependentContext() &&

clang/lib/Sema/SemaExpr.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17881,9 +17881,6 @@ void Sema::PopExpressionEvaluationContext() {
1788117881
WarnOnPendingNoDerefs(Rec);
1788217882
HandleImmediateInvocations(*this, Rec);
1788317883

17884-
if (auto *FD = dyn_cast<FunctionDecl>(CurContext); FD && getCurFunction())
17885-
CheckImmediateEscalatingFunctionDefinition(FD, getCurFunction());
17886-
1788717884
// Warn on any volatile-qualified simple-assignments that are not discarded-
1788817885
// value expressions nor unevaluated operands (those cases get removed from
1788917886
// this list by CheckUnusedVolatileAssignment).

clang/test/CodeGenCXX/gh119046.cpp

Lines changed: 0 additions & 32 deletions
This file was deleted.

clang/test/Sema/nullptr-prec2x.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,7 @@ int nullptr; // expected-warning {{'nullptr' is a keyword in C23}}
66

77
nullptr_t val; // expected-error {{unknown type name 'nullptr_t'}}
88

9+
void foo(void *);
10+
void bar() { foo(__nullptr); } // Test that it converts properly to an arbitrary pointer type without warning
11+
_Static_assert(__nullptr == 0, "value of __nullptr"); // Test that its value matches that of NULL
12+
_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.

clang/test/Sema/nullptr.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,3 +108,10 @@ void test_f1() {
108108
int ir = (f1)(nullptr);
109109
}
110110

111+
// __nullptr keyword in C
112+
void foo(void *);
113+
void bar() { foo(__nullptr); }
114+
static_assert(nullptr == __nullptr);
115+
static_assert(__nullptr == 0); // Test that its value matches that of NULL
116+
static_assert(_Generic(typeof(__nullptr), nullptr_t: true, default: false));
117+
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.

clang/test/SemaCXX/cxx2b-consteval-propagate.cpp

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -529,23 +529,6 @@ D d(0); // expected-note {{in implicit initialization for inherited constructor
529529

530530
}
531531

532-
namespace GH119046 {
533-
534-
template <typename Cls> constexpr auto tfn(int) {
535-
return (unsigned long long)(&Cls::sfn);
536-
//expected-note@-1 {{'tfn<GH119046::S>' is an immediate function because its body evaluates the address of a consteval function 'sfn'}}
537-
};
538-
struct S { static consteval void sfn() {} };
539-
540-
int f() {
541-
int a = 0; // expected-note{{declared here}}
542-
return tfn<S>(a);
543-
//expected-error@-1 {{call to immediate function 'GH119046::tfn<GH119046::S>' is not a constant expression}}
544-
//expected-note@-2 {{read of non-const variable 'a' is not allowed in a constant expression}}
545-
}
546-
547-
}
548-
549532
namespace GH123405 {
550533

551534
consteval void fn() {}

0 commit comments

Comments
 (0)