[m-dev.] for review: more empty array initializers
Peter Ross
peter.ross at miscrit.be
Tue Feb 6 21:05:30 AEDT 2001
On Tue, Feb 06, 2001 at 03:01:34AM +1100, Fergus Henderson wrote:
> 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?
>
I replaced that with a dummy value. Here is the relative diff.
--- compiler/layout_out.m
+++ compiler/layout_out.m
@@ -622,0 +623,2 @@
+ % ANSI/ISO C doesn't allow empty arrays, so
+ % place a dummy value in the array.
@@ -771,0 +774,2 @@
+ % ANSI/ISO C doesn't allow empty arrays, so
+ % place a dummy value in the array.
@@ -843,0 +848,2 @@
+ % ANSI/ISO C doesn't allow empty arrays, so
+ % place a dummy value in the array.
@@ -908 +914,3 @@
- { error("output_file_layout_line_number_vector_defn") }
+ % ANSI/ISO C doesn't allow empty arrays, so
+ % place a dummy value in the array.
+ io__write_string("\t0\n")
@@ -926,0 +935,2 @@
+ % ANSI/ISO C doesn't allow empty arrays, so
+ % place a dummy value in the array.
--------------------------------------------------------------------------
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