[m-rev.] for review: avoid C warnings
Zoltan Somogyi
zs at cs.mu.OZ.AU
Wed Aug 14 17:00:07 AEST 2002
For review by anyone.
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 MR_fatal_error; yet others about non-static
definition following static declaration of unify/compare predicates.
runtime/mercury_type_info.h:
Declare all the relevant fields of the RTTI data structures as static,
if they weren't already.
Declare the unify/compare preds of builtin types as extern, not static,
since they are all exported.
runtime/mercury_std.h:
Define MR_STATIC_CODE_CONST here. It used to be defined in
mercury_type_info.h *after* some places where it is now needed,
and it is a generally useful macro.
runtime/mercury_construct.c:
library/deconstruct.m:
Add const qualifiers to variable declarations as required.
runtime/mercury.h:
#include mercury_misc.h, for the declaration of MR_fatal_error.
(mercury_imp.h already #includes mercury_misc.h.)
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
Index: library/deconstruct.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/deconstruct.m,v
retrieving revision 1.13
diff -u -r1.13 deconstruct.m
--- library/deconstruct.m 2002/08/01 11:52:23 1.13
+++ library/deconstruct.m 2002/08/13 06:47:49
@@ -804,11 +804,11 @@
get_notag_functor_info(Univ::in, ExpUniv::out),
[will_not_call_mercury, thread_safe, promise_pure],
"{
- MR_TypeInfo type_info;
- MR_TypeInfo exp_type_info;
- MR_TypeCtorInfo type_ctor_info;
- MR_NotagFunctorDesc *functor_desc;
- MR_Word value;
+ MR_TypeInfo type_info;
+ MR_TypeInfo exp_type_info;
+ MR_TypeCtorInfo type_ctor_info;
+ const MR_NotagFunctorDesc *functor_desc;
+ MR_Word value;
MR_unravel_univ(Univ, type_info, value);
type_ctor_info = MR_TYPEINFO_GET_TYPE_CTOR_INFO(type_info);
cvs diff: Diffing profiler
cvs diff: Diffing robdd
cvs diff: Diffing runtime
Index: runtime/mercury.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury.h,v
retrieving revision 1.59
diff -u -r1.59 mercury.h
--- runtime/mercury.h 2002/08/09 05:26:47 1.59
+++ runtime/mercury.h 2002/08/13 09:42:28
@@ -65,6 +65,8 @@
#include <setjmp.h> /* for jmp_buf etc., which are used for commits */
#include <string.h> /* for strcmp(), which is used for =/2 on strings */
+#include "mercury_misc.h" /* for MR_fatal_error() */
+
/*---------------------------------------------------------------------------*/
/*
** Type definitions
Index: runtime/mercury_construct.c
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_construct.c,v
retrieving revision 1.5
diff -u -r1.5 mercury_construct.c
--- runtime/mercury_construct.c 2002/08/01 11:52:26 1.5
+++ runtime/mercury_construct.c 2002/08/13 06:45:52
@@ -52,7 +52,7 @@
case MR_TYPECTOR_REP_DU:
case MR_TYPECTOR_REP_DU_USEREQ:
{
- MR_DuFunctorDesc *functor_desc;
+ const MR_DuFunctorDesc *functor_desc;
if (functor_number < 0 ||
functor_number >= MR_type_ctor_num_functors(type_ctor_info))
@@ -76,7 +76,7 @@
case MR_TYPECTOR_REP_ENUM:
case MR_TYPECTOR_REP_ENUM_USEREQ:
{
- MR_EnumFunctorDesc *functor_desc;
+ const MR_EnumFunctorDesc *functor_desc;
if (functor_number < 0 ||
functor_number >= MR_type_ctor_num_functors(type_ctor_info))
@@ -100,7 +100,7 @@
case MR_TYPECTOR_REP_NOTAG_GROUND:
case MR_TYPECTOR_REP_NOTAG_GROUND_USEREQ:
{
- MR_NotagFunctorDesc *functor_desc;
+ const MR_NotagFunctorDesc *functor_desc;
if (functor_number != 0) {
MR_fatal_error("MR_get_functor_info: "
Index: runtime/mercury_std.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_std.h,v
retrieving revision 1.21
diff -u -r1.21 mercury_std.h
--- runtime/mercury_std.h 2002/08/09 05:26:50 1.21
+++ runtime/mercury_std.h 2002/08/13 06:45:02
@@ -100,6 +100,19 @@
/*---------------------------------------------------------------------------*/
/*
+** MR_STATIC_CODE_CONST -- what to use instead of "const" for code addresses
+** that are constant only with MR_STATIC_CODE_ADDRESSES.
+*/
+
+#ifndef MR_STATIC_CODE_ADDRESSES
+ #define MR_STATIC_CODE_CONST
+#else /* MR_STATIC_CODE_ADDRESSES */
+ #define MR_STATIC_CODE_CONST const
+#endif /* MR_STATIC_CODE_ADDRESSES */
+
+/*---------------------------------------------------------------------------*/
+
+/*
** Macros for inlining.
**
** Inlining is treated differently by C++, C99, and GNU C.
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/13 09:38:55
@@ -772,12 +772,12 @@
typedef struct {
MR_ConstString MR_du_functor_name;
- MR_int_least16_t MR_du_functor_orig_arity;
- MR_int_least16_t MR_du_functor_arg_type_contains_var;
- MR_Sectag_Locn MR_du_functor_sectag_locn;
- MR_int_least8_t MR_du_functor_primary;
- MR_int_least32_t MR_du_functor_secondary;
- MR_int_least32_t MR_du_functor_ordinal;
+ const MR_int_least16_t MR_du_functor_orig_arity;
+ const MR_int_least16_t MR_du_functor_arg_type_contains_var;
+ const MR_Sectag_Locn MR_du_functor_sectag_locn;
+ const MR_int_least8_t MR_du_functor_primary;
+ const MR_int_least32_t MR_du_functor_secondary;
+ const MR_int_least32_t MR_du_functor_ordinal;
const MR_PseudoTypeInfo *MR_du_functor_arg_types;
const MR_ConstString *MR_du_functor_arg_names;
const MR_DuExistInfo *MR_du_functor_exist_info;
@@ -816,8 +816,8 @@
/*---------------------------------------------------------------------------*/
typedef struct {
- MR_ConstString MR_enum_functor_name;
- MR_int_least32_t MR_enum_functor_ordinal;
+ MR_ConstString MR_enum_functor_name;
+ const MR_int_least32_t MR_enum_functor_ordinal;
} MR_EnumFunctorDesc;
typedef const MR_EnumFunctorDesc *MR_EnumFunctorDescPtr;
@@ -825,9 +825,9 @@
/*---------------------------------------------------------------------------*/
typedef struct {
- MR_ConstString MR_notag_functor_name;
- MR_PseudoTypeInfo MR_notag_functor_arg_type;
- MR_ConstString MR_notag_functor_arg_name;
+ MR_ConstString MR_notag_functor_name;
+ const MR_PseudoTypeInfo MR_notag_functor_arg_type;
+ MR_ConstString MR_notag_functor_arg_name;
} MR_NotagFunctorDesc;
typedef const MR_NotagFunctorDesc *MR_NotagFunctorDescPtr;
@@ -835,9 +835,9 @@
/*---------------------------------------------------------------------------*/
typedef struct {
- MR_ConstString MR_ra_functor_name;
- MR_int_least32_t MR_ra_functor_ordinal;
- MR_ReservedAddr MR_ra_functor_reserved_addr;
+ MR_ConstString MR_ra_functor_name;
+ const MR_int_least32_t MR_ra_functor_ordinal;
+ MR_ReservedAddr MR_ra_functor_reserved_addr;
} MR_ReservedAddrFunctorDesc;
typedef const MR_ReservedAddrFunctorDesc *MR_ReservedAddrFunctorDescPtr;
@@ -863,8 +863,8 @@
*/
typedef struct {
- MR_int_least32_t MR_sectag_sharers;
- MR_Sectag_Locn MR_sectag_locn;
+ const MR_int_least32_t MR_sectag_sharers;
+ const MR_Sectag_Locn MR_sectag_locn;
const MR_DuFunctorDesc * const *MR_sectag_alternatives;
} MR_DuPtagLayout;
@@ -925,11 +925,11 @@
*/
typedef struct {
- MR_int_least16_t MR_ra_num_res_numeric_addrs;
- MR_int_least16_t MR_ra_num_res_symbolic_addrs;
+ const MR_int_least16_t MR_ra_num_res_numeric_addrs;
+ const MR_int_least16_t MR_ra_num_res_symbolic_addrs;
const void * const *MR_ra_res_symbolic_addrs;
MR_ReservedAddrFunctorDescPtr const *MR_ra_constants;
- MR_DuTypeLayout MR_ra_other_functors;
+ const MR_DuTypeLayout MR_ra_other_functors;
} MR_ReservedAddrTypeDesc;
typedef MR_ReservedAddrTypeDesc *MR_ReservedAddrTypeLayout;
@@ -980,26 +980,26 @@
*/
typedef union {
- void *MR_layout_init;
- MR_DuTypeLayout MR_layout_du;
- MR_EnumTypeLayout MR_layout_enum;
- MR_NotagTypeLayout MR_layout_notag;
- MR_ReservedAddrTypeLayout MR_layout_reserved_addr;
- MR_EquivLayout MR_layout_equiv;
+ const void *MR_layout_init;
+ const MR_DuTypeLayout MR_layout_du;
+ const MR_EnumTypeLayout MR_layout_enum;
+ const MR_NotagTypeLayout MR_layout_notag;
+ const MR_ReservedAddrTypeLayout MR_layout_reserved_addr;
+ const MR_EquivLayout MR_layout_equiv;
} MR_TypeLayout;
/*---------------------------------------------------------------------------*/
typedef union {
- MR_DuFunctorDesc *MR_maybe_res_du_ptr;
- MR_ReservedAddrFunctorDesc *MR_maybe_res_res_ptr;
+ const MR_DuFunctorDesc *MR_maybe_res_du_ptr;
+ const MR_ReservedAddrFunctorDesc *MR_maybe_res_res_ptr;
} MR_MaybeResFunctorDescPtr;
typedef struct {
- MR_ConstString MR_maybe_res_name;
- MR_Integer MR_maybe_res_arity;
- MR_bool MR_maybe_res_is_res;
- MR_MaybeResFunctorDescPtr MR_maybe_res_ptr;
+ MR_ConstString MR_maybe_res_name;
+ const MR_Integer MR_maybe_res_arity;
+ const MR_bool MR_maybe_res_is_res;
+ const MR_MaybeResFunctorDescPtr MR_maybe_res_ptr;
} MR_MaybeResAddrFunctorDesc;
#define MR_maybe_res_du MR_maybe_res_ptr.MR_maybe_res_du_ptr
@@ -1025,11 +1025,11 @@
*/
typedef union {
- void *MR_functors_init;
- MR_DuFunctorDesc **MR_functors_du;
- MR_MaybeResAddrFunctorDesc *MR_functors_res;
- MR_EnumFunctorDesc **MR_functors_enum;
- MR_NotagFunctorDesc *MR_functors_notag;
+ const void *MR_functors_init;
+ const MR_DuFunctorDesc **MR_functors_du;
+ const MR_MaybeResAddrFunctorDesc *MR_functors_res;
+ const MR_EnumFunctorDesc **MR_functors_enum;
+ const MR_NotagFunctorDesc *MR_functors_notag;
} MR_TypeFunctors;
/*---------------------------------------------------------------------------*/
@@ -1045,22 +1045,22 @@
*/
struct MR_TypeCtorInfo_Struct {
- MR_Integer MR_type_ctor_arity;
- MR_int_least8_t MR_type_ctor_version;
- MR_int_least8_t MR_type_ctor_num_ptags; /* if DU */
- MR_TypeCtorRepInt MR_type_ctor_rep_CAST_ME;
- MR_ProcAddr MR_type_ctor_unify_pred;
- MR_ProcAddr MR_type_ctor_compare_pred;
- MR_ConstString MR_type_ctor_module_name;
- MR_ConstString MR_type_ctor_name;
- MR_TypeFunctors MR_type_ctor_functors;
- MR_TypeLayout MR_type_ctor_layout;
- MR_int_least32_t MR_type_ctor_num_functors;
+ const MR_Integer MR_type_ctor_arity;
+ const MR_int_least8_t MR_type_ctor_version;
+ const MR_int_least8_t MR_type_ctor_num_ptags; /* if DU */
+ const MR_TypeCtorRepInt MR_type_ctor_rep_CAST_ME;
+ MR_STATIC_CODE_CONST MR_ProcAddr MR_type_ctor_unify_pred;
+ MR_STATIC_CODE_CONST MR_ProcAddr MR_type_ctor_compare_pred;
+ const MR_ConstString MR_type_ctor_module_name;
+ const MR_ConstString MR_type_ctor_name;
+ const MR_TypeFunctors MR_type_ctor_functors;
+ const MR_TypeLayout MR_type_ctor_layout;
+ const MR_int_least32_t MR_type_ctor_num_functors;
/*
** The following fields will be added later, once we can exploit them:
-** MR_TrieNodePtr MR_type_ctor_std_table;
-** MR_ProcAddr MR_type_ctor_prettyprinter;
+** MR_TrieNodePtr MR_type_ctor_std_table;
+** MR_STATIC_CODE_CONST MR_ProcAddr MR_type_ctor_prettyprinter;
*/
};
@@ -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) \
{ \
@@ -1322,8 +1322,6 @@
#define MR_MAYBE_STATIC_CODE(X) NULL
- #define MR_STATIC_CODE_CONST
-
#define MR_INIT_TYPE_CTOR_INFO(B, T) \
do { \
(B).MR_type_ctor_unify_pred = \
@@ -1351,8 +1349,6 @@
#else /* MR_STATIC_CODE_ADDRESSES */
#define MR_MAYBE_STATIC_CODE(X) (X)
-
- #define MR_STATIC_CODE_CONST const
#define MR_INIT_TYPE_CTOR_INFO(B, T) \
do { } while (0)
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