[m-dev.] for review: fix empty struct creation by llds_common.m

Peter Ross peter.ross at miscrit.be
Tue Nov 21 03:39:24 AEDT 2000


Hi,


===================================================================


Estimated hours taken: 1

compiler/llds_common.m:
    Place a dummy field into any empty data structures created by this
    pass.


Index: compiler/llds_common.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/llds_common.m,v
retrieving revision 1.34
diff -u -r1.34 llds_common.m
--- compiler/llds_common.m	2000/10/13 04:04:54	1.34
+++ compiler/llds_common.m	2000/11/20 16:16:02
@@ -74,7 +74,18 @@
 llds_common__cell_pairs_to_modules([CellContent - CellInfo | CellPairs],
 		BaseName, [Common | Commons]) :-
 	CellInfo = cell_info(VarNum),
-	CellContent = Args - ArgTypes,
+	CellContent = Args0 - ArgTypes0,
+		
+		% If we have an empty data structure place a dummy field
+		% in it, so that the generated C structure isn't empty.
+	( Args0 = [] ->
+		Args = [yes(const(int_const(-1)))],
+		ArgTypes = uniform(yes(integer))
+	;
+		Args = Args0,
+		ArgTypes = ArgTypes0
+	),
+
 	Common = comp_gen_c_data(BaseName, common(VarNum), no,
 		Args, ArgTypes, []),
 	llds_common__cell_pairs_to_modules(CellPairs, BaseName, Commons).
--------------------------------------------------------------------------
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