[m-dev.] for review: more empty array initializers

Fergus Henderson fjh at cs.mu.OZ.AU
Tue Feb 6 03:01:34 AEDT 2001


On 05-Feb-2001, Peter Ross <peter.ross at miscrit.be> wrote:
> Fix a problem where the none.gc.tr.debug grade doesn't compile using
> MSVC.
> 
> compiler/layout_out.m:
>     Avoid generating definitions in the following form
>         type name[] = { };
>     as not all C compilers (read MSVC) like an empty initializer list.
> 
> Index: compiler/layout_out.m
> ===================================================================
> RCS file: /home/mercury1/repository/mercury/compiler/layout_out.m,v
> retrieving revision 1.1
> diff -u -r1.1 layout_out.m
> --- compiler/layout_out.m	2001/01/18 01:18:44	1.1
> +++ compiler/layout_out.m	2001/02/05 15:06:48
> @@ -619,7 +619,11 @@
>  	output_layout_name_storage_type_name(proc_layout_var_names(ProcLabel),
>  		yes),
>  	io__write_string(" = {\n"),
> -	list__foldl(output_number_in_vector, VarNames),
> +	( { VarNames = [] } ->
> +		io__write_string("\t0\n")
> +	;
> +		list__foldl(output_number_in_vector, VarNames)
> +	),

Please document why the code does that in the comments
(not just in the log message).

Likewise for all the other parts you changed.

> @@ -892,7 +904,11 @@
>  	io__write_string("\n"),
>  	output_layout_name_storage_type_name(LayoutName, yes),
>  	io__write_string(" = {\n"),
> -	list__foldl(output_number_in_vector, LineNumbers),
> +	( { LineNumbers = [] } ->
> +		{ error("output_file_layout_line_number_vector_defn") }
> +	;
> +		list__foldl(output_number_in_vector, LineNumbers)
> +	),
>  	io__write_string("};\n"),
>  	{ decl_set_insert(DeclSet0, data_addr(layout_addr(LayoutName)),
>  		DeclSet) }.

Perhaps a comment here explaining why the LineNumbers list
should never be empty?

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
                                    |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions:          mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------



More information about the developers mailing list