File tree Expand file tree Collapse file tree 3 files changed +18
-1
lines changed Expand file tree Collapse file tree 3 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -525,6 +525,8 @@ Attribute Changes in Clang
525525
526526- The ``target_version `` attribute is now only supported for AArch64 and RISC-V architectures.
527527
528+ - Clang now permits ``[[msvc::constexpr]] `` usage outside of the std namespace. (#GH74924)
529+
528530Improvements to Clang's diagnostics
529531-----------------------------------
530532
Original file line number Diff line number Diff line change @@ -10172,7 +10172,9 @@ bool PointerExprEvaluator::VisitCXXNewExpr(const CXXNewExpr *E) {
1017210172 return false;
1017310173 IsNothrow = true;
1017410174 } else if (OperatorNew->isReservedGlobalPlacementOperator()) {
10175- if (Info.CurrentCall->isStdFunction() || Info.getLangOpts().CPlusPlus26) {
10175+ if (Info.CurrentCall->isStdFunction() || Info.getLangOpts().CPlusPlus26 ||
10176+ (Info.CurrentCall->CanEvalMSConstexpr &&
10177+ OperatorNew->hasAttr<MSConstexprAttr>())) {
1017610178 if (!EvaluatePointer(E->getPlacementArg(0), Result, Info))
1017710179 return false;
1017810180 if (Result.Designator.Invalid)
Original file line number Diff line number Diff line change 1+ // RUN: %clang_cc1 -fms-compatibility -fms-compatibility-version=19.33 -std=c++20 -ast-dump %s | FileCheck %s
2+
3+ // CHECK: used operator new
4+ // CHECK: MSConstexprAttr 0x{{[0-9a-f]+}} <col:17, col:23>
5+ [[nodiscard]] [[msvc::constexpr ]] inline void * __cdecl operator new (decltype (sizeof (void *)), void * p) noexcept { return p; }
6+
7+ // CHECK: used constexpr construct_at
8+ // CHECK: AttributedStmt 0x{{[0-9a-f]+}} <col:46, col:88>
9+ // CHECK-NEXT: MSConstexprAttr 0x{{[0-9a-f]+}} <col:48, col:54>
10+ // CHECK-NEXT: ReturnStmt 0x{{[0-9a-f]+}} <col:66, col:88>
11+ constexpr int * construct_at (int * p, int v) { [[msvc::constexpr ]] return ::new (p) int (v); }
12+ constexpr bool check_construct_at () { int x; return *construct_at (&x, 42 ) == 42 ; }
13+ static_assert (check_construct_at());
You can’t perform that action at this time.
0 commit comments