[m-rev.] diff: avoid problems with forwarding decls. and Visual C
Julien Fischer
juliensf at csse.unimelb.edu.au
Sun Jul 17 22:33:33 AEST 2011
Branches: main, 11.07
Avoid a problem that occurs in the hlc.gc grade when using Visual C.
compiler/mlds_to_c.m:
Avoid the use of incomplete types in the forwarding declarations for
scalar and vector common data in the high-level C backend. Visual C
will not accept incomplete types in this context and reports an
error.
Julien.
Index: compiler/mlds_to_c.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/mlds_to_c.m,v
retrieving revision 1.255
diff -u -r1.255 mlds_to_c.m
--- compiler/mlds_to_c.m 23 May 2011 05:08:07 -0000 1.255
+++ compiler/mlds_to_c.m 17 Jul 2011 12:00:06 -0000
@@ -1546,7 +1546,8 @@
TypeNum - CellGroup, !IO) :-
TypeNum = ml_scalar_common_type_num(TypeRawNum),
CellGroup = ml_scalar_cell_group(Type, InitArraySize,
- _Counter, _Members, _RevRows),
+ _Counter, _Members, RevRows),
+
mlds_indent(Indent, !IO),
io.write_string("\nstatic /* final */ const ", !IO),
mlds_output_type_prefix(Opts, Type, !IO),
@@ -1554,7 +1555,8 @@
io.write_string(MangledModuleName, !IO),
io.write_string("_scalar_common_", !IO),
io.write_int(TypeRawNum, !IO),
- io.write_string("[]", !IO),
+ NumRows = cord.length(RevRows),
+ io.format("[%d]", [i(NumRows)], !IO),
mlds_output_type_suffix(Opts, Type, InitArraySize, !IO),
io.write_string(";\n", !IO).
@@ -1581,7 +1583,7 @@
TypeNum - CellGroup, !IO) :-
TypeNum = ml_vector_common_type_num(TypeRawNum),
CellGroup = ml_vector_cell_group(Type, ClassDefn, _FieldNames,
- _NextRow, _RevRows),
+ _NextRow, RevRows),
mlds_output_defn(Opts, Indent, yes, ModuleName, ClassDefn, !IO),
mlds_indent(Indent, !IO),
@@ -1591,7 +1593,8 @@
io.write_string(MangledModuleName, !IO),
io.write_string("_vector_common_", !IO),
io.write_int(TypeRawNum, !IO),
- io.write_string("[]", !IO),
+ NumRows = cord.length(RevRows),
+ io.format("[%d]", [i(NumRows)], !IO),
mlds_output_type_suffix(Opts, Type, no_size, !IO),
io.write_string(";\n", !IO).
@@ -1619,6 +1622,7 @@
CellGroup = ml_scalar_cell_group(Type, InitArraySize,
_Counter, _Members, RowCords),
Rows = cord.list(RowCords),
+ list.length(Rows, NumRows),
mlds_indent(Indent, !IO),
io.write_string("\nstatic /* final */ const ", !IO),
mlds_output_type_prefix(Opts, Type, !IO),
@@ -1626,7 +1630,7 @@
io.write_string(MangledModuleName, !IO),
io.write_string("_scalar_common_", !IO),
io.write_int(TypeRawNum, !IO),
- io.write_string("[]", !IO),
+ io.format("[%d]", [i(NumRows)], !IO),
mlds_output_type_suffix(Opts, Type, InitArraySize, !IO),
io.write_string(" = {\n", !IO),
list.foldl2(mlds_output_cell(Opts, Indent + 1), Rows, 0, _, !IO),
@@ -1656,6 +1660,7 @@
CellGroup = ml_vector_cell_group(Type, _ClassDefn, _FieldNames,
_NextRow, RowCords),
Rows = cord.list(RowCords),
+ list.length(Rows, NumRows),
mlds_indent(Indent, !IO),
io.write_string("\nstatic /* final */ const ", !IO),
mlds_output_type_prefix(Opts, Type, !IO),
@@ -1663,7 +1668,7 @@
io.write_string(MangledModuleName, !IO),
io.write_string("_vector_common_", !IO),
io.write_int(TypeRawNum, !IO),
- io.write_string("[]", !IO),
+ io.format("[%d]", [i(NumRows)], !IO),
mlds_output_type_suffix(Opts, Type, no_size, !IO),
io.write_string(" = {\n", !IO),
list.foldl2(mlds_output_cell(Opts, Indent + 1), Rows, 0, _, !IO),
--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to: mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions: mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------
More information about the reviews
mailing list