[m-rev.] diff: avoid C compiler warnings

Zoltan Somogyi zs at cs.mu.OZ.AU
Wed Apr 17 15:21:01 AEST 2002


compiler/rtti_out.m:
	Cast the elements of the vectors inside TypeInfos and PseudoTypeInfos
	to the right type, to shut up warnings. Do so systematically, instead
	of as a special hack for PseudoTypeInfos. (We cannot avoid casts
	altogether, because we want TypeCtorInfos to be acceptable as both
	TypeInfos and as PseudoTypeInfos.)

Zoltan.

cvs diff: Diffing .
cvs diff: Diffing bindist
cvs diff: Diffing boehm_gc
cvs diff: Diffing boehm_gc/Mac_files
cvs diff: Diffing boehm_gc/cord
cvs diff: Diffing boehm_gc/cord/private
cvs diff: Diffing boehm_gc/doc
cvs diff: Diffing boehm_gc/include
cvs diff: Diffing boehm_gc/include/private
cvs diff: Diffing boehm_gc/tests
cvs diff: Diffing browser
cvs diff: Diffing bytecode
cvs diff: Diffing compiler
Index: compiler/rtti_out.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/rtti_out.m,v
retrieving revision 1.27
diff -u -b -r1.27 rtti_out.m
--- compiler/rtti_out.m	12 Apr 2002 01:24:13 -0000	1.27
+++ compiler/rtti_out.m	17 Apr 2002 03:44:52 -0000
@@ -27,8 +27,14 @@
 :- import_module backend_libs__rtti, ll_backend__llds_out.
 :- import_module bool, io.
 
-	% output a C expression holding the address of the C name of
-	% the specified rtti_data
+	% Output a C expression holding the address of the C name of
+	% the specified rtti_data, preceded by the string in the first
+	% argument (that string will usually be a C cast).
+:- pred output_cast_addr_of_rtti_data(string::in, rtti_data::in,
+	io__state::di, io__state::uo) is det.
+
+	% Output a C expression holding the address of the C name of
+	% the specified rtti_data.
 :- pred output_addr_of_rtti_data(rtti_data::in, io__state::di, io__state::uo)
 	is det.
 
@@ -153,7 +159,7 @@
 		io__write_string("= { NULL };\n")
 	;
 		io__write_string(" = {\n"),
-		output_addr_of_rtti_datas(Types),
+		output_cast_addr_of_rtti_datas("(MR_PseudoTypeInfo) ", Types),
 		io__write_string("};\n")
 	).
 output_rtti_data_defn(reserved_addrs(RttiTypeCtor, ReservedAddrs),
@@ -205,7 +211,7 @@
 	io__write_string(" = {\n\t"""),
 	c_util__output_quoted_string(FunctorName),
 	io__write_string(""",\n\t "),
-	output_addr_of_rtti_data(ArgType),
+	output_cast_addr_of_rtti_data("(MR_PseudoTypeInfo) ", ArgType),
 	io__write_string(",\n\t"),
 	(
 		{ MaybeArgName = yes(ArgName) },
@@ -534,7 +540,7 @@
 	io__write_string(" = {\n\t&"),
 	output_rtti_addr(RttiTypeCtor, type_ctor_info),
 	io__write_string(",\n{"),
-	output_addr_of_rtti_datas(ArgRttiDatas),
+	output_cast_addr_of_rtti_datas("(MR_TypeInfo) ", ArgRttiDatas),
 	io__write_string("}};\n").
 output_type_info_defn(TypeInfo, DeclSet0, DeclSet) -->
 	{ TypeInfo = var_arity_type_info(RttiVarArityId, Args) },
@@ -554,7 +560,7 @@
 	{ list__length(Args, Arity) },
 	io__write_int(Arity),
 	io__write_string(",\n{"),
-	output_addr_of_rtti_datas(ArgRttiDatas),
+	output_cast_addr_of_rtti_datas("(MR_TypeInfo) ", ArgRttiDatas),
 	io__write_string("}};\n").
 
 :- pred output_pseudo_type_info_defn(rtti_pseudo_type_info::in,
@@ -576,7 +582,7 @@
 	io__write_string(" = {\n\t&"),
 	output_rtti_addr(RttiTypeCtor, type_ctor_info),
 	io__write_string(",\n{"),
-	output_addr_of_rtti_datas(ArgRttiDatas),
+	output_cast_addr_of_rtti_datas("(MR_PseudoTypeInfo) ", ArgRttiDatas),
 	io__write_string("}};\n").
 output_pseudo_type_info_defn(PseudoTypeInfo, DeclSet0, DeclSet) -->
 	{ PseudoTypeInfo = var_arity_pseudo_type_info(RttiVarArityId, Args) },
@@ -596,7 +602,7 @@
 	{ list__length(Args, Arity) },
 	io__write_int(Arity),
 	io__write_string(",\n{"),
-	output_addr_of_rtti_datas(ArgRttiDatas),
+	output_cast_addr_of_rtti_datas("(MR_PseudoTypeInfo) ", ArgRttiDatas),
 	io__write_string("}};\n").
 output_pseudo_type_info_defn(type_var(_), DeclSet, DeclSet) --> [].
 
@@ -1051,6 +1057,16 @@
 		output_addr_of_rtti_addr(RttiTypeCtor)),
 	io__write_string("\n").
 
+:- pred output_cast_addr_of_rtti_datas(string::in, list(rtti_data)::in,
+	io__state::di, io__state::uo) is det.
+
+output_cast_addr_of_rtti_datas(_, []) --> [].
+output_cast_addr_of_rtti_datas(Cast, [RttiData | RttiDatas]) -->
+	io__write_string("\t"),
+	io__write_list([RttiData | RttiDatas], ",\n\t",
+		output_cast_addr_of_rtti_data(Cast)),
+	io__write_string("\n").
+
 :- pred output_addr_of_rtti_datas(list(rtti_data)::in,
 	io__state::di, io__state::uo) is det.
 
@@ -1061,10 +1077,15 @@
 		output_addr_of_rtti_data),
 	io__write_string("\n").
 
+output_cast_addr_of_rtti_data(Cast, RttiData) -->
+	io__write_string(Cast),
+	output_addr_of_rtti_data(RttiData).
+
 output_addr_of_rtti_data(RttiData) -->
-	( { RttiData = pseudo_type_info(type_var(VarNum)) } ->
+	(
+		{ RttiData = pseudo_type_info(type_var(VarNum)) }
+	->
 		% rtti_data_to_name/3 does not handle this case
-		io__write_string("(MR_PseudoTypeInfo) "),
 		io__write_int(VarNum)
 	;
 		{ RttiData = base_typeclass_info(_InstanceModuleName, ClassId,
@@ -1082,20 +1103,6 @@
 	io__state::di, io__state::uo) is det.
 
 output_addr_of_rtti_addr(RttiTypeCtor, RttiName) -->
-	%
-	% The various different kinds of pseudotypeinfos
-	% each have different types, but really we treat
-	% them like a union rather than as separate types,
-	% so here we need to cast all such constants to
-	% a single type MR_PseudoTypeInfo.
-	%
-	(
-		{ RttiName = pseudo_type_info(_) }
-	->
-		io__write_string("(MR_PseudoTypeInfo) ")
-	;
-		[]
-	),
 	%
 	% If the RttiName is not an array, then
 	% we need to use `&' to take its address
cvs diff: Diffing compiler/notes
cvs diff: Diffing debian
cvs diff: Diffing deep_profiler
cvs diff: Diffing deep_profiler/notes
cvs diff: Diffing doc
cvs diff: Diffing extras
cvs diff: Diffing extras/aditi
cvs diff: Diffing extras/cgi
cvs diff: Diffing extras/complex_numbers
cvs diff: Diffing extras/complex_numbers/samples
cvs diff: Diffing extras/complex_numbers/tests
cvs diff: Diffing extras/concurrency
cvs diff: Diffing extras/curs
cvs diff: Diffing extras/curs/samples
cvs diff: Diffing extras/curses
cvs diff: Diffing extras/curses/sample
cvs diff: Diffing extras/dynamic_linking
cvs diff: Diffing extras/graphics
cvs diff: Diffing extras/graphics/mercury_opengl
cvs diff: Diffing extras/graphics/mercury_tcltk
cvs diff: Diffing extras/graphics/samples
cvs diff: Diffing extras/graphics/samples/calc
cvs diff: Diffing extras/graphics/samples/maze
cvs diff: Diffing extras/graphics/samples/pent
cvs diff: Diffing extras/lazy_evaluation
cvs diff: Diffing extras/lex
cvs diff: Diffing extras/lex/samples
cvs diff: Diffing extras/logged_output
cvs diff: Diffing extras/moose
cvs diff: Diffing extras/moose/samples
cvs diff: Diffing extras/morphine
cvs diff: Diffing extras/morphine/non-regression-tests
cvs diff: Diffing extras/morphine/scripts
cvs diff: Diffing extras/morphine/source
cvs diff: Diffing extras/odbc
cvs diff: Diffing extras/posix
cvs diff: Diffing extras/quickcheck
cvs diff: Diffing extras/quickcheck/tutes
cvs diff: Diffing extras/references
cvs diff: Diffing extras/references/samples
cvs diff: Diffing extras/references/tests
cvs diff: Diffing extras/stream
cvs diff: Diffing extras/trailed_update
cvs diff: Diffing extras/trailed_update/samples
cvs diff: Diffing extras/trailed_update/tests
cvs diff: Diffing extras/xml
cvs diff: Diffing extras/xml/samples
cvs diff: Diffing java
cvs diff: Diffing java/library
cvs diff: Diffing java/runtime
cvs diff: Diffing library
cvs diff: Diffing profiler
cvs diff: Diffing robdd
cvs diff: Diffing runtime
cvs diff: Diffing runtime/GETOPT
cvs diff: Diffing runtime/machdeps
cvs diff: Diffing samples
cvs diff: Diffing samples/c_interface
cvs diff: Diffing samples/c_interface/c_calls_mercury
cvs diff: Diffing samples/c_interface/cplusplus_calls_mercury
cvs diff: Diffing samples/c_interface/mercury_calls_c
cvs diff: Diffing samples/c_interface/mercury_calls_cplusplus
cvs diff: Diffing samples/c_interface/mercury_calls_fortran
cvs diff: Diffing samples/c_interface/simpler_c_calls_mercury
cvs diff: Diffing samples/c_interface/simpler_cplusplus_calls_mercury
cvs diff: Diffing samples/diff
cvs diff: Diffing samples/muz
cvs diff: Diffing samples/rot13
cvs diff: Diffing samples/solutions
cvs diff: Diffing samples/tests
cvs diff: Diffing samples/tests/c_interface
cvs diff: Diffing samples/tests/c_interface/c_calls_mercury
cvs diff: Diffing samples/tests/c_interface/cplusplus_calls_mercury
cvs diff: Diffing samples/tests/c_interface/mercury_calls_c
cvs diff: Diffing samples/tests/c_interface/mercury_calls_cplusplus
cvs diff: Diffing samples/tests/c_interface/mercury_calls_fortran
cvs diff: Diffing samples/tests/c_interface/simpler_c_calls_mercury
cvs diff: Diffing samples/tests/c_interface/simpler_cplusplus_calls_mercury
cvs diff: Diffing samples/tests/diff
cvs diff: Diffing samples/tests/muz
cvs diff: Diffing samples/tests/rot13
cvs diff: Diffing samples/tests/solutions
cvs diff: Diffing samples/tests/toplevel
cvs diff: Diffing scripts
cvs diff: Diffing tests
cvs diff: Diffing tests/benchmarks
cvs diff: Diffing tests/debugger
cvs diff: Diffing tests/debugger/declarative
cvs diff: Diffing tests/dppd
cvs diff: Diffing tests/general
cvs diff: Diffing tests/general/accumulator
cvs diff: Diffing tests/general/structure_reuse
cvs diff: Diffing tests/hard_coded
cvs diff: Diffing tests/hard_coded/exceptions
cvs diff: Diffing tests/hard_coded/purity
cvs diff: Diffing tests/hard_coded/sub-modules
cvs diff: Diffing tests/hard_coded/typeclasses
cvs diff: Diffing tests/invalid
cvs diff: Diffing tests/invalid/purity
cvs diff: Diffing tests/misc_tests
cvs diff: Diffing tests/recompilation
cvs diff: Diffing tests/tabling
cvs diff: Diffing tests/term
cvs diff: Diffing tests/valid
cvs diff: Diffing tests/warnings
cvs diff: Diffing tools
cvs diff: Diffing trace
cvs diff: Diffing util
cvs diff: Diffing vim
cvs diff: Diffing vim/after
cvs diff: Diffing vim/ftplugin
cvs diff: Diffing vim/syntax
--------------------------------------------------------------------------
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