This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH, function-specific-branch, committed] Cast alloca/xmalloc results to appropriate type.


I noticed when moving the function specific patches to the current trunk that
we now turn on the warnings about needing a cast from void * when GCC converts
to C++, so this patch fixes some warnings in the code I wrote.

2008-06-25  Michael Meissner  <michael.meissner@amd.com>

	* c-common.c (parse_optimize_options): Cast alloca returns to the
	appropriate pointer type.

	* config/i386/i386.c (ix86_target_string): Cast xmalloc return to
	the appropriate pointer type.
	(ix86_valid_option_attribute_inner_p): Cast alloca return to the
	appropriate pointer type.

Index: gcc/c-common.c
===================================================================
--- gcc/c-common.c	(revision 137076)
+++ gcc/c-common.c	(working copy)
@@ -6652,7 +6652,7 @@ parse_optimize_options (tree args, bool 
       else if (TREE_CODE (value) == STRING_CST)
 	{
 	  size_t len = TREE_STRING_LENGTH (value);
-	  char *p = alloca (len + 1);
+	  char *p = (char *) alloca (len + 1);
 	  char *end = p + len;
 	  char *comma;
 	  char *next_p = p;
@@ -6679,7 +6679,7 @@ parse_optimize_options (tree args, bool 
 		  next_p = NULL;
 		}
 
-	      r = q = alloca (len2 + 3);
+	      r = q = (char *) alloca (len2 + 3);
 
 	      /* If the user supplied -Oxxx or -fxxx, only allow -Oxxx or -fxxx
 		 options.  */
@@ -6717,7 +6717,7 @@ parse_optimize_options (tree args, bool 
     }
 
   opt_argc = VEC_length (const_char_p, optimize_args);
-  opt_argv = alloca (sizeof (char *) * (opt_argc + 1));
+  opt_argv = (const char **) alloca (sizeof (char *) * (opt_argc + 1));
 
   for (i = 1; i < opt_argc; i++)
     opt_argv[i] = VEC_index (const_char_p, optimize_args, i);
Index: gcc/config/i386/i386.c
===================================================================
--- gcc/config/i386/i386.c	(revision 137041)
+++ gcc/config/i386/i386.c	(working copy)
@@ -2326,7 +2326,7 @@ ix86_target_string (int isa, int flags, 
     }
 
   /* Build the string.  */
-  ret = ptr = xmalloc (len);
+  ret = ptr = (char *) xmalloc (len);
   line_len = 0;
 
   for (i = 0; i < num; i++)
@@ -3385,7 +3385,7 @@ ix86_valid_option_attribute_inner_p (tre
     gcc_unreachable ();
 
   /* Handle multiple arguments separated by commas.  */
-  next_optstr = alloca (TREE_STRING_LENGTH (args) + 1);
+  next_optstr = (char *) alloca (TREE_STRING_LENGTH (args) + 1);
   memcpy (next_optstr, TREE_STRING_POINTER (args), TREE_STRING_LENGTH (args));
   next_optstr[ TREE_STRING_LENGTH (args) ] = '\0';
 

-- 
Michael Meissner, AMD
90 Central Street, MS 83-29, Boxborough, MA, 01719, USA
michael.meissner@amd.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]