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]

[gcc-in-cxx] Use CONST_CAST


In C++ it is necessary to actually use the CONST_CAST macro to avoid a
warning.  I committed this patch to the gcc-in-cxx branch to replace a
few casts with CONST_CAST.

Ian


2009-03-04  Ian Lance Taylor  <iant@google.com>

	* gcc.c (process_command, main): Use CONST_CAST.
	* collect2.c (main, scan_prog_file): Likewise.


Index: gcc.c
===================================================================
--- gcc.c	(revision 144568)
+++ gcc.c	(working copy)
@@ -3605,10 +3605,11 @@ process_command (int argc, const char **
     }
 
   /* Convert new-style -- options to old-style.  */
-  translate_options (&argc, (const char *const **) &argv);
+  translate_options (&argc, CONST_CAST (const char *const **, &argv));
 
   /* Do language-specific adjustment/addition of flags.  */
-  lang_specific_driver (&argc, (const char *const **) &argv, &added_libraries);
+  lang_specific_driver (&argc, CONST_CAST (const char *const **, &argv),
+			&added_libraries);
 
   /* Scan argv twice.  Here, the first time, just count how many switches
      there will be in their vector, and how many input files in theirs.
@@ -6336,7 +6337,7 @@ main (int argc, char **argv)
      Make a table of specified input files (infiles, n_infiles).
      Decode switches that are handled locally.  */
 
-  process_command (argc, (const char **) argv);
+  process_command (argc, CONST_CAST (const char **, argv));
 
   /* Initialize the vector of specs to just the default.
      This means one element containing 0s, as a terminator.  */
Index: collect2.c
===================================================================
--- collect2.c	(revision 144568)
+++ collect2.c	(working copy)
@@ -856,9 +856,9 @@ main (int argc, char **argv)
   /* Do not invoke xcalloc before this point, since locale needs to be
      set first, in case a diagnostic is issued.  */
 
-  ld1 = (const char **)(ld1_argv = XCNEWVEC (char *, argc+4));
-  ld2 = (const char **)(ld2_argv = XCNEWVEC (char *, argc+11));
-  object = (const char **)(object_lst = XCNEWVEC (char *, argc));
+  ld1 = CONST_CAST (const char **, (ld1_argv = XCNEWVEC (char *, argc+4)));
+  ld2 = CONST_CAST (const char **, (ld2_argv = XCNEWVEC (char *, argc+11)));
+  object = CONST_CAST (const char **, (object_lst = XCNEWVEC (char *, argc)));
 
 #ifdef DEBUG
   debug = 1;
@@ -903,7 +903,7 @@ main (int argc, char **argv)
      -fno-exceptions -w */
   num_c_args += 5;
 
-  c_ptr = (const char **) (c_argv = XCNEWVEC (char *, num_c_args));
+  c_ptr = CONST_CAST (const char **, (c_argv = XCNEWVEC (char *, num_c_args)));
 
   if (argc < 2)
     fatal ("no arguments");
@@ -1405,7 +1405,8 @@ main (int argc, char **argv)
       if (strip_flag)
 	{
 	  char **real_strip_argv = XCNEWVEC (char *, 3);
-	  const char ** strip_argv = (const char **) real_strip_argv;
+	  const char ** strip_argv = CONST_CAST (const char **,
+						 real_strip_argv);
 
 	  strip_argv[0] = strip_file_name;
 	  strip_argv[1] = output_file;
@@ -2089,7 +2090,7 @@ scan_prog_file (const char *prog_name, e
   void (*quit_handler) (int);
 #endif
   char *real_nm_argv[4];
-  const char **nm_argv = (const char **) real_nm_argv;
+  const char **nm_argv = CONST_CAST (const char **, real_nm_argv);
   int argc = 0;
   struct pex_obj *pex;
   const char *errmsg;

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