File tree Expand file tree Collapse file tree 2 files changed +19
-2
lines changed Expand file tree Collapse file tree 2 files changed +19
-2
lines changed Original file line number Diff line number Diff line change @@ -91,11 +91,15 @@ def note_constexpr_pointer_subtraction_zero_size : Note<
91
91
"subtraction of pointers to type %0 of zero size">;
92
92
def note_constexpr_pointer_comparison_unspecified : Note<
93
93
"comparison between '%0' and '%1' has unspecified value">;
94
+ def note_constexpr_pointer_arith_unspecified : Note<
95
+ "arithmetic involving '%0' and '%1' has unspecified value">;
94
96
def note_constexpr_pointer_constant_comparison : Note<
95
97
"comparison of numeric address '%0' with pointer '%1' can only be performed "
96
98
"at runtime">;
97
99
def note_constexpr_literal_comparison : Note<
98
100
"comparison of addresses of literals has unspecified value">;
101
+ def note_constexpr_literal_arith : Note<
102
+ "arithmetic on addresses of literals has unspecified value">;
99
103
def note_constexpr_opaque_call_comparison : Note<
100
104
"comparison against opaque constant address '%0' can only be performed at "
101
105
"runtime">;
Original file line number Diff line number Diff line change @@ -14600,8 +14600,21 @@ bool IntExprEvaluator::VisitBinaryOperator(const BinaryOperator *E) {
14600
14600
return Error(E);
14601
14601
const Expr *LHSExpr = LHSValue.Base.dyn_cast<const Expr *>();
14602
14602
const Expr *RHSExpr = RHSValue.Base.dyn_cast<const Expr *>();
14603
- if (!LHSExpr || !RHSExpr)
14604
- return Error(E);
14603
+ if (!LHSExpr || !RHSExpr) {
14604
+ std::string LHS = LHSValue.toString(Info.Ctx, E->getLHS()->getType());
14605
+ std::string RHS = RHSValue.toString(Info.Ctx, E->getRHS()->getType());
14606
+ Info.FFDiag(E, diag::note_constexpr_pointer_arith_unspecified)
14607
+ << LHS << RHS;
14608
+ return false;
14609
+ }
14610
+
14611
+ if (ArePotentiallyOverlappingStringLiterals(Info, LHSValue, RHSValue)) {
14612
+ std::string LHS = LHSValue.toString(Info.Ctx, E->getLHS()->getType());
14613
+ std::string RHS = RHSValue.toString(Info.Ctx, E->getRHS()->getType());
14614
+ Info.FFDiag(E, diag::note_constexpr_literal_arith) << LHS << RHS;
14615
+ return false;
14616
+ }
14617
+
14605
14618
const AddrLabelExpr *LHSAddrExpr = dyn_cast<AddrLabelExpr>(LHSExpr);
14606
14619
const AddrLabelExpr *RHSAddrExpr = dyn_cast<AddrLabelExpr>(RHSExpr);
14607
14620
if (!LHSAddrExpr || !RHSAddrExpr)
You can’t perform that action at this time.
0 commit comments