[m-rev.] diff: fix bug with --gcc-nested-functions
Fergus Henderson
fjh at cs.mu.OZ.AU
Thu Oct 25 15:55:11 AEST 2001
Branches: main
Estimated hours taken: 2
compiler/mlds_to_c.m:
Fix a bug that broke the hl*_nest (--gcc-nested-functions) grades:
make sure we generate forward declarations for nested functions,
in case they are referenced before they are defined.
With this fix, the compiler bootstraps in grade hlc_nest.gc,
and passes all of the tests except tests/valid/static.m.
Workspace: /home/earth/fjh/ws-earth3/mercury
Index: compiler/mlds_to_c.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/mlds_to_c.m,v
retrieving revision 1.105
diff -u -d -r1.105 mlds_to_c.m
--- compiler/mlds_to_c.m 24 Oct 2001 13:34:28 -0000 1.105
+++ compiler/mlds_to_c.m 25 Oct 2001 04:11:47 -0000
@@ -1869,6 +1869,14 @@
->
io__write_string("extern ")
;
+ % forward declarations for GNU C nested functions need
+ % to be prefixed with "auto"
+ { DeclOrDefn = forward_decl },
+ { Name = function(_, _, _, _) },
+ { Access = local }
+ ->
+ io__write_string("auto ")
+ ;
[]
).
@@ -1932,6 +1940,19 @@
( { Defns \= [] } ->
{ FuncInfo = func_info(FuncName, _) },
{ FuncName = qual(ModuleName, _) },
+
+ % output forward declarations for any nested functions
+ % defined in this block, in case they are referenced before
+ % they are defined
+ { list__filter(defn_is_function, Defns, NestedFuncDefns) },
+ ( { NestedFuncDefns \= [] } ->
+ mlds_output_decls(Indent + 1, ModuleName,
+ NestedFuncDefns),
+ io__write_string("\n")
+ ;
+ []
+ ),
+
mlds_output_defns(Indent + 1, ModuleName, Defns),
io__write_string("\n")
;
--
Fergus Henderson <fjh at cs.mu.oz.au> | "... it seems to me that 15 years of
The University of Melbourne | email is plenty for one lifetime."
WWW: <http://www.cs.mu.oz.au/~fjh> | -- Prof. Donald E. Knuth
--------------------------------------------------------------------------
mercury-reviews mailing list
post: mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------
More information about the reviews
mailing list