Skip to content

Commit 155f6b4

Browse files
committed
[clang][Interp] Fix reporting invalid new/delete expressions
This should be a CCEDiag call and we do *not* abort because of it.
1 parent 62aa596 commit 155f6b4

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

clang/lib/AST/Interp/Interp.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -728,8 +728,8 @@ bool CheckDynamicMemoryAllocation(InterpState &S, CodePtr OpPC) {
728728
return true;
729729

730730
const SourceInfo &E = S.Current->getSource(OpPC);
731-
S.FFDiag(E, diag::note_constexpr_new);
732-
return false;
731+
S.CCEDiag(E, diag::note_constexpr_new);
732+
return true;
733733
}
734734

735735
bool CheckNewDeleteForms(InterpState &S, CodePtr OpPC, bool NewWasArray,

clang/test/AST/Interp/new-delete.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -560,4 +560,9 @@ constexpr int a() { // both-error {{never produces a constant expression}}
560560
}
561561
static_assert(a() == 1, ""); // both-error {{not an integral constant expression}} \
562562
// both-note {{in call to 'a()'}}
563+
564+
565+
static_assert(true ? *new int : 4, ""); // both-error {{expression is not an integral constant expression}} \
566+
// both-note {{read of uninitialized object is not allowed in a constant expression}}
567+
563568
#endif

0 commit comments

Comments
 (0)