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 @@ -14588,8 +14588,21 @@ bool IntExprEvaluator::VisitBinaryOperator(const BinaryOperator *E) {
14588
14588
return Error(E);
14589
14589
const Expr *LHSExpr = LHSValue.Base.dyn_cast<const Expr *>();
14590
14590
const Expr *RHSExpr = RHSValue.Base.dyn_cast<const Expr *>();
14591
- if (!LHSExpr || !RHSExpr)
14592
- return Error(E);
14591
+ if (!LHSExpr || !RHSExpr) {
14592
+ std::string LHS = LHSValue.toString(Info.Ctx, E->getLHS()->getType());
14593
+ std::string RHS = RHSValue.toString(Info.Ctx, E->getRHS()->getType());
14594
+ Info.FFDiag(E, diag::note_constexpr_pointer_arith_unspecified)
14595
+ << LHS << RHS;
14596
+ return false;
14597
+ }
14598
+
14599
+ if (ArePotentiallyOverlappingStringLiterals(Info, LHSValue, RHSValue)) {
14600
+ std::string LHS = LHSValue.toString(Info.Ctx, E->getLHS()->getType());
14601
+ std::string RHS = RHSValue.toString(Info.Ctx, E->getRHS()->getType());
14602
+ Info.FFDiag(E, diag::note_constexpr_literal_arith) << LHS << RHS;
14603
+ return false;
14604
+ }
14605
+
14593
14606
const AddrLabelExpr *LHSAddrExpr = dyn_cast<AddrLabelExpr>(LHSExpr);
14594
14607
const AddrLabelExpr *RHSAddrExpr = dyn_cast<AddrLabelExpr>(RHSExpr);
14595
14608
if (!LHSAddrExpr || !RHSAddrExpr)
You can’t perform that action at this time.
0 commit comments