Expr::EvalResult Eval;
Eval.Diag = &Notes;
ConstantExpr *CE = Candidate.getPointer();
- if (!CE->EvaluateAsConstantExpr(Eval, Expr::EvaluateForCodeGen,
- SemaRef.getASTContext(), true)) {
+ bool Result = CE->EvaluateAsConstantExpr(Eval, Expr::EvaluateForCodeGen,
+ SemaRef.getASTContext(), true);
+ if (!Result || !Notes.empty()) {
Expr *InnerExpr = CE->getSubExpr()->IgnoreImplicit();
FunctionDecl *FD = nullptr;
if (auto *Call = dyn_cast<CallExpr>(InnerExpr))
namespace alloc {
+consteval int f() {
+ int *A = new int(0);
+// expected-note@-1+ {{allocation performed here was not deallocated}}
+ return *A;
+}
+
+int i1 = f(); // expected-error {{is not a constant expression}}
+
struct A {
int* p = new int(42);
// expected-note@-1+ {{heap allocation performed here}}