Skip to content

Commit cab4726

Browse files
committed
mkCast: add ad-hoc exception for bitfields
1 parent 9667b57 commit cab4726

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

py/dml/ctree.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4815,6 +4815,11 @@ def mkCast(site, expr, new_type):
48154815
# 1.2 integer expressions often lie about their actual type,
48164816
# and require a "redundant" cast! Why yes, this IS horrid!
48174817
return Cast(site, expr, new_type)
4818+
if real.is_int and real.members is not None:
4819+
# An integer type can be compatible with a bitfields without being
4820+
# equal to it, as DMLC will treat bitfields differently. Leverage
4821+
# Cast in this case
4822+
return Cast(site, expr, new_type)
48184823
return mkRValue(expr)
48194824
if isinstance(real, (TStruct, TExternStruct, TVector, TTraitList)):
48204825
raise ECAST(site, expr, new_type)

0 commit comments

Comments
 (0)