[PATCH]: Fix -Wc++-compat for alpha-dec-vms and i386-unknown-netware

Kaveh R. GHAZI ghazi@caip.rutgers.edu
Sun Jun 29 18:09:00 GMT 2008


Testing some of the more unusual targets revealed a couple of more warning
nits which I fixed below.

Tested via "make cc1 xgcc" in cross-config to alpha-dec-vms and
i386-unknown-netware (among others).

Okay for mainline?

		Thanks,
		--Kaveh

2008-06-29  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>

	* config/alpha/alpha.c (alpha_need_linkage, alpha_use_linkage):
	Fix -Wc++-compat and/or -Wcast-qual warnings.
	* config/i386/netware.c (gen_stdcall_or_fastcall_decoration,
	gen_regparm_prefix): Likewise.
	* vmsdbgout.c (write_modbeg, lookup_filename,
	vmsdbgout_source_line, vmsdbgout_init): Likewise.

diff -rup orig/egcc-SVN20080628/gcc/config/alpha/alpha.c egcc-SVN20080628/gcc/config/alpha/alpha.c
--- orig/egcc-SVN20080628/gcc/config/alpha/alpha.c	2008-05-10 02:02:39.000000000 +0200
+++ egcc-SVN20080628/gcc/config/alpha/alpha.c	2008-06-28 22:52:48.000000000 +0200
@@ -9489,7 +9489,7 @@ alpha_need_linkage (const char *name, in
   /* Construct a SYMBOL_REF for us to call.  */
   {
     size_t name_len = strlen (name);
-    char *linksym = alloca (name_len + 6);
+    char *linksym = XALLOCAVEC (char, name_len + 6);
     linksym[0] = '$';
     memcpy (linksym + 1, name, name_len);
     memcpy (linksym + 1 + name_len, "..lk", 5);
@@ -9556,7 +9556,7 @@ alpha_use_linkage (rtx linkage, tree cfu

       sprintf (buf, "$%d..%s..lk", cfaf->num, name);
       buflen = strlen (buf);
-      linksym = alloca (buflen + 1);
+      linksym = XALLOCAVEC (char, buflen + 1);
       memcpy (linksym, buf, buflen + 1);

       al->linkage = gen_rtx_SYMBOL_REF
diff -rup orig/egcc-SVN20080628/gcc/config/i386/netware.c egcc-SVN20080628/gcc/config/i386/netware.c
--- orig/egcc-SVN20080628/gcc/config/i386/netware.c	2008-03-14 00:35:50.000000000 +0100
+++ egcc-SVN20080628/gcc/config/i386/netware.c	2008-06-28 23:02:34.000000000 +0200
@@ -77,7 +77,7 @@ gen_stdcall_or_fastcall_decoration (tree
 	}
     }

-  new_str = alloca (1 + strlen (old_str) + 1 + 10 + 1);
+  new_str = XALLOCAVEC (char, 1 + strlen (old_str) + 1 + 10 + 1);
   sprintf (new_str, "%c%s@" HOST_WIDE_INT_PRINT_UNSIGNED,
 	   prefix, old_str, total);

@@ -132,7 +132,7 @@ gen_regparm_prefix (tree decl, tree id,
   if (nregs > total / UNITS_PER_WORD)
     nregs = total / UNITS_PER_WORD;
   gcc_assert (nregs <= 9);
-  new_str = alloca (3 + strlen (old_str) + 1);
+  new_str = XALLOCAVEC (char, 3 + strlen (old_str) + 1);
   sprintf (new_str, "_%u@%s", nregs, old_str);

   return get_identifier (new_str);
diff -rup orig/egcc-SVN20080628/gcc/vmsdbgout.c egcc-SVN20080628/gcc/vmsdbgout.c
--- orig/egcc-SVN20080628/gcc/vmsdbgout.c	2008-06-07 02:00:12.000000000 +0200
+++ egcc-SVN20080628/gcc/vmsdbgout.c	2008-06-28 22:50:01.000000000 +0200
@@ -715,7 +715,7 @@ write_modbeg (int dosizeonly)
   int totsize = 0;

   /* Assumes primary filename has Unix syntax file spec.  */
-  module_name = xstrdup (basename ((char *) primary_filename));
+  module_name = xstrdup (lbasename (primary_filename));

   m = strrchr (module_name, '.');
   if (m)
@@ -1510,9 +1510,8 @@ lookup_filename (const char *file_name)
     {

       file_info_table_allocated += FILE_TABLE_INCREMENT;
-      file_info_table = xrealloc (file_info_table,
-				  (file_info_table_allocated
-				   * sizeof (dst_file_info_entry)));
+      file_info_table = XRESIZEVEC (dst_file_info_entry, file_info_table,
+				    file_info_table_allocated);
     }

   /* Add the new entry to the end of the filename table.  */
@@ -1549,9 +1548,8 @@ vmsdbgout_source_line (register unsigned
       if (line_info_table_in_use == line_info_table_allocated)
 	{
 	  line_info_table_allocated += LINE_INFO_TABLE_INCREMENT;
-	  line_info_table = xrealloc (line_info_table,
-				      (line_info_table_allocated
-				       * sizeof (dst_line_info_entry)));
+	  line_info_table = XRESIZEVEC (dst_line_info_entry, line_info_table,
+					line_info_table_allocated);
 	}

       /* Add the new entry at the end of the line_info_table.  */
@@ -1600,8 +1598,7 @@ vmsdbgout_init (const char *main_input_f
   primary_filename = main_input_filename;

   /* Allocate the initial hunk of the file_info_table.  */
-  file_info_table
-    = xcalloc (FILE_TABLE_INCREMENT, sizeof (dst_file_info_entry));
+  file_info_table = XCNEWVEC (dst_file_info_entry, FILE_TABLE_INCREMENT);
   file_info_table_allocated = FILE_TABLE_INCREMENT;

   /* Skip the first entry - file numbers begin at 1 */
@@ -1612,8 +1609,7 @@ vmsdbgout_init (const char *main_input_f
   func_table_in_use = 1;

   /* Allocate the initial hunk of the line_info_table.  */
-  line_info_table
-    = xcalloc (LINE_INFO_TABLE_INCREMENT, sizeof (dst_line_info_entry));
+  line_info_table = XCNEWVEC (dst_line_info_entry, LINE_INFO_TABLE_INCREMENT);
   line_info_table_allocated = LINE_INFO_TABLE_INCREMENT;
   /* zero-th entry is allocated, but unused */
   line_info_table_in_use = 1;



More information about the Gcc-patches mailing list