File tree Expand file tree Collapse file tree 4 files changed +49
-2
lines changed Expand file tree Collapse file tree 4 files changed +49
-2
lines changed Original file line number Diff line number Diff line change @@ -194,6 +194,12 @@ bool ByteCodeExprGen<Emitter>::VisitCastExpr(const CastExpr *CE) {
194
194
return false ;
195
195
196
196
PrimType T = classifyPrim (CE->getType ());
197
+ if (T == PT_IntAP)
198
+ return this ->emitCastPointerIntegralAP (Ctx.getBitWidth (CE->getType ()),
199
+ CE);
200
+ if (T == PT_IntAPS)
201
+ return this ->emitCastPointerIntegralAPS (Ctx.getBitWidth (CE->getType ()),
202
+ CE);
197
203
return this ->emitCastPointerIntegral (T, CE);
198
204
}
199
205
Original file line number Diff line number Diff line change @@ -1833,6 +1833,32 @@ bool CastPointerIntegral(InterpState &S, CodePtr OpPC) {
1833
1833
return true ;
1834
1834
}
1835
1835
1836
+ static inline bool CastPointerIntegralAP (InterpState &S, CodePtr OpPC,
1837
+ uint32_t BitWidth) {
1838
+ const Pointer &Ptr = S.Stk .pop <Pointer>();
1839
+
1840
+ const SourceInfo &E = S.Current ->getSource (OpPC);
1841
+ S.CCEDiag (E, diag::note_constexpr_invalid_cast)
1842
+ << 2 << S.getLangOpts ().CPlusPlus << S.Current ->getRange (OpPC);
1843
+
1844
+ S.Stk .push <IntegralAP<false >>(
1845
+ IntegralAP<false >::from (Ptr.getIntegerRepresentation (), BitWidth));
1846
+ return true ;
1847
+ }
1848
+
1849
+ static inline bool CastPointerIntegralAPS (InterpState &S, CodePtr OpPC,
1850
+ uint32_t BitWidth) {
1851
+ const Pointer &Ptr = S.Stk .pop <Pointer>();
1852
+
1853
+ const SourceInfo &E = S.Current ->getSource (OpPC);
1854
+ S.CCEDiag (E, diag::note_constexpr_invalid_cast)
1855
+ << 2 << S.getLangOpts ().CPlusPlus << S.Current ->getRange (OpPC);
1856
+
1857
+ S.Stk .push <IntegralAP<true >>(
1858
+ IntegralAP<true >::from (Ptr.getIntegerRepresentation (), BitWidth));
1859
+ return true ;
1860
+ }
1861
+
1836
1862
// ===----------------------------------------------------------------------===//
1837
1863
// Zero, Nullptr
1838
1864
// ===----------------------------------------------------------------------===//
Original file line number Diff line number Diff line change @@ -664,10 +664,19 @@ def CastFloatingIntegralAPS : Opcode {
664
664
}
665
665
666
666
def CastPointerIntegral : Opcode {
667
- let Types = [AluTypeClass];
668
- let Args = [];
667
+ let Types = [FixedSizeIntegralTypeClass];
669
668
let HasGroup = 1 ;
670
669
}
670
+ def CastPointerIntegralAP : Opcode {
671
+ let Types = [];
672
+ let HasGroup = 0 ;
673
+ let Args = [ArgUint32];
674
+ }
675
+ def CastPointerIntegralAPS : Opcode {
676
+ let Types = [];
677
+ let HasGroup = 0 ;
678
+ let Args = [ArgUint32];
679
+ }
671
680
672
681
def DecayPtr : Opcode {
673
682
let Types = [PtrTypeClass, PtrTypeClass];
Original file line number Diff line number Diff line change @@ -257,3 +257,9 @@ int Y __attribute__((annotate(
257
257
42 ,
258
258
(struct TestStruct ) { .a = 1 , .b = 2 }
259
259
)));
260
+
261
+ #ifdef __SIZEOF_INT128__
262
+ const int * p = & b ;
263
+ const __int128 K = (__int128 )(int * )0 ;
264
+ const unsigned __int128 KU = (unsigned __int128 )(int * )0 ;
265
+ #endif
You can’t perform that action at this time.
0 commit comments