Revised patch for EXTRA_SPECS missing initializer warnings

Kaveh R. Ghazi ghazi@caip.rutgers.edu
Mon Oct 26 15:26:00 GMT 1998


	On Jim Wilson's request to come up with a more elegant way to
handle the EXTRA_SPECS missing initializer problem, I wrote the
following patch.

	It does the static initialization using an intermediate
structure with exactly the elements EXTRA_SPECS provides.  It then
initializes the actual (larger) structure with these members.  This
nixes the missing initializer warnings while avoiding the need to
diddle with every target file which defines EXTRA_SPECS and/or
SUBTARGET_EXTRA_SPECS.


	This approach should be valid since tm.texi claims EXTRA_SPECS
has exactly two structure members:

 > The definition should be an initializer for an array of structures,
 > containing a string constant, that defines the specification name, and a
 > string constant that provides the specification.
 > 

	I tested it by running "gcc -dumpspecs" after a bootstrap and it
seemed to work fine.  (Assuming that was a valid test,) is this okay to
install?

		--Kaveh





Sun Oct 25 15:24:24 1998  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>

	* gcc.c (EXTRA_SPECS, extra_specs): Introduce an intermediate
 	structure which has exactly the members provided by EXTRA_SPECS.
  	Xmalloc() the real `extra_specs', and initialize it from this
	intermediate structure.

	* alpha.h (EXTRA_SPECS): Revert change for missing initializers.

	* mips.h  (EXTRA_SPECS): Likewise.

	* sparc.h (EXTRA_SPECS): Likewise.

	
diff -rup orig/egcs-CVS19981025/gcc/gcc.c egcs-CVS19981025/gcc/gcc.c
--- orig/egcs-CVS19981025/gcc/gcc.c	Sun Oct 25 09:24:49 1998
+++ egcs-CVS19981025/gcc/gcc.c	Sun Oct 25 15:02:11 1998
@@ -1179,7 +1179,16 @@ static struct spec_list static_specs[] =
 };
 
 #ifdef EXTRA_SPECS		/* additional specs needed */
-static struct spec_list extra_specs[] = { EXTRA_SPECS };
+/* Structure to keep track of just the first two args of a spec_list.
+   That is all that the EXTRA_SPECS macro gives us. */
+struct spec_list_1
+{
+  char *name;
+  char *ptr;
+};
+
+static struct spec_list_1 extra_specs_1[] = { EXTRA_SPECS };
+static struct spec_list * extra_specs = (struct spec_list *)0;
 #endif
 
 /* List of dynamically allocates specs that have been defined so far.  */
@@ -1203,9 +1212,17 @@ init_spec ()
     fprintf (stderr, "Using builtin specs.\n");
 
 #ifdef EXTRA_SPECS
-  for (i = (sizeof (extra_specs) / sizeof (extra_specs[0])) - 1; i >= 0; i--)
+  extra_specs = (struct spec_list *)
+    xmalloc (sizeof(struct spec_list) *
+	     (sizeof(extra_specs_1)/sizeof(extra_specs_1[0])));
+  bzero ((PTR) extra_specs, sizeof(struct spec_list) *
+	 (sizeof(extra_specs_1)/sizeof(extra_specs_1[0])));
+  
+  for (i = (sizeof(extra_specs_1) / sizeof(extra_specs_1[0])) - 1; i >= 0; i--)
     {
       sl = &extra_specs[i];
+      sl->name = extra_specs_1[i].name;
+      sl->ptr = extra_specs_1[i].ptr;
       sl->next = next;
       sl->name_len = strlen (sl->name);
       sl->ptr_spec = &sl->ptr;
diff -rup orig/egcs-CVS19981025/gcc/config/alpha/alpha.h egcs-CVS19981025/gcc/config/alpha/alpha.h
--- orig/egcs-CVS19981025/gcc/config/alpha/alpha.h	Sun Oct 25 09:23:15 1998
+++ egcs-CVS19981025/gcc/config/alpha/alpha.h	Sun Oct 25 15:13:48 1998
@@ -308,21 +308,21 @@ extern char *alpha_mlat_string;	/* For -
 #define SUBTARGET_EXTRA_SPECS
 #endif
 
-#define EXTRA_SPECS						\
-  { "cpp_am_bwx", CPP_AM_BWX_SPEC, 0, 0, 0, 0 },		\
-  { "cpp_am_max", CPP_AM_MAX_SPEC, 0, 0, 0, 0 },		\
-  { "cpp_am_cix", CPP_AM_CIX_SPEC, 0, 0, 0, 0 },		\
-  { "cpp_im_ev4", CPP_IM_EV4_SPEC, 0, 0, 0, 0 },		\
-  { "cpp_im_ev5", CPP_IM_EV5_SPEC, 0, 0, 0, 0 },		\
-  { "cpp_im_ev6", CPP_IM_EV6_SPEC, 0, 0, 0, 0 },		\
-  { "cpp_cpu_ev4", CPP_CPU_EV4_SPEC, 0, 0, 0, 0 },		\
-  { "cpp_cpu_ev5", CPP_CPU_EV5_SPEC, 0, 0, 0, 0 },		\
-  { "cpp_cpu_ev56", CPP_CPU_EV56_SPEC, 0, 0, 0, 0 },		\
-  { "cpp_cpu_pca56", CPP_CPU_PCA56_SPEC, 0, 0, 0, 0 },		\
-  { "cpp_cpu_ev6", CPP_CPU_EV6_SPEC, 0, 0, 0, 0 },		\
-  { "cpp_cpu_default", CPP_CPU_DEFAULT_SPEC, 0, 0, 0, 0 },	\
-  { "cpp_cpu", CPP_CPU_SPEC, 0, 0, 0, 0 },			\
-  { "cpp_subtarget", CPP_SUBTARGET_SPEC, 0, 0, 0, 0 },		\
+#define EXTRA_SPECS				\
+  { "cpp_am_bwx", CPP_AM_BWX_SPEC },		\
+  { "cpp_am_max", CPP_AM_MAX_SPEC },		\
+  { "cpp_am_cix", CPP_AM_CIX_SPEC },		\
+  { "cpp_im_ev4", CPP_IM_EV4_SPEC },		\
+  { "cpp_im_ev5", CPP_IM_EV5_SPEC },		\
+  { "cpp_im_ev6", CPP_IM_EV6_SPEC },		\
+  { "cpp_cpu_ev4", CPP_CPU_EV4_SPEC },		\
+  { "cpp_cpu_ev5", CPP_CPU_EV5_SPEC },		\
+  { "cpp_cpu_ev56", CPP_CPU_EV56_SPEC },	\
+  { "cpp_cpu_pca56", CPP_CPU_PCA56_SPEC },	\
+  { "cpp_cpu_ev6", CPP_CPU_EV6_SPEC },		\
+  { "cpp_cpu_default", CPP_CPU_DEFAULT_SPEC },	\
+  { "cpp_cpu", CPP_CPU_SPEC },			\
+  { "cpp_subtarget", CPP_SUBTARGET_SPEC },	\
   SUBTARGET_EXTRA_SPECS
 
 
diff -rup orig/egcs-CVS19981025/gcc/config/mips/mips.h egcs-CVS19981025/gcc/config/mips/mips.h
--- orig/egcs-CVS19981025/gcc/config/mips/mips.h	Sun Oct 25 09:23:48 1998
+++ egcs-CVS19981025/gcc/config/mips/mips.h	Sun Oct 25 15:15:13 1998
@@ -950,18 +950,18 @@ while (0)
    Do not define this macro if it does not need to do anything.  */
 
 #define EXTRA_SPECS							\
-  { "subtarget_cc1_spec", SUBTARGET_CC1_SPEC, 0, 0, 0, 0 },		\
-  { "subtarget_cpp_spec", SUBTARGET_CPP_SPEC, 0, 0, 0, 0 },		\
-  { "subtarget_cpp_size_spec", SUBTARGET_CPP_SIZE_SPEC, 0, 0, 0, 0 },	\
-  { "long_max_spec", LONG_MAX_SPEC, 0, 0, 0, 0 },			\
-  { "mips_as_asm_spec", MIPS_AS_ASM_SPEC, 0, 0, 0, 0 },			\
-  { "gas_asm_spec", GAS_ASM_SPEC, 0, 0, 0, 0 },				\
-  { "target_asm_spec", TARGET_ASM_SPEC, 0, 0, 0, 0 },			\
-  { "subtarget_mips_as_asm_spec", SUBTARGET_MIPS_AS_ASM_SPEC, 0, 0, 0, 0 }, \
-  { "subtarget_asm_optimizing_spec", SUBTARGET_ASM_OPTIMIZING_SPEC, 0, 0, 0, 0 }, \
-  { "subtarget_asm_debugging_spec", SUBTARGET_ASM_DEBUGGING_SPEC, 0, 0, 0, 0 }, \
-  { "subtarget_asm_spec", SUBTARGET_ASM_SPEC, 0, 0, 0, 0 },		\
-  { "linker_endian_spec", LINKER_ENDIAN_SPEC, 0, 0, 0, 0 },		\
+  { "subtarget_cc1_spec", SUBTARGET_CC1_SPEC },				\
+  { "subtarget_cpp_spec", SUBTARGET_CPP_SPEC },				\
+  { "subtarget_cpp_size_spec", SUBTARGET_CPP_SIZE_SPEC },		\
+  { "long_max_spec", LONG_MAX_SPEC },					\
+  { "mips_as_asm_spec", MIPS_AS_ASM_SPEC },				\
+  { "gas_asm_spec", GAS_ASM_SPEC },					\
+  { "target_asm_spec", TARGET_ASM_SPEC },				\
+  { "subtarget_mips_as_asm_spec", SUBTARGET_MIPS_AS_ASM_SPEC }, 	\
+  { "subtarget_asm_optimizing_spec", SUBTARGET_ASM_OPTIMIZING_SPEC },	\
+  { "subtarget_asm_debugging_spec", SUBTARGET_ASM_DEBUGGING_SPEC },	\
+  { "subtarget_asm_spec", SUBTARGET_ASM_SPEC },				\
+  { "linker_endian_spec", LINKER_ENDIAN_SPEC },				\
   SUBTARGET_EXTRA_SPECS
 
 #ifndef SUBTARGET_EXTRA_SPECS
diff -rup orig/egcs-CVS19981025/gcc/config/sparc/sparc.h egcs-CVS19981025/gcc/config/sparc/sparc.h
--- orig/egcs-CVS19981025/gcc/config/sparc/sparc.h	Sun Oct 25 09:24:01 1998
+++ egcs-CVS19981025/gcc/config/sparc/sparc.h	Sun Oct 25 15:12:58 1998
@@ -316,20 +316,20 @@ Unrecognized value in TARGET_CPU_DEFAULT
    Do not define this macro if it does not need to do anything.  */
 
 #define EXTRA_SPECS \
-  { "cpp_cpu",		CPP_CPU_SPEC, 0, 0, 0, 0 },		\
-  { "cpp_cpu_default",	CPP_CPU_DEFAULT_SPEC, 0, 0, 0, 0 },	\
-  { "cpp_arch32",	CPP_ARCH32_SPEC, 0, 0, 0, 0 },		\
-  { "cpp_arch64",	CPP_ARCH64_SPEC, 0, 0, 0, 0 },		\
-  { "cpp_arch_default",	CPP_ARCH_DEFAULT_SPEC, 0, 0, 0, 0 },	\
-  { "cpp_arch",		CPP_ARCH_SPEC, 0, 0, 0, 0 },		\
-  { "cpp_endian",	CPP_ENDIAN_SPEC, 0, 0, 0, 0 },		\
-  { "cpp_subtarget",	CPP_SUBTARGET_SPEC, 0, 0, 0, 0 },	\
-  { "asm_cpu",		ASM_CPU_SPEC, 0, 0, 0, 0 },		\
-  { "asm_cpu_default",	ASM_CPU_DEFAULT_SPEC, 0, 0, 0, 0 },	\
-  { "asm_arch32",	ASM_ARCH32_SPEC, 0, 0, 0, 0 },		\
-  { "asm_arch64",	ASM_ARCH64_SPEC, 0, 0, 0, 0 },		\
-  { "asm_arch_default",	ASM_ARCH_DEFAULT_SPEC, 0, 0, 0, 0 },	\
-  { "asm_arch",		ASM_ARCH_SPEC, 0, 0, 0, 0 },		\
+  { "cpp_cpu",		CPP_CPU_SPEC },		\
+  { "cpp_cpu_default",	CPP_CPU_DEFAULT_SPEC },	\
+  { "cpp_arch32",	CPP_ARCH32_SPEC },	\
+  { "cpp_arch64",	CPP_ARCH64_SPEC },	\
+  { "cpp_arch_default",	CPP_ARCH_DEFAULT_SPEC },\
+  { "cpp_arch",		CPP_ARCH_SPEC },	\
+  { "cpp_endian",	CPP_ENDIAN_SPEC },	\
+  { "cpp_subtarget",	CPP_SUBTARGET_SPEC },	\
+  { "asm_cpu",		ASM_CPU_SPEC },		\
+  { "asm_cpu_default",	ASM_CPU_DEFAULT_SPEC },	\
+  { "asm_arch32",	ASM_ARCH32_SPEC },	\
+  { "asm_arch64",	ASM_ARCH64_SPEC },	\
+  { "asm_arch_default",	ASM_ARCH_DEFAULT_SPEC },\
+  { "asm_arch",		ASM_ARCH_SPEC },	\
   SUBTARGET_EXTRA_SPECS
 
 #define SUBTARGET_EXTRA_SPECS




More information about the Gcc-patches mailing list