@@ -1564,34 +1564,38 @@ bool CheckNewTypeMismatch(InterpState &S, CodePtr OpPC, const Expr *E,
1564
1564
bool InvalidNewDeleteExpr (InterpState &S, CodePtr OpPC, const Expr *E) {
1565
1565
assert (E);
1566
1566
1567
- if (S.getLangOpts ().CPlusPlus26 )
1568
- return true ;
1569
-
1570
- const auto &Loc = S.Current ->getSource (OpPC);
1571
-
1572
1567
if (const auto *NewExpr = dyn_cast<CXXNewExpr>(E)) {
1573
1568
const FunctionDecl *OperatorNew = NewExpr->getOperatorNew ();
1574
1569
1575
- if (!S. getLangOpts (). CPlusPlus26 && NewExpr->getNumPlacementArgs () > 0 ) {
1570
+ if (NewExpr->getNumPlacementArgs () > 0 ) {
1576
1571
// This is allowed pre-C++26, but only an std function.
1577
- if (S.Current ->isStdFunction ())
1572
+ if (S.getLangOpts (). CPlusPlus26 || S. Current ->isStdFunction ())
1578
1573
return true ;
1579
- S.FFDiag (Loc , diag::note_constexpr_new_placement)
1574
+ S.FFDiag (S. Current -> getSource (OpPC) , diag::note_constexpr_new_placement)
1580
1575
<< /* C++26 feature*/ 1 << E->getSourceRange ();
1581
- } else if (NewExpr->getNumPlacementArgs () == 1 &&
1582
- !OperatorNew->isReservedGlobalPlacementOperator ()) {
1583
- S.FFDiag (Loc, diag::note_constexpr_new_placement)
1584
- << /* Unsupported*/ 0 << E->getSourceRange ();
1585
1576
} else if (!OperatorNew->isReplaceableGlobalAllocationFunction ()) {
1586
- S.FFDiag (Loc, diag::note_constexpr_new_non_replaceable)
1577
+ S.FFDiag (S.Current ->getSource (OpPC),
1578
+ diag::note_constexpr_new_non_replaceable)
1587
1579
<< isa<CXXMethodDecl>(OperatorNew) << OperatorNew;
1580
+ return false ;
1581
+ } else if (!S.getLangOpts ().CPlusPlus26 &&
1582
+ NewExpr->getNumPlacementArgs () == 1 &&
1583
+ !OperatorNew->isReservedGlobalPlacementOperator ()) {
1584
+ if (!S.getLangOpts ().CPlusPlus26 ) {
1585
+ S.FFDiag (S.Current ->getSource (OpPC), diag::note_constexpr_new_placement)
1586
+ << /* Unsupported*/ 0 << E->getSourceRange ();
1587
+ return false ;
1588
+ }
1589
+ return true ;
1588
1590
}
1589
1591
} else {
1590
1592
const auto *DeleteExpr = cast<CXXDeleteExpr>(E);
1591
1593
const FunctionDecl *OperatorDelete = DeleteExpr->getOperatorDelete ();
1592
1594
if (!OperatorDelete->isReplaceableGlobalAllocationFunction ()) {
1593
- S.FFDiag (Loc, diag::note_constexpr_new_non_replaceable)
1595
+ S.FFDiag (S.Current ->getSource (OpPC),
1596
+ diag::note_constexpr_new_non_replaceable)
1594
1597
<< isa<CXXMethodDecl>(OperatorDelete) << OperatorDelete;
1598
+ return false ;
1595
1599
}
1596
1600
}
1597
1601
0 commit comments