Skip to content

Commit

Permalink
Avoid warning from C compiler about mismatched pointer types.
Browse files Browse the repository at this point in the history
Avoid warning from C compiler about mismatched pointer types
when the --optimise-constructor-last-call optimisation is enabled
in high-level C grades.

compiler/ml_unify_gen.m:
	Cast the pointer of a cell field to the type of the address
	variable that will hold it.
  • Loading branch information
wangp committed Nov 28, 2013
1 parent c5f35d8 commit 58d1f3f
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions compiler/ml_unify_gen.m
Original file line number Diff line number Diff line change
Expand Up @@ -1024,7 +1024,7 @@
ml_gen_field_take_address_assigns([], _, _, _, _, _, []).
ml_gen_field_take_address_assigns([TakeAddrInfo | TakeAddrInfos],
CellLval, CellType, MaybeTag, Context, Info, [Assign | Assigns]) :-
TakeAddrInfo = take_addr_info(AddrVar, Offset, ConsArgType, FieldType),
TakeAddrInfo = take_addr_info(AddrVar, Offset, _ConsArgType, FieldType),

ml_gen_info_get_module_info(Info, ModuleInfo),
module_info_get_globals(ModuleInfo, Globals),
Expand All @@ -1042,7 +1042,9 @@
ml_field_offset(ml_const(mlconst_int(OffsetInt))),
FieldType, CellType)),
ml_gen_var(Info, AddrVar, AddrLval),
CastSourceRval = ml_unop(cast(mlds_ptr_type(ConsArgType)), SourceRval),
ml_variable_type(Info, AddrVar, AddrVarType),
MLDS_AddrVarType = mercury_type_to_mlds_type(ModuleInfo, AddrVarType),
CastSourceRval = ml_unop(cast(MLDS_AddrVarType), SourceRval),
Assign = ml_gen_assign(AddrLval, CastSourceRval, Context)
;
HighLevelData = yes,
Expand Down

0 comments on commit 58d1f3f

Please sign in to comment.