File tree Expand file tree Collapse file tree 2 files changed +10
-3
lines changed
Expand file tree Collapse file tree 2 files changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -18606,12 +18606,15 @@ bool IntExprEvaluator::VisitCastExpr(const CastExpr *E) {
1860618606
1860718607 if (!Result.isInt()) {
1860818608 // Allow casts of address-of-label differences if they are no-ops
18609- // or narrowing. (The narrowing case isn't actually guaranteed to
18609+ // or narrowing, if the result is at least 32 bits wide.
18610+ // (The narrowing case isn't actually guaranteed to
1861018611 // be constant-evaluatable except in some narrow cases which are hard
1861118612 // to detect here. We let it through on the assumption the user knows
1861218613 // what they are doing.)
18613- if (Result.isAddrLabelDiff())
18614- return Info.Ctx.getTypeSize(DestType) <= Info.Ctx.getTypeSize(SrcType);
18614+ if (Result.isAddrLabelDiff()) {
18615+ unsigned DestBits = Info.Ctx.getTypeSize(DestType);
18616+ return DestBits >= 32 && DestBits <= Info.Ctx.getTypeSize(SrcType);
18617+ }
1861518618 // Only allow casts of lvalues if they are lossless.
1861618619 return Info.Ctx.getTypeSize(DestType) == Info.Ctx.getTypeSize(SrcType);
1861718620 }
Original file line number Diff line number Diff line change @@ -73,6 +73,10 @@ __int128_t PR11705 = (__int128_t)&PR11705;
7373// CHECK: @_ZZ23UnfoldableAddrLabelDiffvE1x = internal global i128 0
7474void UnfoldableAddrLabelDiff () { static __int128_t x = (long )&&a-(long )&&b; a:b:return ;}
7575
76+ // CHECK: @_ZZ24UnfoldableAddrLabelDiff2vE1x = internal global i16 0
77+ void UnfoldableAddrLabelDiff2 () { static short x = (long )&&a-(long )&&b; a:b:return ;}
78+
79+
7680// But make sure we do fold this.
7781// CHECK: @_ZZ21FoldableAddrLabelDiffvE1x = internal global i64 sub (i64 ptrtoint (ptr blockaddress(@_Z21FoldableAddrLabelDiffv
7882void FoldableAddrLabelDiff () { static long x = (long )&&a-(long )&&b; a:b:return ;}
You can’t perform that action at this time.
0 commit comments