[m-rev.] for review: Avoid warning from C compiler about mismatched pointer types.

Julien Fischer jfischer at opturion.com
Thu Nov 28 15:39:35 AEDT 2013


On Wed, Nov 27, 2013 at 2:13 PM, Peter Wang <novalazy at gmail.com> wrote:

> compiler/ml_unify_gen.m:
>         Cast the pointer of a cell field to the type of the address
>         variable that will hold it.
>

This presumably fixes the warnings that occasionally pop up when lcmc is
enabled?

 compiler/ml_unify_gen.m |    6 ++++--
>  1 files changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/compiler/ml_unify_gen.m b/compiler/ml_unify_gen.m
> index bcd5c47..aafe9f4 100644
> --- a/compiler/ml_unify_gen.m
> +++ b/compiler/ml_unify_gen.m
> @@ -1024,7 +1024,7 @@ ml_gen_new_object_reuse_cell(MaybeConsId,
> MaybeCtorName, Tag, MaybeTag,
>  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),
> @@ -1042,7 +1042,9 @@ ml_gen_field_take_address_assigns([TakeAddrInfo |
> TakeAddrInfos],
>              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,
>

That looks fine.

Cheers,
Julien.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurylang.org/archives/reviews/attachments/20131128/d0d5690a/attachment.html>


More information about the reviews mailing list