diff --git a/clang/lib/AST/ByteCode/InterpState.cpp b/clang/lib/AST/ByteCode/InterpState.cpp index d6e6771f0a04f..7848f298cfec8 100644 --- a/clang/lib/AST/ByteCode/InterpState.cpp +++ b/clang/lib/AST/ByteCode/InterpState.cpp @@ -113,7 +113,9 @@ bool InterpState::maybeDiagnoseDanglingAllocations() { << (It.second.size() - 1) << Source->getSourceRange(); } } - return NoAllocationsLeft; + // Keep evaluating before C++20, since the CXXNewExpr wasn't valid there + // in the first place. + return NoAllocationsLeft || !getLangOpts().CPlusPlus20; } StdAllocatorCaller InterpState::getStdAllocatorCaller(StringRef Name) const { diff --git a/clang/test/AST/ByteCode/cxx11-pedantic.cpp b/clang/test/AST/ByteCode/cxx11-pedantic.cpp index a73f20ead1092..247c7ef1c77d8 100644 --- a/clang/test/AST/ByteCode/cxx11-pedantic.cpp +++ b/clang/test/AST/ByteCode/cxx11-pedantic.cpp @@ -20,3 +20,10 @@ namespace DynamicCast { // both-note {{dynamic_cast}} }; } + +namespace NewDelete { + struct T { + int n : *new int(4); // both-warning {{constant expression}} \ + // both-note {{until C++20}} + }; +}