diff --git a/src/acconfig.h b/src/acconfig.h index e612fc9ae280e626be9651db6eecdf820ae5118b..0940c2d7a911366775c106749c2177e6ababbe9b 100644 --- a/src/acconfig.h +++ b/src/acconfig.h @@ -1,5 +1,5 @@ /* - * $Id: acconfig.h,v 1.87 2001/06/12 18:50:27 grubba Exp $ + * $Id: acconfig.h,v 1.88 2001/07/01 21:34:49 mast Exp $ */ #ifndef MACHINE_H #define MACHINE_H @@ -422,6 +422,9 @@ /* set this to the modifier type string to print FLOAT_TYPE, like "L" or "" */ #undef PRINTPIKEFLOAT +/* Define if the compiler understand union initializations. */ +#undef HAVE_UNION_INIT + @BOTTOM@ /* NT stuff */ diff --git a/src/array.c b/src/array.c index c46a741aec35ea7c47321d240a7cd4c5b097317c..88825bc91d1763e29af1604ab51bcbbb8ac0cfd4 100644 --- a/src/array.c +++ b/src/array.c @@ -23,7 +23,7 @@ #include "stuff.h" #include "bignum.h" -RCSID("$Id: array.c,v 1.114 2001/06/30 18:44:21 hubbe Exp $"); +RCSID("$Id: array.c,v 1.115 2001/07/01 21:34:50 mast Exp $"); PMOD_EXPORT struct array empty_array= { @@ -35,18 +35,27 @@ PMOD_EXPORT struct array empty_array= 0, /* no types */ 0, /* no flags */ empty_array.real_item, /* Initialize the item pointer. */ +#ifdef HAVE_UNION_INIT + {{0, 0, {0}}}, /* Only to avoid warnings. */ +#endif }; PMOD_EXPORT struct array weak_empty_array= { PIKE_CONSTANT_MEMOBJ_INIT(1), &weak_shrink_empty_array, &empty_array, 0, 0, 0, ARRAY_WEAK_FLAG, weak_empty_array.real_item, +#ifdef HAVE_UNION_INIT + {{0, 0, {0}}}, /* Only to avoid warnings. */ +#endif }; PMOD_EXPORT struct array weak_shrink_empty_array= { PIKE_CONSTANT_MEMOBJ_INIT(1), &empty_array, &weak_empty_array, 0, 0, 0, ARRAY_WEAK_FLAG|ARRAY_WEAK_SHRINK, weak_shrink_empty_array.real_item, +#ifdef HAVE_UNION_INIT + {{0, 0, {0}}}, /* Only to avoid warnings. */ +#endif }; struct array *gc_internal_array = &empty_array; diff --git a/src/bignum.c b/src/bignum.c index d4edf5106c65639f5f2f79ab01ea52dc9e000bc3..19581433c0c06245c04e5601668f794256a25347 100644 --- a/src/bignum.c +++ b/src/bignum.c @@ -8,7 +8,12 @@ #include "svalue.h" #include "pike_error.h" -struct svalue auto_bignum_program = { T_INT }; +struct svalue auto_bignum_program = { + T_INT, 0, +#ifdef HAVE_UNION_INIT + {0}, /* Only to avoid warnings. */ +#endif +}; PMOD_EXPORT int gmp_library_loaded=0; int gmp_library_resolving=0; diff --git a/src/configure.in b/src/configure.in index 5ffd6f231495c0013327f00ba22fd84c0ed41df2..7497e3478ff29f63b3be5bf0bf91e6cffcc2f7ae 100644 --- a/src/configure.in +++ b/src/configure.in @@ -1,4 +1,4 @@ -AC_REVISION("$Id: configure.in,v 1.529 2001/06/29 23:26:48 hubbe Exp $") +AC_REVISION("$Id: configure.in,v 1.530 2001/07/01 21:34:50 mast Exp $") AC_INIT(interpret.c) AC_CONFIG_HEADER(machine.h) @@ -4964,6 +4964,31 @@ AC_DEFINE_UNQUOTED(PRINTPIKEFLOAT,"$pike_cv_printf_float_type") ####################################################################### +AC_MSG_CHECKING(if union initialization works) +AC_CACHE_VAL(pike_cv_have_union_init, [ + AC_TRY_COMPILE([], [ + struct foo {int a; char *b;}; + struct bar {int c[2];}; + union anything + { + struct foo *foo; + struct bar *bar; + }; + struct svalue + { + unsigned type; + unsigned subtype; + union anything u; + }; + struct svalue my_svalue = {0, 0, {{17, "17"}}}; + ], pike_cv_have_union_init=yes, pike_cv_have_union_init=no)]) +AC_MSG_RESULT($pike_cv_have_union_init) +if test "$pike_cv_have_union_init" = yes; then + AC_DEFINE(HAVE_UNION_INIT) +fi + +####################################################################### + # Set info about shared libraries. AC_SUBST(SO) AC_SUBST(LDSHARED) diff --git a/src/encode.c b/src/encode.c index a79b8c46f12e6b86c72b2e6605965e644fb623b9..de194e5628bd884491205e665cb6404cbd8fdfc0 100644 --- a/src/encode.c +++ b/src/encode.c @@ -25,7 +25,7 @@ #include "version.h" #include "bignum.h" -RCSID("$Id: encode.c,v 1.101 2001/07/01 16:59:45 grubba Exp $"); +RCSID("$Id: encode.c,v 1.102 2001/07/01 21:34:50 mast Exp $"); /* #define ENCODE_DEBUG */ @@ -525,7 +525,12 @@ static void encode_value2(struct svalue *val, struct encode_data *data) #endif { - static struct svalue dested = { T_INT, NUMBER_DESTRUCTED }; + static struct svalue dested = { + T_INT, NUMBER_DESTRUCTED, +#ifdef HAVE_UNION_INIT + {0}, /* Only to avoid warnings. */ +#endif + }; INT32 i; struct svalue *tmp; diff --git a/src/error.c b/src/error.c index 039c9263fdf4708b6ce944d6223432d36f4cabf8..39ae2fe8b3b8e43db993f2eebc9d0d9b0c4e6d34 100644 --- a/src/error.c +++ b/src/error.c @@ -22,7 +22,7 @@ #include "threads.h" #include "gc.h" -RCSID("$Id: error.c,v 1.72 2001/06/18 15:44:40 grubba Exp $"); +RCSID("$Id: error.c,v 1.73 2001/07/01 21:34:50 mast Exp $"); #undef ATTRIBUTE #define ATTRIBUTE(X) @@ -132,7 +132,12 @@ PMOD_EXPORT void push_error(const char *description) f_aggregate(2); } -PMOD_EXPORT struct svalue throw_value = { PIKE_T_INT }; +PMOD_EXPORT struct svalue throw_value = { + PIKE_T_INT, 0, +#ifdef HAVE_UNION_INIT + {0}, /* Only to avoid warnings. */ +#endif +}; int throw_severity; static const char *in_error; diff --git a/src/mapping.c b/src/mapping.c index b6257ce53dd561faa1b977e4b974044b92d39f10..d8243ecc89a026d69016afb4661e94d6d9b8e351 100644 --- a/src/mapping.c +++ b/src/mapping.c @@ -5,7 +5,7 @@ \*/ /**/ #include "global.h" -RCSID("$Id: mapping.c,v 1.127 2001/06/30 21:28:36 mast Exp $"); +RCSID("$Id: mapping.c,v 1.128 2001/07/01 21:34:51 mast Exp $"); #include "main.h" #include "object.h" #include "mapping.h" @@ -135,13 +135,13 @@ static void check_mapping_type_fields(struct mapping *m) #endif static struct mapping_data empty_data = - { PIKE_CONSTANT_MEMOBJ_INIT(1), 1, 0,0,0,0,0,0,0 }; + { PIKE_CONSTANT_MEMOBJ_INIT(1), 1, 0,0,0,0,0,0, 0, 0,{0}}; static struct mapping_data weak_ind_empty_data = - { PIKE_CONSTANT_MEMOBJ_INIT(1), 1, 0,0,0,0,0,0, MAPPING_WEAK_INDICES}; + { PIKE_CONSTANT_MEMOBJ_INIT(1), 1, 0,0,0,0,0,0, MAPPING_WEAK_INDICES, 0,{0}}; static struct mapping_data weak_val_empty_data = - { PIKE_CONSTANT_MEMOBJ_INIT(1), 1, 0,0,0,0,0,0, MAPPING_WEAK_VALUES}; + { PIKE_CONSTANT_MEMOBJ_INIT(1), 1, 0,0,0,0,0,0, MAPPING_WEAK_VALUES, 0,{0}}; static struct mapping_data weak_both_empty_data = - { PIKE_CONSTANT_MEMOBJ_INIT(1), 1, 0,0,0,0,0,0, MAPPING_WEAK }; + { PIKE_CONSTANT_MEMOBJ_INIT(1), 1, 0,0,0,0,0,0, MAPPING_WEAK, 0,{0}}; /* This function allocates the hash table and svalue space for a mapping * struct. The size is the max number of indices that can fit in the diff --git a/src/svalue.c b/src/svalue.c index bb76347e7f3a59000e418bbfba8334e4add4ef97..c4be8fcc42d3f910c6e73b164bcb68dd2a735206 100644 --- a/src/svalue.c +++ b/src/svalue.c @@ -62,9 +62,14 @@ static int pike_isnan(double x) #endif /* HAVE__ISNAN */ #endif /* HAVE_ISNAN */ -RCSID("$Id: svalue.c,v 1.108 2001/07/01 18:26:42 mast Exp $"); +RCSID("$Id: svalue.c,v 1.109 2001/07/01 21:34:51 mast Exp $"); -struct svalue dest_ob_zero = { T_INT, 0 }; +struct svalue dest_ob_zero = { + T_INT, 0, +#ifdef HAVE_UNION_INIT + {0}, /* Only to avoid warnings. */ +#endif +}; /* * This routine frees a short svalue given a pointer to it and