diff --git a/clang/lib/AST/Interp/Interp.cpp b/clang/lib/AST/Interp/Interp.cpp index cd6fc60400ebda..6fcd90e5f58498 100644 --- a/clang/lib/AST/Interp/Interp.cpp +++ b/clang/lib/AST/Interp/Interp.cpp @@ -728,8 +728,8 @@ bool CheckDynamicMemoryAllocation(InterpState &S, CodePtr OpPC) { return true; const SourceInfo &E = S.Current->getSource(OpPC); - S.FFDiag(E, diag::note_constexpr_new); - return false; + S.CCEDiag(E, diag::note_constexpr_new); + return true; } bool CheckNewDeleteForms(InterpState &S, CodePtr OpPC, bool NewWasArray, diff --git a/clang/test/AST/Interp/new-delete.cpp b/clang/test/AST/Interp/new-delete.cpp index cb46426c0e3be6..7a85def7849209 100644 --- a/clang/test/AST/Interp/new-delete.cpp +++ b/clang/test/AST/Interp/new-delete.cpp @@ -560,4 +560,9 @@ constexpr int a() { // both-error {{never produces a constant expression}} } static_assert(a() == 1, ""); // both-error {{not an integral constant expression}} \ // both-note {{in call to 'a()'}} + + +static_assert(true ? *new int : 4, ""); // both-error {{expression is not an integral constant expression}} \ + // both-note {{read of uninitialized object is not allowed in a constant expression}} + #endif