[m-rev.] for review: avoid C warnings

Zoltan Somogyi zs at cs.mu.OZ.AU
Sun Aug 18 17:03:05 AEST 2002


On 14-Aug-2002, Fergus Henderson <fjh at cs.mu.OZ.AU> wrote:
> In general, declaring fields as `const' is probably not a good idea.
> It makes it very difficult to dynamically allocate values of that type
> (since there would be no type-safe way to initialize the const fields).

OK, I have declared as const only the fields (in unions, not structures)
required to get rid of warnings. The updated diff follows.

After this diff, the only warnings I get during a hlc.gc bootcheck (not
including the tests and the usual warnings from mmake) are warnings caused by
the MLDS backend. In particular, the timestamp module defines an abstract type
called "typestamp" that it privately defines to be a string. The functions
in libs.timestamp.c treat values of type "timestamp" as MR_String; the
functions in other modules treat those same values as if they had C type
MR_Word. According to your post in the thread about my change to
make_port_code, this is a significant problem, but it is one for you to fix.

Zoltan.

----------------------------------------------------

Avoid a bunch of warning messages from the C compiler.

Some of these warning are about discarding const qualifiers in static RTTI
data structures. Others are about non-static definition following static
declaration of unify/compare predicates.

runtime/mercury_type_info.h:
	Declare the alternatives through which we initialize the MR_TypeLayout
	and MR_TypeFunctor unions of type_ctor_infos as const, to avoid
	warnings. This should be OK even if we start creating type_ctor_infos
	at runtime, because any type_ctor_infos created at runtime should be
	initialized through one of the other (non-dummy) alternatives.

	Declare the unify/compare preds of builtin types as extern, not static,
	since they are all exported. This prevents an error message when
	compiling library/array.c.

	Fix a documentation error.

runtime/mercury_builtin_types.c:
	Declare the unify/compare preds of the builtin types defined in this
	module as extern, not static,

cvs diff: Diffing .
cvs diff: Diffing bench
cvs diff: Diffing bench/progs
cvs diff: Diffing bench/progs/compress
cvs diff: Diffing bench/progs/icfp2000
cvs diff: Diffing bench/progs/icfp2001
cvs diff: Diffing bench/progs/nuc
cvs diff: Diffing bench/progs/ray
cvs diff: Diffing bench/progs/tree234
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
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
Index: runtime/mercury_builtin_types.c
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_builtin_types.c,v
retrieving revision 1.1
diff -u -r1.1 mercury_builtin_types.c
--- runtime/mercury_builtin_types.c	2002/08/09 05:26:48	1.1
+++ runtime/mercury_builtin_types.c	2002/08/16 11:56:48
@@ -373,88 +373,88 @@
 ** These are just wrappers which call the unboxed version.
 */
 
-static MR_bool MR_CALL
+MR_bool MR_CALL
 mercury__builtin__do_unify__int_0_0(MR_Box x, MR_Box y)
 {
 	return mercury__builtin____Unify____int_0_0(
 		(MR_Integer) x, (MR_Integer) y);
 }
 
-static MR_bool MR_CALL
+MR_bool MR_CALL
 mercury__builtin__do_unify__string_0_0(MR_Box x, MR_Box y)
 {
 	return mercury__builtin____Unify____string_0_0(
 		(MR_String) x, (MR_String) y);
 }
 
-static MR_bool MR_CALL
+MR_bool MR_CALL
 mercury__builtin__do_unify__float_0_0(MR_Box x, MR_Box y)
 {
 	return mercury__builtin____Unify____float_0_0(
 		MR_unbox_float(x), MR_unbox_float(y));
 }
 
-static MR_bool MR_CALL
+MR_bool MR_CALL
 mercury__builtin__do_unify__character_0_0(MR_Box x, MR_Box y)
 {
 	return mercury__builtin____Unify____character_0_0(
 		(MR_Char) (MR_Word) x, (MR_Char) (MR_Word) y);
 }
 
-static MR_bool MR_CALL
+MR_bool MR_CALL
 mercury__builtin__do_unify__void_0_0(MR_Box x, MR_Box y)
 {
 	MR_fatal_error("called unify/2 for `void' type");
 }
 
-static MR_bool MR_CALL
+MR_bool MR_CALL
 mercury__builtin__do_unify__c_pointer_0_0(MR_Box x, MR_Box y)
 {
 	return mercury__builtin____Unify____c_pointer_0_0(
 		(MR_C_Pointer) x, (MR_C_Pointer) y);
 }
 
-static MR_bool MR_CALL
+MR_bool MR_CALL
 mercury__private_builtin__do_unify__heap_pointer_0_0(MR_Box x, MR_Box y)
 {
 	return mercury__private_builtin____Unify____heap_pointer_0_0(
 		(MR_Heap_Pointer) x, (MR_Heap_Pointer) y);
 }
 
-static MR_bool MR_CALL
+MR_bool MR_CALL
 mercury__builtin__do_unify__func_0_0(MR_Box x, MR_Box y)
 {
 	MR_fatal_error("called unify/2 for `func' type");
 }
 
-static MR_bool MR_CALL
+MR_bool MR_CALL
 mercury__builtin__do_unify__pred_0_0(MR_Box x, MR_Box y)
 {
 	MR_fatal_error("called unify/2 for `pred' type");
 }
 
-static MR_bool MR_CALL
+MR_bool MR_CALL
 mercury__builtin__do_unify__tuple_0_0(MR_Box x, MR_Box y)
 {
 	return mercury__builtin____Unify____tuple_0_0(
 		(MR_Tuple) x, (MR_Tuple) y);
 }
 
-static MR_bool MR_CALL
+MR_bool MR_CALL
 mercury__type_desc__do_unify__type_ctor_desc_0_0(MR_Box x, MR_Box y)
 {
 	return mercury__type_desc____Unify____type_ctor_desc_0_0(
 		(MR_Type_Ctor_Desc) x, (MR_Type_Ctor_Desc) y);
 }
 
-static MR_bool MR_CALL
+MR_bool MR_CALL
 mercury__type_desc__do_unify__type_desc_0_0(MR_Box x, MR_Box y)
 {
 	return mercury__type_desc____Unify____type_desc_0_0(
 		(MR_Type_Desc) x, (MR_Type_Desc) y);
 }
 
-static MR_bool MR_CALL
+MR_bool MR_CALL
 mercury__private_builtin__do_unify__type_ctor_info_1_0(
 	MR_Mercury_Type_Info type_info, MR_Box x, MR_Box y)
 {
@@ -462,7 +462,7 @@
 		type_info, (MR_Mercury_Type_Ctor_Info) x, (MR_Mercury_Type_Ctor_Info) y);
 }
 
-static MR_bool MR_CALL
+MR_bool MR_CALL
 mercury__private_builtin__do_unify__type_info_1_0(
 	MR_Mercury_Type_Info type_info, MR_Box x, MR_Box y)
 {
@@ -470,7 +470,7 @@
 		type_info, (MR_Mercury_Type_Info) x, (MR_Mercury_Type_Info) y);
 }
 
-static MR_bool MR_CALL
+MR_bool MR_CALL
 mercury__private_builtin__do_unify__typeclass_info_1_0(
 	MR_Mercury_Type_Info type_info, MR_Box x, MR_Box y)
 {
@@ -478,7 +478,7 @@
 		type_info, (MR_Mercury_TypeClass_Info) x, (MR_Mercury_TypeClass_Info) y);
 }
 
-static MR_bool MR_CALL
+MR_bool MR_CALL
 mercury__private_builtin__do_unify__base_typeclass_info_1_0(
 	MR_Mercury_Type_Info type_info, MR_Box x, MR_Box y)
 {
@@ -495,7 +495,7 @@
 ** These are just wrappers which call the unboxed version.
 */
 
-static void MR_CALL
+void MR_CALL
 mercury__builtin__do_compare__int_0_0(
 	MR_Comparison_Result *result, MR_Box x, MR_Box y)
 {
@@ -503,7 +503,7 @@
 		(MR_Integer) x, (MR_Integer) y);
 }
 
-static void MR_CALL
+void MR_CALL
 mercury__builtin__do_compare__string_0_0(
 	MR_Comparison_Result *result, MR_Box x, MR_Box y)
 {
@@ -511,7 +511,7 @@
 		(MR_String) x, (MR_String) y);
 }
 
-static void MR_CALL
+void MR_CALL
 mercury__builtin__do_compare__float_0_0(
 	MR_Comparison_Result *result, MR_Box x, MR_Box y)
 {
@@ -519,7 +519,7 @@
 		MR_unbox_float(x), MR_unbox_float(y));
 }
 
-static void MR_CALL
+void MR_CALL
 mercury__builtin__do_compare__character_0_0(
 	MR_Comparison_Result *result, MR_Box x, MR_Box y)
 {
@@ -527,14 +527,14 @@
 		result, (MR_Char) (MR_Word) x, (MR_Char) (MR_Word) y);
 }
 
-static void MR_CALL
+void MR_CALL
 mercury__builtin__do_compare__void_0_0(
 	MR_Comparison_Result *result, MR_Box x, MR_Box y)
 {
 	MR_fatal_error("called compare/3 for `void' type");
 }
 
-static void MR_CALL
+void MR_CALL
 mercury__builtin__do_compare__c_pointer_0_0(
 	MR_Comparison_Result *result, MR_Box x, MR_Box y)
 {
@@ -542,7 +542,7 @@
 		result, (MR_C_Pointer) x, (MR_C_Pointer) y);
 }
 
-static void MR_CALL
+void MR_CALL
 mercury__private_builtin__do_compare__heap_pointer_0_0(
 	MR_Comparison_Result *result, MR_Box x, MR_Box y)
 {
@@ -550,21 +550,21 @@
 		"called compare/3 for `private_builtin:heap_pointer' type");
 }
 
-static void MR_CALL
+void MR_CALL
 mercury__builtin__do_compare__func_0_0(
 	MR_Comparison_Result *result, MR_Box x, MR_Box y)
 {
 	MR_fatal_error("called compare/3 for `func' type");
 }
 
-static void MR_CALL
+void MR_CALL
 mercury__builtin__do_compare__pred_0_0(MR_Comparison_Result *result,
 	MR_Box x, MR_Box y)
 {
 	MR_fatal_error("called compare/3 for `pred' type");
 }
 
-static void MR_CALL
+void MR_CALL
 mercury__builtin__do_compare__tuple_0_0(
 	MR_Comparison_Result *result, MR_Box x, MR_Box y)
 {
@@ -572,7 +572,7 @@
 		result, (MR_Tuple) x, (MR_Tuple) y);
 }
 
-static void MR_CALL
+void MR_CALL
 mercury__type_desc__do_compare__type_ctor_desc_0_0(
 	MR_Comparison_Result *result, MR_Box x, MR_Box y)
 {
@@ -580,7 +580,7 @@
 		result, (MR_Type_Ctor_Desc) x, (MR_Type_Ctor_Desc) y);
 }
 
-static void MR_CALL
+void MR_CALL
 mercury__type_desc__do_compare__type_desc_0_0(
 	MR_Comparison_Result *result, MR_Box x, MR_Box y)
 {
@@ -588,7 +588,7 @@
 		result, (MR_Type_Desc) x, (MR_Type_Desc) y);
 }
 
-static void MR_CALL
+void MR_CALL
 mercury__private_builtin__do_compare__type_ctor_info_1_0(
 	MR_Mercury_Type_Info type_info, MR_Comparison_Result *result,
 	MR_Box x, MR_Box y)
@@ -598,7 +598,7 @@
 		(MR_Mercury_Type_Ctor_Info) x, (MR_Mercury_Type_Ctor_Info) y);
 }
 
-static void MR_CALL
+void MR_CALL
 mercury__private_builtin__do_compare__type_info_1_0(
 	MR_Mercury_Type_Info type_info, MR_Comparison_Result *result,
 	MR_Box x, MR_Box y)
@@ -607,7 +607,7 @@
 		type_info, result, (MR_Mercury_Type_Info) x, (MR_Mercury_Type_Info) y);
 }
 
-static void MR_CALL
+void MR_CALL
 mercury__private_builtin__do_compare__typeclass_info_1_0(
 	MR_Mercury_Type_Info type_info, MR_Comparison_Result *result,
 	MR_Box x, MR_Box y)
@@ -617,7 +617,7 @@
 		(MR_Mercury_TypeClass_Info) x, (MR_Mercury_TypeClass_Info) y);
 }
 
-static void MR_CALL
+void MR_CALL
 mercury__private_builtin__do_compare__base_typeclass_info_1_0(
 	MR_Mercury_Type_Info type_info, MR_Comparison_Result *result,
 	MR_Box x, MR_Box y)
Index: runtime/mercury_type_info.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_type_info.h,v
retrieving revision 1.95
diff -u -r1.95 mercury_type_info.h
--- runtime/mercury_type_info.h	2002/08/09 05:26:50	1.95
+++ runtime/mercury_type_info.h	2002/08/16 10:12:50
@@ -940,7 +940,7 @@
 ** This type describes the identity of the type that an equivalence type
 ** is equivalent to, and hence its layout.
 **
-** An MR_NotagLayout gives the pseudo typeinfo of the type that this type
+** An MR_EquivLayout gives the pseudo typeinfo of the type that this type
 ** is equivalent to.
 **
 ** The intention is that if you have a word in an equivalence type that you
@@ -980,7 +980,7 @@
 */
 
 typedef union {
-    void                        *MR_layout_init;
+    const void                  *MR_layout_init;
     MR_DuTypeLayout             MR_layout_du;
     MR_EnumTypeLayout           MR_layout_enum;
     MR_NotagTypeLayout          MR_layout_notag;
@@ -1025,7 +1025,7 @@
 */
 
 typedef union {
-    void                        *MR_functors_init;
+    const void                  *MR_functors_init;
     MR_DuFunctorDesc            **MR_functors_du;
     MR_MaybeResAddrFunctorDesc  *MR_functors_res;
     MR_EnumFunctorDesc          **MR_functors_enum;
@@ -1169,8 +1169,8 @@
     MR_PASTE2(MR_, MR_PASTE2(NAME, MR_PASTE2(Func_, ARITY)))
 
   #define MR_DEFINE_TYPE_CTOR_INFO_DECLARE_ADDRS(u, c, a)               \
-    static MR_PASTE2(MR_UnifyFunc_, a) u;                               \
-    static MR_PASTE2(MR_CompareFunc_, a) c;
+    extern MR_PASTE2(MR_UnifyFunc_, a) u;                               \
+    extern MR_PASTE2(MR_CompareFunc_, a) c;
 
   #define MR_DEFINE_TYPE_CTOR_INFO_BODY(m, n, a, cr, u, c)              \
     {                                                                   \
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