]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
middle-end: replace CONST_CAST with const_cast<> [PR123892]
authorTorbjörn SVENSSON <torbjorn.svensson@foss.st.com>
Wed, 4 Feb 2026 13:23:44 +0000 (14:23 +0100)
committerTorbjörn SVENSSON <torbjorn.svensson@foss.st.com>
Fri, 6 Feb 2026 08:02:04 +0000 (09:02 +0100)
gcc/ChangeLog:

PR middle-end/123892
* attribs.cc: Replace CONST_CAST with const_cast<>.
* builtins.cc: Likewise.
* collect2.cc: Likewise.
* config/bpf/core-builtins.cc: Likewise.
* config/gcn/mkoffload.cc: Likewise.
* config/nvptx/mkoffload.cc: Likewise.
* config/nvptx/nvptx.cc: Likewise.
* ctfc.cc: Likewise.
* dumpfile.cc: Likewise.
* gcc.cc: Likewise.
* gcov.cc: Likewise.
* gengtype-parse.cc: Likewise.
* gengtype-state.cc: Likewise.
* gengtype.cc: Likewise.
* genoutput.cc: Likewise.
* ggc-page.cc: Likewise.
* godump.cc: Likewise.
* lto-section-in.cc: Likewise.
* lto-wrapper.cc: Likewise.
* omp-offload.cc: Likewise.
* passes.cc: Likewise.
* plugin.cc: Likewise.
* prefix.cc: Likewise.
* pretty-print.cc: Likewise.
* selftest.cc: Likewise.
* statistics.cc: Likewise.
* stringpool.cc: Likewise.
* tree.h: Likewise.
* tree-profile.cc: Likewise.
* vec.h: Likewise.
* system.h (CONST_CAST2): Remove.
(CONST_CAST): Likewise.
* tsystem.h (CONST_CAST2): Remove.
(CONST_CAST): Likewise.

gcc/c-family/ChangeLog:

PR middle-end/123892
* c-common.cc: Replace CONST_CAST with const_cast<>.
* c-lex.cc: Likewise.

gcc/c/ChangeLog:

PR middle-end/123892
* c-decl.cc: Replace CONST_CAST with const_cast<>.
* c-parser.cc: Likewise.

gcc/cp/ChangeLog:

PR middle-end/123892
* call.cc: Replace CONST_CAST with const_cast<>.
* parser.cc: Likewise.

gcc/d/ChangeLog:

PR middle-end/123892
* d-builtins.cc: Replace CONST_CAST with const_cast<>.
* d-incpath.cc: Likewise.
* d-lang.cc: Likewise.
* d-spec.cc: Likewise.
* decl.cc: Likewise.

gcc/fortran/ChangeLog:

PR middle-end/123892
* gfortran.h: Replace CONST_CAST with const_cast<>.
* module.cc: Likewise.
* openmp.cc: Likewise.
* options.cc: Likewise.
* parse.cc: Likewise.
* scanner.cc: Likewise.
* st.cc: Likewise.
* trans-intrinsic.cc: Likewise.

gcc/lto/ChangeLog:

PR middle-end/123892
* lto-common.cc: Replace CONST_CAST with const_cast<>.
* lto.cc: Likewise.

Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
53 files changed:
gcc/attribs.cc
gcc/builtins.cc
gcc/c-family/c-common.cc
gcc/c-family/c-lex.cc
gcc/c/c-decl.cc
gcc/c/c-parser.cc
gcc/collect2.cc
gcc/config/bpf/core-builtins.cc
gcc/config/gcn/mkoffload.cc
gcc/config/nvptx/mkoffload.cc
gcc/config/nvptx/nvptx.cc
gcc/cp/call.cc
gcc/cp/parser.cc
gcc/ctfc.cc
gcc/d/d-builtins.cc
gcc/d/d-incpath.cc
gcc/d/d-lang.cc
gcc/d/d-spec.cc
gcc/d/decl.cc
gcc/dumpfile.cc
gcc/fortran/gfortran.h
gcc/fortran/module.cc
gcc/fortran/openmp.cc
gcc/fortran/options.cc
gcc/fortran/parse.cc
gcc/fortran/scanner.cc
gcc/fortran/st.cc
gcc/fortran/trans-intrinsic.cc
gcc/gcc.cc
gcc/gcov.cc
gcc/gengtype-parse.cc
gcc/gengtype-state.cc
gcc/gengtype.cc
gcc/genoutput.cc
gcc/ggc-page.cc
gcc/godump.cc
gcc/lto-section-in.cc
gcc/lto-wrapper.cc
gcc/lto/lto-common.cc
gcc/lto/lto.cc
gcc/omp-offload.cc
gcc/passes.cc
gcc/plugin.cc
gcc/prefix.cc
gcc/pretty-print.cc
gcc/selftest.cc
gcc/statistics.cc
gcc/stringpool.cc
gcc/system.h
gcc/tree-profile.cc
gcc/tree.h
gcc/tsystem.h
gcc/vec.h

index ab79ca379ac4524d371f0c9c67e501d87c56d8f5..1205b2fc1dfb4ec16c380175c3c959b6b36cf52a 100644 (file)
@@ -371,7 +371,7 @@ register_scoped_attribute (const struct attribute_spec *attr,
         ->find_slot_with_hash (&str, substring_hash (str.str, str.length),
                                INSERT);
   gcc_assert (!*slot || attr->name[0] == '*');
-  *slot = CONST_CAST (struct attribute_spec *, attr);
+  *slot = const_cast<struct attribute_spec *> (attr);
 }
 
 /* Return the spec for the scoped attribute with namespace NS and
index 28454c5377700ca28c9124b8d0dc9e02dd6ca8f0..692e20088c28983f9f7bfadf706ea19c703afd95 100644 (file)
@@ -3788,12 +3788,12 @@ expand_builtin_memory_copy_args (tree dest, tree src, tree len,
       && CONST_INT_P (len_rtx)
       && (unsigned HOST_WIDE_INT) INTVAL (len_rtx) <= nbytes
       && can_store_by_pieces (INTVAL (len_rtx), builtin_memcpy_read_str,
-                             CONST_CAST (char *, rep),
+                             const_cast<char *> (rep),
                              dest_align, false))
     {
       dest_mem = store_by_pieces (dest_mem, INTVAL (len_rtx),
                                  builtin_memcpy_read_str,
-                                 CONST_CAST (char *, rep),
+                                 const_cast<char *> (rep),
                                  dest_align, false, retmode);
       dest_mem = force_operand (XEXP (dest_mem, 0), target);
       dest_mem = convert_memory_address (ptr_mode, dest_mem);
@@ -4142,14 +4142,14 @@ expand_builtin_strncpy (tree exp, rtx target)
       if (!p || dest_align == 0 || !tree_fits_uhwi_p (len)
          || !can_store_by_pieces (tree_to_uhwi (len),
                                   builtin_strncpy_read_str,
-                                  CONST_CAST (char *, p),
+                                  const_cast<char *> (p),
                                   dest_align, false))
        return NULL_RTX;
 
       dest_mem = get_memory_rtx (dest, len);
       store_by_pieces (dest_mem, tree_to_uhwi (len),
                       builtin_strncpy_read_str,
-                      CONST_CAST (char *, p), dest_align, false,
+                      const_cast<char *> (p), dest_align, false,
                       RETURN_BEGIN);
       dest_mem = force_operand (XEXP (dest_mem, 0), target);
       dest_mem = convert_memory_address (ptr_mode, dest_mem);
@@ -4927,7 +4927,7 @@ expand_builtin_memcmp (tree exp, rtx target, bool result_eq)
   result = emit_block_cmp_hints (arg1_rtx, arg2_rtx, len_rtx,
                                 TREE_TYPE (len), target,
                                 result_eq, constfn,
-                                CONST_CAST (char *, rep),
+                                const_cast<char *> (rep),
                                 tree_ctz (len));
 
   if (result)
index 7f891e1ef4935f22595a9e18ed9d9710a4ddcaa3..22d51162d9bb506ed203486f334b09449a5b5333 100644 (file)
@@ -853,7 +853,7 @@ fix_string_type (tree value)
     {
       error ("size of string literal is too large");
       length = tree_to_shwi (TYPE_MAX_VALUE (ssizetype)) / charsz * charsz;
-      char *str = CONST_CAST (char *, TREE_STRING_POINTER (value));
+      char *str = const_cast<char *> (TREE_STRING_POINTER (value));
       memset (str + length, '\0',
              MIN (TREE_STRING_LENGTH (value) - length, charsz));
       TREE_STRING_LENGTH (value) = length;
index 4c0354e63a98cea402d947263a5ed44c555b14a0..1750fbc3d062448244b605ed3bbfa95bb7fb93a4 100644 (file)
@@ -174,7 +174,7 @@ cb_ident (cpp_reader * ARG_UNUSED (pfile),
       if (cpp_interpret_string (pfile, str, 1, &cstr, CPP_STRING))
        {
          targetm.asm_out.output_ident ((const char *) cstr.text);
-         free (CONST_CAST (unsigned char *, cstr.text));
+         free (const_cast<unsigned char *> (cstr.text));
        }
     }
 }
@@ -633,7 +633,7 @@ c_lex_with_flags (tree *value, location_t *loc, unsigned char *cpp_flags,
                                            (const char *) tok->val.str.text);
            TREE_TYPE (num_string) = char_array_type_node;
            num_string = fix_string_type (num_string);
-           str = CONST_CAST (char *, TREE_STRING_POINTER (num_string));
+           str = const_cast<char *> (TREE_STRING_POINTER (num_string));
            str[len] = '\0';
            literal = build_userdef_literal (suffix_id, *value, overflow,
                                             num_string);
@@ -1700,7 +1700,7 @@ lex_string (const cpp_token *tok, tree *valp, bool objc_string, bool translate)
       (parse_in, strs, concats + 1, &istr, type))
     {
       value = build_string (istr.len, (const char *) istr.text);
-      free (CONST_CAST (unsigned char *, istr.text));
+      free (const_cast<unsigned char *> (istr.text));
       if (concats)
        {
          gcc_assert (locs);
index ea0eaec0bb5d31bfb45ca49f6f9525f28d57551a..f2440a0a630091449f7015452a35350c819dee3e 100644 (file)
@@ -5015,7 +5015,7 @@ c_make_fname_decl (location_t loc, tree id, int type_dep)
   DECL_ARTIFICIAL (decl) = 1;
 
   init = build_string (length + 1, name);
-  free (CONST_CAST (char *, name));
+  free (const_cast<char *> (name));
   TREE_TYPE (init) = type;
   DECL_INITIAL (decl) = init;
 
index 5ab3d84ea80cc3e7ccf2ff6f5635ada9302804d3..9816a9425ce1e6700526b26cfc9ec2ef180b6036 100644 (file)
@@ -9893,7 +9893,7 @@ c_parser_string_literal (c_parser *parser, bool translate, bool wide_ok)
          (parse_in, strs, count, &istr, type)))
     {
       value = build_string (istr.len, (const char *) istr.text);
-      free (CONST_CAST (unsigned char *, istr.text));
+      free (const_cast<unsigned char *> (istr.text));
       if (count > 1)
        {
          location_t *locs = (location_t *) obstack_finish (&loc_ob);
index cebdb488781edb741fd3914978d94d4c1094848e..4353be6e3e7d2b79c087617eccc2888a3d064347 100644 (file)
@@ -2760,7 +2760,7 @@ scan_prog_file (const char *prog_name, scanpass which_pass,
         non-const char * filename parameter, even though it will not
         modify that string.  So we must cast away const-ness here,
         using CONST_CAST to prevent complaints from -Wcast-qual.  */
-      if ((ldptr = ldopen (CONST_CAST (char *, prog_name), ldptr)) != NULL)
+      if ((ldptr = ldopen (const_cast<char *> (prog_name), ldptr)) != NULL)
        {
          if (! MY_ISCOFF (HEADER (ldptr).f_magic))
            {
index 9eca8a7a55fb601bccd0370590167600fe0eb1ee..d366b7c06a4f6c8f47a8cac9aa7ffae1e205db8a 100644 (file)
@@ -799,7 +799,7 @@ process_field_expr (struct cr_builtins *data)
       for (int i = 0; i < nr_accessors; i++)
        n += snprintf (str + n, sizeof (str) - n,
                       i == 0 ? "%u" : ":%u", accessors[i]);
-      ret.str = CONST_CAST (char *, ggc_strdup (str));
+      ret.str = const_cast<char *> (ggc_strdup (str));
     }
   else
     gcc_unreachable ();
@@ -916,7 +916,7 @@ process_enum_value (struct cr_builtins *data)
      in 6 chars.  */
   char tmp[6];
   sprintf (tmp, "%u", index);
-  ret.str = CONST_CAST (char *, ggc_strdup(tmp));
+  ret.str = const_cast<char *> (ggc_strdup (tmp));
 
   return ret;
 }
index 2bad9b4e2d36276b0aa7d574fe270c375111ab7d..71e11f0f307b540126a06d2a80605131330e1ba1 100644 (file)
@@ -182,7 +182,7 @@ xputenv (const char *string)
 {
   if (verbose)
     fprintf (stderr, "%s\n", string);
-  putenv (CONST_CAST (char *, string));
+  putenv (const_cast<char *> (string));
 }
 
 /* Parse STR, saving found tokens into PVALUES and return their number.
@@ -839,7 +839,7 @@ compile_native (const char *infile, const char *outfile, const char *compiler,
   obstack_ptr_grow (&argv_obstack, NULL);
 
   const char **new_argv = XOBFINISH (&argv_obstack, const char **);
-  fork_execute (new_argv[0], CONST_CAST (char **, new_argv), true,
+  fork_execute (new_argv[0], const_cast<char **> (new_argv), true,
                ".gccnative_args");
   obstack_free (&argv_obstack, NULL);
 }
@@ -1366,8 +1366,10 @@ main (int argc, char **argv)
       obstack_ptr_grow (&files_to_cleanup, omp_requires_file);
 
       /* Run the compiler pass.  */
-      xputenv (concat ("GCC_OFFLOAD_OMP_REQUIRES_FILE=", omp_requires_file, NULL));
-      fork_execute (cc_argv[0], CONST_CAST (char **, cc_argv), true, ".gcc_args");
+      xputenv (concat ("GCC_OFFLOAD_OMP_REQUIRES_FILE=", omp_requires_file,
+                      NULL));
+      fork_execute (cc_argv[0], const_cast<char **> (cc_argv), true,
+                   ".gcc_args");
       obstack_free (&cc_argv_obstack, NULL);
       unsetenv("GCC_OFFLOAD_OMP_REQUIRES_FILE");
 
@@ -1395,7 +1397,8 @@ main (int argc, char **argv)
       fclose (out);
 
       /* Run the assemble/link pass.  */
-      fork_execute (ld_argv[0], CONST_CAST (char **, ld_argv), true, ".ld_args");
+      fork_execute (ld_argv[0], const_cast<char **> (ld_argv), true,
+                   ".ld_args");
       obstack_free (&ld_argv_obstack, NULL);
 
       process_obj (gcn_o_name, cfile, omp_requires);
index 3d61339e8759bd840b0e0b7865d40c32329855a9..6a2a3bc939b0e695baa999aa83d62ea4cba5ea94 100644 (file)
@@ -104,7 +104,7 @@ xputenv (const char *string)
 {
   if (verbose)
     fprintf (stderr, "%s\n", string);
-  putenv (CONST_CAST (char *, string));
+  putenv (const_cast<char *> (string));
 }
 
 
@@ -625,7 +625,7 @@ compile_native (const char *infile, const char *outfile, const char *compiler,
   obstack_ptr_grow (&argv_obstack, NULL);
 
   const char **new_argv = XOBFINISH (&argv_obstack, const char **);
-  fork_execute (new_argv[0], CONST_CAST (char **, new_argv), true,
+  fork_execute (new_argv[0], const_cast<char **> (new_argv), true,
                ".gccnative_args");
   obstack_free (&argv_obstack, NULL);
 }
@@ -842,7 +842,7 @@ main (int argc, char **argv)
        omp_requires_file = make_temp_file (".mkoffload.omp_requires");
 
       xputenv (concat ("GCC_OFFLOAD_OMP_REQUIRES_FILE=", omp_requires_file, NULL));
-      fork_execute (new_argv[0], CONST_CAST (char **, new_argv), true,
+      fork_execute (new_argv[0], const_cast<char **> (new_argv), true,
                    ".gcc_args");
       obstack_free (&argv_obstack, NULL);
       unsetenv("GCC_OFFLOAD_OMP_REQUIRES_FILE");
index dbe788c7bbca91824b450088fa230caf7e89fb2e..4cee096cca502126d872053984707c423bfd4149 100644 (file)
@@ -513,7 +513,7 @@ section_for_sym (rtx sym)
 static const char *
 section_for_decl (const_tree decl)
 {
-  return section_for_sym (XEXP (DECL_RTL (CONST_CAST (tree, decl)), 0));
+  return section_for_sym (XEXP (DECL_RTL (const_cast<tree> (decl)), 0));
 }
 
 /* Check NAME for special function names and redirect them by returning a
index 979343e8329a3e635e6254d960e90e3172988e67..c23a615fa1a9cc31477f82e2e991f9d036caa0f9 100644 (file)
@@ -11848,7 +11848,7 @@ name_as_c_string (tree name, tree type, bool *free_p)
   else
     pretty_name = identifier_to_locale (IDENTIFIER_POINTER (name));
 
-  return CONST_CAST (char *, pretty_name);
+  return const_cast<char *> (pretty_name);
 }
 
 /* If CANDIDATES contains exactly one candidate, return it, otherwise
index 4d988c27cb802edceca6b0c4c64741061a94aea4..5f1d028de0cc3eeb0896c4cea2335c167d5722e5 100644 (file)
@@ -5024,7 +5024,7 @@ cp_parser_string_literal_common (cp_parser *parser, bool translate,
       (parse_in, strs, count, &istr, type))
     {
       value = build_string (istr.len, (const char *)istr.text);
-      free (CONST_CAST (unsigned char *, istr.text));
+      free (const_cast<unsigned char *> (istr.text));
       if (count > 1)
        {
          location_t *locs = (location_t *)obstack_finish (&loc_ob);
index 4609b3dc3212b51e2847279cf0ad6aadfeb1edaf..8beca20df8c8752143f453c64a17beafc76e5331 100644 (file)
@@ -292,7 +292,7 @@ ctfc_strtable_add_str (ctf_strtable_t * str_table, const char * name,
      not add null strings, return the offset to the empty string for them.  */
   if ((!name || (name != NULL && !strcmp (name, ""))) && str_offset)
     {
-      ctf_string = CONST_CAST (char *, str_table->ctstab_estr);
+      ctf_string = const_cast<char *> (str_table->ctstab_estr);
       str_offset = 0;
     }
   else
@@ -300,7 +300,7 @@ ctfc_strtable_add_str (ctf_strtable_t * str_table, const char * name,
       gcc_assert (name);
       /* Add null-terminated strings to the string table.  */
       len = strlen (name) + 1;
-      ctf_string = CONST_CAST (char *, ggc_strdup (name));
+      ctf_string = const_cast<char *> (ggc_strdup (name));
 
       ctfc_strtable_append_str (str_table, ctf_string);
       /* Add string to the string table.  Keep number of strings updated.  */
@@ -357,7 +357,7 @@ ctf_add_cuname (ctf_container_ref ctfc, const char * filename)
     }
   else
     /* Filename is an absolute path.  */
-    cuname = CONST_CAST (char *, ggc_strdup (filename));
+    cuname = const_cast<char *> (ggc_strdup (filename));
 
   ctf_add_string (ctfc, cuname, &(ctfc->ctfc_cuname_offset));
   /* Add 1 as CTF strings in the CTF string table are null-terminated
index dce03e9f53b976fca0d7b9bd7e89a86d28a3e2d4..4f42c11cd7d7115b4217fe1557d7d715692e86d8 100644 (file)
@@ -386,7 +386,7 @@ d_eval_constant_expression (const Loc &loc, tree cst)
        {
          const void *string = TREE_STRING_POINTER (cst);
          size_t len = TREE_STRING_LENGTH (cst) - 1;
-         return StringExp::create (loc, CONST_CAST (void *, string), len);
+         return StringExp::create (loc, const_cast<void *> (string), len);
        }
       else if (code == VECTOR_CST)
        {
index aaafc77b0a015f9a19cfca75516b44626c5e170f..61565005922f7e0f67c1af00000f3fe329161aed 100644 (file)
@@ -77,7 +77,7 @@ add_globalpaths (Strings &paths)
       if (target == NULL || !FileName::exists (target))
        {
          if (target)
-           free (CONST_CAST (char *, target));
+           free (const_cast<char *> (target));
          continue;
        }
 
@@ -97,7 +97,7 @@ add_filepaths (Strings &paths)
 
       if (!FileName::exists (target))
        {
-         free (CONST_CAST (char *, target));
+         free (const_cast<char *> (target));
          continue;
        }
 
index a522e51f5a2078c93c3d319808ed0d02579b180c..815b1782a654f36803cea960eda6307c0498cd6f 100644 (file)
@@ -455,7 +455,7 @@ d_handle_option (size_t scode, const char *arg, HOST_WIDE_INT value,
       break;
 
     case OPT_fdebug_:
-      if (Identifier::isValidIdentifier (CONST_CAST (char *, arg)))
+      if (Identifier::isValidIdentifier (const_cast<char *> (arg)))
        {
          DebugCondition::addGlobalIdent (arg);
          break;
@@ -700,7 +700,7 @@ d_handle_option (size_t scode, const char *arg, HOST_WIDE_INT value,
       break;
 
     case OPT_fversion_:
-      if (Identifier::isValidIdentifier (CONST_CAST (char *, arg)))
+      if (Identifier::isValidIdentifier (const_cast<char *> (arg)))
        {
          VersionCondition::addGlobalIdent (arg);
          break;
index c4600b2e9f4d38165662084be877cfe99d166993..2993d3475b47b4b7961cc667ae4a4caee1ef5f5d 100644 (file)
@@ -162,7 +162,7 @@ lang_specific_driver (cl_decoded_option **in_decoded_options,
          break;
 
        case OPT_defaultlib_:
-         free (CONST_CAST (char *, defaultlib));
+         free (const_cast<char *> (defaultlib));
          if (arg != NULL)
            {
              args[i] |= SKIPOPT;
@@ -171,7 +171,7 @@ lang_specific_driver (cl_decoded_option **in_decoded_options,
          break;
 
        case OPT_debuglib_:
-         free (CONST_CAST (char *, debuglib));
+         free (const_cast<char *> (debuglib));
          if (arg != NULL)
            {
              args[i] |= SKIPOPT;
index 2614277d96a7719b20c283c3c863307cddc10fad..b95fd1a2521355acc898fbec9f32cb2cb9dee89a 100644 (file)
@@ -2055,7 +2055,7 @@ make_thunk (FuncDeclaration *decl, int offset)
       unsigned identlen = IDENTIFIER_LENGTH (target_name) + 14;
       ident = XNEWVEC (const char, identlen);
 
-      snprintf (CONST_CAST (char *, ident), identlen,
+      snprintf (const_cast<char *> (ident), identlen,
                "_DTi%u%s", offset, IDENTIFIER_POINTER (target_name));
     }
 
@@ -2065,7 +2065,7 @@ make_thunk (FuncDeclaration *decl, int offset)
   d_keep (thunk);
 
   if (decl->resolvedLinkage () != LINK::cpp)
-    free (CONST_CAST (char *, ident));
+    free (const_cast<char *> (ident));
 
   /* Thunks are connected to the definitions of the functions, so thunks are
      not produced for external functions.  */
index 2541fab85ca0dd8438c50e9a5cfb7802f29e9b60..a309877773d49d9f45da20a63c413194088d7c3d 100644 (file)
@@ -1733,7 +1733,7 @@ dump_enable_all (dump_kind dkind, dump_flags_t flags, const char *filename)
               dump_files[i].pstate = 1;
             }
           if (old_filename && filename != old_filename)
-            free (CONST_CAST (char *, old_filename));
+           free (const_cast<char *> (old_filename));
         }
     }
 
@@ -1754,7 +1754,7 @@ dump_enable_all (dump_kind dkind, dump_flags_t flags, const char *filename)
               m_extra_dump_files[i].pstate = 1;
             }
           if (old_filename && filename != old_filename)
-            free (CONST_CAST (char *, old_filename));
+           free (const_cast<char *> (old_filename));
         }
     }
 
@@ -1807,7 +1807,7 @@ gcc::dump_manager::update_dfi_for_opt_info (dump_file_info *dfi) const
   if (m_optinfo_filename)
     dfi->alt_filename = xstrdup (m_optinfo_filename);
   if (old_filename && m_optinfo_filename != old_filename)
-    free (CONST_CAST (char *, old_filename));
+    free (const_cast<char *> (old_filename));
 
   return true;
 }
@@ -1904,7 +1904,7 @@ dump_switch_p_1 (const char *arg, struct dump_file_info *dfi, bool doglob)
   if (filename)
     {
       if (dfi->pfilename)
-  free (CONST_CAST (char *, dfi->pfilename));
+       free (const_cast<char *> (dfi->pfilename));
       dfi->pfilename = xstrdup (filename);
     }
 
index 37b24f97fa3a0cb6d9bdf055657aceb066a30d0a..dda5b6262bfbe7920d2812543a2402291faa2686 100644 (file)
@@ -3571,7 +3571,12 @@ vec_push (char **&optr, size_t &osz, const char *elt)
   /* {auto,}vec.safe_push () replacement.  Don't ask..  */
   // if (strlen (elt) < 4) return; premature optimization: eliminated by cutoff
   optr = XRESIZEVEC (char *, optr, osz + 2);
-  optr[osz] = CONST_CAST (char *, elt);
+  optr[osz] =
+#ifdef __cplusplus
+    const_cast<char *> (elt);
+#else
+    (__extension__ (union {const char *_q; const char *_nq;})(elt))._nq;
+#endif
   optr[++osz] = NULL;
 }
 
index eda0bc9e299c9a95cf4bbcfa39a453aa8b1549c6..47b1c9431323045430caf0109ce736d85c7a051d 100644 (file)
@@ -3936,10 +3936,9 @@ mio_expr (gfc_expr **ep)
       break;
 
     case EXPR_SUBSTRING:
-      e->value.character.string
-       = CONST_CAST (gfc_char_t *,
-                     mio_allocated_wide_string (e->value.character.string,
-                                                e->value.character.length));
+      e->value.character.string = const_cast<gfc_char_t *>
+       (mio_allocated_wide_string (e->value.character.string,
+                                   e->value.character.length));
       mio_ref_list (&e->ref);
       break;
 
@@ -3976,10 +3975,9 @@ mio_expr (gfc_expr **ep)
          hwi = e->value.character.length;
          mio_hwi (&hwi);
          e->value.character.length = hwi;
-         e->value.character.string
-           = CONST_CAST (gfc_char_t *,
-                         mio_allocated_wide_string (e->value.character.string,
-                                                    e->value.character.length));
+         e->value.character.string = const_cast<gfc_char_t *>
+           (mio_allocated_wide_string (e->value.character.string,
+                                       e->value.character.length));
          break;
 
        default:
index af3cb54ad561261e3c9e04301324a231efd6f400..11876162d60afac5468d0ddee3cd40d4d1eb71bd 100644 (file)
@@ -223,7 +223,7 @@ gfc_free_omp_clauses (gfc_omp_clauses *c)
   gfc_free_expr_list (c->wait_list);
   gfc_free_expr_list (c->tile_list);
   gfc_free_expr_list (c->sizes_list);
-  free (CONST_CAST (char *, c->critical_name));
+  free (const_cast<char *> (c->critical_name));
   if (c->assume)
     {
       free (c->assume->absent);
index 13b0ffb453807e4aaaa9d3db532a371a244246e8..925a1e38dcf424bc314408b76c0418aa46f5d676 100644 (file)
@@ -370,7 +370,7 @@ gfc_post_options (const char **pfilename)
     gfc_add_include_path (".", true, true, false, false);
 
   if (canon_source_file != gfc_source_file)
-    free (CONST_CAST (char *, canon_source_file));
+    free (const_cast<char *> (canon_source_file));
 
   /* Decide which form the file will be read in as.  */
 
index 413d0666df7a77621409406ea7053f85c3211fa3..e397ea6015cddc2a5158e76bb7acc72d56cd33d6 100644 (file)
@@ -6435,7 +6435,7 @@ parse_omp_structured_block (gfc_statement omp_st, bool workshare_stmts_only)
                         new_st.ext.omp_name) != 0))
        gfc_error ("Name after !$omp critical and !$omp end critical does "
                   "not match at %C");
-      free (CONST_CAST (char *, new_st.ext.omp_name));
+      free (const_cast<char *> (new_st.ext.omp_name));
       new_st.ext.omp_name = NULL;
       break;
     case EXEC_OMP_END_SINGLE:
index 1e18385b5bf5697179fdd590bdd890b8228cb803..6bdbe5593cef4b7efb384dd91fcd504b118c6969 100644 (file)
@@ -173,9 +173,7 @@ wide_strchr (const gfc_char_t *s, gfc_char_t c)
 {
   do {
     if (*s == c)
-      {
-        return CONST_CAST(gfc_char_t *, s);
-      }
+      return const_cast<gfc_char_t *> (s);
   } while (*s++);
   return 0;
 }
index edf52912a851132f74bfba80b7c177e73ac0a413..ce4fcad884f512d688d754534fd3e6237d73bd28 100644 (file)
@@ -295,7 +295,7 @@ gfc_free_statement (gfc_code *p)
       break;
 
     case EXEC_OMP_END_CRITICAL:
-      free (CONST_CAST (char *, p->ext.omp_name));
+      free (const_cast<char *> (p->ext.omp_name));
       break;
 
     case EXEC_OMP_FLUSH:
index cfdd0258241a4b212f3ec3f6c8dd92927ef8e9c7..ec98f967200477481991a4534b42e66c918891ac 100644 (file)
@@ -675,7 +675,7 @@ gfc_adjust_builtins (void)
       for (hash_map<nofree_string_hash, int>::iterator it
           = gfc_vectorized_builtins->begin ();
           it != gfc_vectorized_builtins->end (); ++it)
-       free (CONST_CAST (char *, (*it).first));
+       free (const_cast<char *> ((*it).first));
 
       delete gfc_vectorized_builtins;
       gfc_vectorized_builtins = NULL;
index bc66b795df0eda0bb79d41fb78bd83db28e0bfed..065f69c9d8beabbd9c28a96d5dcec025c6b86ffe 100644 (file)
@@ -146,7 +146,7 @@ env_manager::xput (const char *string)
       m_keys.safe_push (kv);
     }
 
-  ::putenv (CONST_CAST (char *, string));
+  ::putenv (const_cast<char *> (string));
 }
 
 /* Undo any xputenv changes made since last restore.
@@ -2155,7 +2155,7 @@ set_spec (const char *name, const char *spec, bool user_p)
 
   /* Free the old spec.  */
   if (old_spec && sl->alloc_p)
-    free (CONST_CAST (char *, old_spec));
+    free (const_cast<char *> (old_spec));
 
   sl->user_p = user_p;
   sl->alloc_p = true;
@@ -2316,7 +2316,7 @@ close_at_file (void)
 
   /* Copy the strings over.  */
   for (i = 0; i < n_args; i++)
-    argv[i] = CONST_CAST (char *, at_file_argbuf[i]);
+    argv[i] = const_cast<char *> (at_file_argbuf[i]);
   argv[i] = NULL;
 
   at_file_argbuf.truncate (0);
@@ -2568,7 +2568,7 @@ read_specs (const char *filename, bool main_p, bool user_p)
 
              set_spec (p2, *(sl->ptr_spec), user_p);
              if (sl->alloc_p)
-               free (CONST_CAST (char *, *(sl->ptr_spec)));
+               free (const_cast<char *> (*(sl->ptr_spec)));
 
              *(sl->ptr_spec) = "";
              sl->alloc_p = 0;
@@ -2944,18 +2944,18 @@ for_each_path (const struct path_prefix *paths,
         Don't repeat any we have already seen.  */
       if (multi_dir)
        {
-         free (CONST_CAST (char *, multi_dir));
+         free (const_cast<char *> (multi_dir));
          multi_dir = NULL;
-         free (CONST_CAST (char *, multi_suffix));
+         free (const_cast<char *> (multi_suffix));
          multi_suffix = machine_suffix;
-         free (CONST_CAST (char *, just_multi_suffix));
+         free (const_cast<char *> (just_multi_suffix));
          just_multi_suffix = just_machine_suffix;
        }
       else
        skip_multi_dir = true;
       if (multi_os_dir)
        {
-         free (CONST_CAST (char *, multi_os_dir));
+         free (const_cast<char *> (multi_os_dir));
          multi_os_dir = NULL;
        }
       else
@@ -2964,12 +2964,12 @@ for_each_path (const struct path_prefix *paths,
 
   if (multi_dir)
     {
-      free (CONST_CAST (char *, multi_dir));
-      free (CONST_CAST (char *, multi_suffix));
-      free (CONST_CAST (char *, just_multi_suffix));
+      free (const_cast<char *> (multi_dir));
+      free (const_cast<char *> (multi_suffix));
+      free (const_cast<char *> (just_multi_suffix));
     }
   if (multi_os_dir)
-    free (CONST_CAST (char *, multi_os_dir));
+    free (const_cast<char *> (multi_os_dir));
   if (ret != path)
     free (path);
   return ret;
@@ -3454,7 +3454,7 @@ execute (void)
       errmsg = pex_run (pex,
                        ((i + 1 == n_commands ? PEX_LAST : 0)
                         | (string == commands[i].prog ? PEX_SEARCH : 0)),
-                       string, CONST_CAST (char **, commands[i].argv),
+                       string, const_cast<char **> (commands[i].argv),
                        NULL, NULL, &err);
       if (errmsg != NULL)
        {
@@ -3466,7 +3466,7 @@ execute (void)
        }
 
       if (i && string != commands[i].prog)
-       free (CONST_CAST (char *, string));
+       free (const_cast<char *> (string));
     }
 
   execution_count++;
@@ -3610,7 +3610,7 @@ execute (void)
       }
 
    if (commands[0].argv[0] != commands[0].prog)
-     free (CONST_CAST (char *, commands[0].argv[0]));
+     free (const_cast<char *> (commands[0].argv[0]));
 
     return ret_code;
   }
@@ -7703,13 +7703,13 @@ give_switch (int switchnum, int omit_first_word)
              while (length-- && !IS_DIR_SEPARATOR (arg[length]))
                if (arg[length] == '.')
                  {
-                   (CONST_CAST (char *, arg))[length] = 0;
+                   (const_cast<char *> (arg))[length] = 0;
                    dot = 1;
                    break;
                  }
              do_spec_1 (arg, 1, NULL);
              if (dot)
-               (CONST_CAST (char *, arg))[length] = '.';
+               (const_cast<char *> (arg))[length] = '.';
              do_spec_1 (suffix_subst, 1, NULL);
            }
          else
@@ -10148,7 +10148,7 @@ set_multilib_dir (void)
   if (multilib_dir == NULL && multilib_os_dir != NULL
       && strcmp (multilib_os_dir, ".") == 0)
     {
-      free (CONST_CAST (char *, multilib_os_dir));
+      free (const_cast<char *> (multilib_os_dir));
       multilib_os_dir = NULL;
     }
   else if (multilib_dir != NULL && multilib_os_dir == NULL)
index 5bed44841c03c8509dfcf36b152ce9a81b635604..6256caa19e9456c8549830049e7b5d6f7144fefa 100644 (file)
@@ -2091,7 +2091,7 @@ create_file_names (const char *file_name)
     }
 
   /* Remove the extension.  */
-  cptr = strrchr (CONST_CAST (char *, lbasename (name)), '.');
+  cptr = strrchr (const_cast<char *> (lbasename (name)), '.');
   if (cptr)
     *cptr = 0;
 
index 530e4f782783d96760a8d2cd114d1e9ae7db0230..962d94390a7f0cab331056e41bcb3fb3d896781c 100644 (file)
@@ -237,9 +237,9 @@ string_seq (void)
 
       l1 = strlen (s1);
       l2 = strlen (s2);
-      buf = XRESIZEVEC (char, CONST_CAST (char *, s1), l1 + l2 + 1);
+      buf = XRESIZEVEC (char, const_cast<char *> (s1), l1 + l2 + 1);
       memcpy (buf + l1, s2, l2 + 1);
-      XDELETE (CONST_CAST (char *, s2));
+      XDELETE (const_cast<char *> (s2));
       s1 = buf;
     }
   return s1;
index 42bc1d2b00b3605783b5e3e9eec7ec91f77ad963..4f69bae36205b49d22c1e8652320f0fa38702324 100644 (file)
@@ -52,7 +52,7 @@ type_lineloc (const_type_p ty)
     case TYPE_LANG_STRUCT:
     case TYPE_USER_STRUCT:
     case TYPE_UNDEFINED:
-      return CONST_CAST (struct fileloc*, &ty->u.s.line);
+      return const_cast<struct fileloc*> (&ty->u.s.line);
     case TYPE_SCALAR:
     case TYPE_STRING:
     case TYPE_POINTER:
index 159d424f145d86280b4939aa3ce0f4aa9075a8d3..5860f9875ed104cb5231974a726210486a2a280f 100644 (file)
@@ -2060,8 +2060,8 @@ header_dot_h_frul (input_file* inpf, char**poutname,
 static outf_p
 source_dot_cc_frul (input_file* inpf, char**poutname, char**pforname)
 {
-  char *newbasename = CONST_CAST (char*, get_file_basename (inpf));
-  char *newoutname = CONST_CAST (char*, get_file_gtfilename (inpf));
+  char *newbasename = const_cast<char*> (get_file_basename (inpf));
+  char *newoutname = const_cast<char*> (get_file_gtfilename (inpf));
   DBGPRINTF ("inpf %p inpname %s original outname %s forname %s",
             (void*) inpf, get_input_file_name (inpf),
             *poutname, *pforname);
@@ -2529,7 +2529,7 @@ output_mangled_typename (outf_p of, const_type_p t)
          oprintf (of, "%lu%s", (unsigned long) strlen (id_for_tag),
                   id_for_tag);
          if (id_for_tag != t->u.s.tag)
-           free (CONST_CAST (char *, id_for_tag));
+           free (const_cast<char *> (id_for_tag));
        }
        break;
       case TYPE_ARRAY:
@@ -3303,7 +3303,7 @@ get_output_file_for_structure (const_type_p s)
 
   /* The call to get_output_file_with_visibility may update fn by
      caching its result inside, so we need the CONST_CAST.  */
-  return get_output_file_with_visibility (CONST_CAST (input_file*, fn));
+  return get_output_file_with_visibility (const_cast<input_file*> (fn));
 }
 
 
@@ -3368,7 +3368,7 @@ write_marker_function_name (outf_p of, type_p s, const char *prefix)
       const char *id_for_tag = filter_type_name (s->u.s.tag);
       oprintf (of, "gt_%sx_%s", prefix, id_for_tag);
       if (id_for_tag != s->u.s.tag)
-       free (CONST_CAST (char *, id_for_tag));
+       free (const_cast<char *> (id_for_tag));
     }
   else
     gcc_unreachable ();
@@ -3710,7 +3710,7 @@ write_types (outf_p output_header, type_p structures,
                           "#define gt_%sx_%s gt_%sx_%s\n",
                           wtd->prefix, s->u.s.tag, wtd->prefix, t_id_for_tag);
                  if (t_id_for_tag != t->u.s.tag)
-                   free (CONST_CAST (char *, t_id_for_tag));
+                   free (const_cast<char *> (t_id_for_tag));
                }
              else
                error_at_line (&s->u.s.line,
@@ -3726,7 +3726,7 @@ write_types (outf_p output_header, type_p structures,
                 wtd->prefix, s_id_for_tag);
 
        if (s_id_for_tag != s->u.s.tag)
-         free (CONST_CAST (char *, s_id_for_tag));
+         free (const_cast<char *> (s_id_for_tag));
 
        if (s->u.s.line.file == NULL)
          {
@@ -4113,7 +4113,7 @@ put_mangled_filename (outf_p f, const input_file *inpf)
   /* The call to get_output_file_name may indirectly update fn since
      get_output_file_with_visibility caches its result inside, so we
      need the CONST_CAST.  */
-  const char *name = get_output_file_name (CONST_CAST (input_file*, inpf));
+  const char *name = get_output_file_name (const_cast<input_file*> (inpf));
   if (!f || !name)
     return;
   for (; *name != 0; name++)
@@ -4427,7 +4427,7 @@ write_root (outf_p f, pair_p v, type_p type, const char *name, int has_length,
            else
              oprintf (f, "    NULL");
            if (id_for_tag != tp->u.s.tag)
-             free (CONST_CAST (char *, id_for_tag));
+             free (const_cast<char *> (id_for_tag));
          }
        else if (has_length
                 && (tp->kind == TYPE_POINTER || union_or_struct_p (tp)))
@@ -4531,7 +4531,7 @@ write_roots (pair_p variables, bool emit_pch)
   for (v = variables; v; v = v->next)
     {
       outf_p f =
-       get_output_file_with_visibility (CONST_CAST (input_file*,
+       get_output_file_with_visibility (const_cast<input_file*> (
                                                     v->line.file));
       struct flist *fli;
       const char *length = NULL;
@@ -4584,7 +4584,7 @@ write_roots (pair_p variables, bool emit_pch)
 
   for (v = variables; v; v = v->next)
     {
-      outf_p f = get_output_file_with_visibility (CONST_CAST (input_file*,
+      outf_p f = get_output_file_with_visibility (const_cast<input_file*> (
                                                              v->line.file));
       struct flist *fli;
       int skip_p = 0;
@@ -4620,7 +4620,7 @@ write_roots (pair_p variables, bool emit_pch)
 
   for (v = variables; v; v = v->next)
     {
-      outf_p f = get_output_file_with_visibility (CONST_CAST (input_file*,
+      outf_p f = get_output_file_with_visibility (const_cast<input_file*> (
                                                              v->line.file));
       struct flist *fli;
       int skip_p = 1;
@@ -4654,7 +4654,7 @@ write_roots (pair_p variables, bool emit_pch)
 
   for (v = variables; v; v = v->next)
     {
-      outf_p f = get_output_file_with_visibility (CONST_CAST (input_file*,
+      outf_p f = get_output_file_with_visibility (const_cast<input_file*> (
                                                              v->line.file));
       struct flist *fli;
       options_p o;
@@ -4689,7 +4689,7 @@ write_roots (pair_p variables, bool emit_pch)
 
   for (v = variables; v; v = v->next)
     {
-      outf_p f = get_output_file_with_visibility (CONST_CAST (input_file*,
+      outf_p f = get_output_file_with_visibility (const_cast<input_file*> (
                                                              v->line.file));
       struct flist *fli;
       int skip_p = 0;
index a004fd7edbf7aadcce40a74013902ec3f9820ef6..cab03964885945926829ebdfc1e4ba1bbb73da18 100644 (file)
@@ -1302,7 +1302,7 @@ note_constraint (md_rtx_info *info)
   new_cdata = XNEWVAR (class constraint_data,
                       sizeof (class constraint_data) + namelen);
   new (new_cdata) constraint_data ();
-  strcpy (CONST_CAST (char *, new_cdata->name), name);
+  strcpy (const_cast<char *> (new_cdata->name), name);
   new_cdata->namelen = namelen;
   new_cdata->loc = info->loc;
   new_cdata->next_this_letter = *slot;
index 99023990cbffa676d171328693e15d92713934fa..e3cccc9d07996bf7056f0eeaab7d48f63bf41b6b 100644 (file)
@@ -1589,7 +1589,7 @@ gt_ggc_m_S (const void *p)
         a STRING_CST.  */
       gcc_assert (offset == offsetof (struct tree_string, str));
       p = ((const char *) p) - offset;
-      gt_ggc_mx_lang_tree_node (CONST_CAST (void *, p));
+      gt_ggc_mx_lang_tree_node (const_cast<void *> (p));
       return;
     }
 
index c6bb1763e7f4e11168692d514c432c4cad619e6d..9fe693d9a3956e4aca5edfd0e9284e31384088ea 100644 (file)
@@ -465,7 +465,7 @@ go_undef (unsigned int lineno, const char *buffer)
 
   real_debug_hooks->undef (lineno, buffer);
 
-  mhval.name = CONST_CAST (char *, buffer);
+  mhval.name = const_cast<char *> (buffer);
   mhval.value = NULL;
   slot = htab_find_slot (macro_hash, &mhval, NO_INSERT);
   if (slot != NULL)
@@ -1186,14 +1186,14 @@ go_output_typedef (class godump_container *container, tree decl)
       slot = htab_find_slot (container->type_hash, type, INSERT);
       if (*slot != NULL)
        return;
-      *slot = CONST_CAST (void *, (const void *) type);
+      *slot = const_cast<void *> ((const void *) type);
 
       if (!go_format_type (container, original_type, true, false,
                           NULL, false))
        {
          fprintf (go_dump_file, "// ");
          slot = htab_find_slot (container->invalid_hash, type, INSERT);
-         *slot = CONST_CAST (void *, (const void *) type);
+         *slot = const_cast<void *> ((const void *) type);
        }
       fprintf (go_dump_file, "type _%s ",
               IDENTIFIER_POINTER (DECL_NAME (decl)));
@@ -1225,14 +1225,14 @@ go_output_typedef (class godump_container *container, tree decl)
        slot = htab_find_slot (container->type_hash, type, INSERT);
        if (*slot != NULL)
          return;
-       *slot = CONST_CAST (void *, (const void *) type);
+       *slot = const_cast<void *> ((const void *) type);
 
        if (!go_format_type (container, TREE_TYPE (decl), false, false, NULL,
                            false))
         {
           fprintf (go_dump_file, "// ");
           slot = htab_find_slot (container->invalid_hash, type, INSERT);
-          *slot = CONST_CAST (void *, (const void *) type);
+          *slot = const_cast<void *> ((const void *) type);
         }
        fprintf (go_dump_file, "type _%s ",
               IDENTIFIER_POINTER (TYPE_NAME (TREE_TYPE (decl))));
@@ -1352,7 +1352,7 @@ keyword_hash_init (class godump_container *container)
   for (i = 0; i < count; i++)
     {
       slot = htab_find_slot (container->keyword_hash, keywords[i], INSERT);
-      *slot = CONST_CAST (void *, (const void *) keywords[i]);
+      *slot = const_cast<void *> ((const void *) keywords[i]);
     }
 }
 
index f23354dbc79ce9671a84d875e574a0a53b5c279b..c57f84f02bd46b66986dc94afe9e63107dadc3aa 100644 (file)
@@ -225,7 +225,7 @@ lto_free_section_data (struct lto_file_decl_data *file_data,
   /* The underlying data address has been extracted from the mapping header.
      Free that, then free the allocated uncompression buffer.  */
   (free_section_f) (file_data, section_type, name, header->data, header->len);
-  free (CONST_CAST (char *, real_data));
+  free (const_cast<char *> (real_data));
 }
 
 /* Free data allocated by lto_get_raw_section_data.  */
@@ -321,8 +321,8 @@ renaming_slot_free (void *slot)
 {
   struct lto_renaming_slot *s = (struct lto_renaming_slot *) slot;
 
-  free (CONST_CAST (void *, (const void *) s->old_name));
-  free (CONST_CAST (void *, (const void *) s->new_name));
+  free (const_cast<void *> ((const void *) s->old_name));
+  free (const_cast<void *> ((const void *) s->new_name));
   free ((void *) s);
 }
 
index a15f0e259e5f7ca269f066764e030a2d186484be..c300655b1d8d32612e90752311f887b98f4ef1d3 100644 (file)
@@ -1401,7 +1401,7 @@ make_exists (void)
   int exit_status = 0;
   int err = 0;
   const char *errmsg
-    = pex_one (PEX_SEARCH, make_args[0], CONST_CAST (char **, make_args),
+    = pex_one (PEX_SEARCH, make_args[0], const_cast<char **> (make_args),
               "make", NULL, NULL, &exit_status, &err);
   freeargv (make_argv);
   return errmsg == NULL && exit_status == 0 && err == 0;
@@ -1929,7 +1929,7 @@ cont1:
 
   new_argv = XOBFINISH (&argv_obstack, const char **);
   argv_ptr = &new_argv[new_head_argc];
-  fork_execute (new_argv[0], CONST_CAST (char **, new_argv), true,
+  fork_execute (new_argv[0], const_cast<char **> (new_argv), true,
                "ltrans_args");
 
   /* Copy the early generated debug info from the objects to temporary
@@ -2154,7 +2154,7 @@ cont:
                snprintf (argsuffix,
                          sizeof (DUMPBASE_SUFFIX) + sizeof (".ltrans_args"),
                          "ltrans%u.ltrans_args", i);
-             fork_execute (new_argv[0], CONST_CAST (char **, new_argv),
+             fork_execute (new_argv[0], const_cast<char **> (new_argv),
                            true, save_temps ? argsuffix : NULL);
              if (!ltrans_cache)
                maybe_unlink (input_names[i]);
@@ -2206,7 +2206,7 @@ cont:
          obstack_ptr_grow (&argv_obstack, NULL);
          new_argv = XOBFINISH (&argv_obstack, const char **);
 
-         pex = collect_execute (new_argv[0], CONST_CAST (char **, new_argv),
+         pex = collect_execute (new_argv[0], const_cast<char **> (new_argv),
                                 NULL, NULL, PEX_SEARCH, false, NULL);
          do_wait (new_argv[0], pex);
          freeargv (make_argv);
index 17bbc8d84120cf1327b1341196e965f0643a5605..cc513b84ef1a98f83ab559f708f535b4f390c66d 100644 (file)
@@ -96,7 +96,7 @@ free_with_string (void *arg)
 {
   struct lto_section_slot *s = (struct lto_section_slot *)arg;
 
-  free (CONST_CAST (char *, s->name));
+  free (const_cast<char *> (s->name));
   free (arg);
 }
 
@@ -2504,7 +2504,7 @@ get_section_data (struct lto_file_decl_data *file_data,
       *len = f_slot->len;
     }
 
-  free (CONST_CAST (char *, section_name));
+  free (const_cast<char *> (section_name));
   return data;
 }
 
@@ -2531,7 +2531,7 @@ free_section_data (struct lto_file_decl_data *file_data ATTRIBUTE_UNUSED,
 
   munmap ((caddr_t) computed_offset, computed_len);
 #else
-  free (CONST_CAST(char *, offset));
+  free (const_cast<char *> (offset));
 #endif
 }
 
index 0a3032c7c00ebf36115c1e97a5a762cbbf279f73..9589c6ca5ab3b956546e31d19673f0a17e29785b 100644 (file)
@@ -180,7 +180,7 @@ stream_out (char *temp_filename, lto_symtab_encoder_t encoder, int part)
   streamer_dump_file = dump_begin (TDI_lto_stream_out, NULL, part);
   ipa_write_optimization_summaries (encoder, part == 0);
 
-  free (CONST_CAST (char *, file->filename));
+  free (const_cast<char *> (file->filename));
 
   lto_set_current_out_file (NULL);
   lto_obj_file_close (file);
index 100387493339b27fa0b04943768671a2377a1761..8522644eabc1bfa47a98c2d346dc0aca257596f0 100644 (file)
@@ -916,7 +916,7 @@ oacc_parse_default_dims (const char *dims)
              const char *eptr;
 
              errno = 0;
-             val = strtol (pos, CONST_CAST (char **, &eptr), 10);
+             val = strtol (pos, const_cast<char **> (&eptr), 10);
              if (errno || val <= 0 || (int) val != val)
                goto malformed;
              pos = eptr;
index a7e8d4a8f18da23fa2a946383c805233b2d93453..9ec37eeb2a98b348ffe3be9bc639885772dcd8f4 100644 (file)
@@ -887,7 +887,7 @@ pass_manager::register_one_dump_file (opt_pass *pass)
   set_pass_for_id (id, pass);
   full_name = concat (prefix, pass->name, num, NULL);
   register_pass_name (pass, full_name);
-  free (CONST_CAST (char *, full_name));
+  free (const_cast<char *> (full_name));
 }
 
 /* Register the dump files for the pass_manager starting at PASS. */
@@ -2207,7 +2207,7 @@ release_dump_file_name (void)
 {
   if (dump_file_name)
     {
-      free (CONST_CAST (char *, dump_file_name));
+      free (const_cast<char *> (dump_file_name));
       dump_file_name = NULL;
     }
 }
index 7e8837c53017e47f64930a9bb6cb14c510b4321c..436be5e01475cbbca1c3b2b7fe36edfe43dd4058 100644 (file)
@@ -186,7 +186,7 @@ add_new_plugin (const char* plugin_name)
 
   if (name_is_short)
     {
-      base_name = CONST_CAST (char*, plugin_name);
+      base_name = const_cast<char*> (plugin_name);
 
 #if defined(__MINGW32__)
       static const char plugin_ext[] = ".dll";
index 7ee59f74fc0927ca53643dd37ca9d15f94cf1b36..82ef3f2616486f6ff3f2dbd54f7ff306f6409a1e 100644 (file)
@@ -265,7 +265,7 @@ update_path (const char *path, const char *key)
 
       result = concat (key, &path[len], NULL);
       if (free_key)
-       free (CONST_CAST (char *, key));
+       free (const_cast<char *> (key));
       result = translate_name (result);
     }
   else
index 799fc06bd0193f946ce644f113bb2b9b02ebc7b1..3cdbe46bd4145879554fe4041fb9ee6a672900b7 100644 (file)
@@ -3055,7 +3055,7 @@ identifier_to_locale (const char *ident)
              /* Repeat the whole conversion process as needed with
                 larger buffers so non-reversible transformations can
                 always be detected.  */
-             ICONV_CONST char *inbuf = CONST_CAST (char *, ident);
+             ICONV_CONST char *inbuf = const_cast<char *> (ident);
              char *outbuf;
              size_t inbytesleft = idlen;
              size_t outbytesleft = ret_alloc - 1;
index f77511745097f4b8863ec852cfa29a189977ac26..7f78effb0c1e14056afc877963290b2486f861d6 100644 (file)
@@ -80,7 +80,7 @@ print_diff (const location &loc, const char *val1, const char *val2)
   int exit_status = 0;
   int err = 0;
   pex_one (PEX_SEARCH | PEX_LAST,
-          args[0], CONST_CAST (char **, args),
+          args[0], const_cast<char **> (args),
           NULL, NULL, NULL, &exit_status, &err);
 }
 
index e7c2c8d0a3b6c7d87f3add638e937cfade0ab605..9b3a36e0a983e6444ee8b94c288cbd3a375c6379 100644 (file)
@@ -74,7 +74,7 @@ stats_counter_hasher::equal (const statistics_counter *c1,
 inline void
 stats_counter_hasher::remove (statistics_counter *v)
 {
-  free (CONST_CAST (char *, v->id));
+  free (const_cast<char *> (v->id));
   free (v);
 }
 
index 2d1eb4e2879ff270c0060fe14abee59f90f634a5..630b3e7c8cf2ee05008f41643a5c46097ea7e25c 100644 (file)
@@ -216,14 +216,14 @@ gt_pch_p_S (void *obj ATTRIBUTE_UNUSED, void *x ATTRIBUTE_UNUSED,
 void
 gt_pch_n_S (const void *x)
 {
-  gt_pch_note_object (CONST_CAST (void *, x), CONST_CAST (void *, x),
+  gt_pch_note_object (const_cast<void *> (x), const_cast<void *> (x),
                      &gt_pch_p_S);
 }
 
 void
 gt_pch_n_S2 (const void *x, size_t string_len)
 {
-  gt_pch_note_object (CONST_CAST (void *, x), CONST_CAST (void *, x),
+  gt_pch_note_object (const_cast<void *> (x), const_cast<void *> (x),
                      &gt_pch_p_S, string_len);
 }
 
index faa6857690ad57d70893ae38110d5cc692fd2169..01fa005509a96e79f4350f684b41a55a27014464 100644 (file)
@@ -1152,49 +1152,6 @@ extern void fancy_abort (const char *, int, const char *)
 
 #endif /* GCC >= 3.0 */
 
-/* This macro allows casting away const-ness to pass -Wcast-qual
-   warnings.  DO NOT USE THIS UNLESS YOU REALLY HAVE TO!  It should
-   only be used in certain specific cases.  One valid case is where
-   the C standard definitions or prototypes force you to.  E.g. if you
-   need to free a const object, or if you pass a const string to
-   execv, et al.  Another valid use would be in an allocation function
-   that creates const objects that need to be initialized.  In some
-   cases we have non-const functions that return the argument
-   (e.g. next_nonnote_insn).  Rather than create const shadow
-   functions, we can cast away const-ness in calling these interfaces
-   if we're careful to verify that the called function does indeed not
-   modify its argument and the return value is only used in a const
-   context.  (This can be somewhat dangerous as these assumptions can
-   change after the fact).  Beyond these uses, most other cases of
-   using this macro should be viewed with extreme caution.  */
-
-#ifdef __cplusplus
-#define CONST_CAST2(TOTYPE,FROMTYPE,X) (const_cast<TOTYPE> (X))
-#else
-#if defined(__GNUC__) && GCC_VERSION > 4000
-/* GCC 4.0.x has a bug where it may ICE on this expression,
-   so does GCC 3.4.x (PR17436).  */
-#define CONST_CAST2(TOTYPE,FROMTYPE,X) ((__extension__(union {FROMTYPE _q; TOTYPE _nq;})(X))._nq)
-#elif defined(__GNUC__)
-inline char *
-helper_const_non_const_cast (const char *p)
-{
-  union {
-    const char *const_c;
-    char *c;
-  } val;
-  val.const_c = p;
-  return val.c;
-}
-
-#define CONST_CAST2(TOTYPE,FROMTYPE,X) \
-       ((TOTYPE) helper_const_non_const_cast ((const char *) (FROMTYPE) (X)))
-#else
-#define CONST_CAST2(TOTYPE,FROMTYPE,X) ((TOTYPE)(FROMTYPE)(X))
-#endif
-#endif
-#define CONST_CAST(TYPE,X) CONST_CAST2 (TYPE, const TYPE, (X))
-
 /* Activate certain diagnostics as warnings (not errors via the
    -Werror flag).  */
 #if GCC_VERSION >= 4003
index 885716535f1c0654335506f3cfbaf5f469a47f33..f2f160ae742da80d766e88615e22c7b51055417c 100644 (file)
@@ -1242,7 +1242,7 @@ gimple_init_gcov_profiler (void)
       fn_name = concat ("__gcov_interval_profiler", fn_suffix, NULL);
       tree_interval_profiler_fn = build_fn_decl (fn_name,
                                                 interval_profiler_fn_type);
-      free (CONST_CAST (char *, fn_name));
+      free (const_cast<char *> (fn_name));
       TREE_NOTHROW (tree_interval_profiler_fn) = 1;
       DECL_ATTRIBUTES (tree_interval_profiler_fn)
        = tree_cons (get_identifier ("leaf"), NULL,
@@ -1255,7 +1255,7 @@ gimple_init_gcov_profiler (void)
                                          NULL_TREE);
       fn_name = concat ("__gcov_pow2_profiler", fn_suffix, NULL);
       tree_pow2_profiler_fn = build_fn_decl (fn_name, pow2_profiler_fn_type);
-      free (CONST_CAST (char *, fn_name));
+      free (const_cast<char *> (fn_name));
       TREE_NOTHROW (tree_pow2_profiler_fn) = 1;
       DECL_ATTRIBUTES (tree_pow2_profiler_fn)
        = tree_cons (get_identifier ("leaf"), NULL,
@@ -1269,7 +1269,7 @@ gimple_init_gcov_profiler (void)
       fn_name = concat ("__gcov_topn_values_profiler", fn_suffix, NULL);
       tree_topn_values_profiler_fn
        = build_fn_decl (fn_name, topn_values_profiler_fn_type);
-      free (CONST_CAST (char *, fn_name));
+      free (const_cast<char *> (fn_name));
 
       TREE_NOTHROW (tree_topn_values_profiler_fn) = 1;
       DECL_ATTRIBUTES (tree_topn_values_profiler_fn)
@@ -1287,7 +1287,7 @@ gimple_init_gcov_profiler (void)
       fn_name = concat ("__gcov_indirect_call_profiler_v4", fn_suffix, NULL);
       tree_indirect_call_profiler_fn
        = build_fn_decl (fn_name, ic_profiler_fn_type);
-      free (CONST_CAST (char *, fn_name));
+      free (const_cast<char *> (fn_name));
 
       TREE_NOTHROW (tree_indirect_call_profiler_fn) = 1;
       DECL_ATTRIBUTES (tree_indirect_call_profiler_fn)
@@ -1311,14 +1311,14 @@ gimple_init_gcov_profiler (void)
       fn_name = concat ("__gcov_average_profiler", fn_suffix, NULL);
       tree_average_profiler_fn = build_fn_decl (fn_name,
                                                average_profiler_fn_type);
-      free (CONST_CAST (char *, fn_name));
+      free (const_cast<char *> (fn_name));
       TREE_NOTHROW (tree_average_profiler_fn) = 1;
       DECL_ATTRIBUTES (tree_average_profiler_fn)
        = tree_cons (get_identifier ("leaf"), NULL,
                     DECL_ATTRIBUTES (tree_average_profiler_fn));
       fn_name = concat ("__gcov_ior_profiler", fn_suffix, NULL);
       tree_ior_profiler_fn = build_fn_decl (fn_name, average_profiler_fn_type);
-      free (CONST_CAST (char *, fn_name));
+      free (const_cast<char *> (fn_name));
       TREE_NOTHROW (tree_ior_profiler_fn) = 1;
       DECL_ATTRIBUTES (tree_ior_profiler_fn)
        = tree_cons (get_identifier ("leaf"), NULL,
index d650c85d5c5e986875277bc54cd0de3fe3232c39..49a443f74ed0d45299d924c90ae55d4d055f65e1 100644 (file)
@@ -4279,7 +4279,7 @@ tree_vec_elt_check (const_tree __t, int __i,
     tree_check_failed (__t, __f, __l, __g, TREE_VEC, 0);
   if (__i < 0 || __i >= __t->base.u.length)
     tree_vec_elt_check_failed (__i, __t->base.u.length, __f, __l, __g);
-  return CONST_CAST (const_tree *, &__t->vec.a[__i]);
+  return const_cast<const_tree *> (&__t->vec.a[__i]);
   //return &__t->vec.a[__i];
 }
 
@@ -4295,7 +4295,7 @@ omp_clause_elt_check (const_tree __t, int __i,
     tree_check_failed (__t, __f, __l, __g, OMP_CLAUSE, 0);
   if (__i < 0 || __i >= omp_clause_num_ops [__t->omp_clause.code])
     omp_clause_operand_check_failed (__i, __t, __f, __l, __g);
-  return CONST_CAST (const_tree *, &__t->omp_clause.ops[__i]);
+  return const_cast<const_tree *> (&__t->omp_clause.ops[__i]);
 }
 
 inline const_tree
@@ -4353,7 +4353,7 @@ tree_operand_check (const_tree __t, int __i,
   const_tree __u = EXPR_CHECK (__t);
   if (__i < 0 || __i >= TREE_OPERAND_LENGTH (__u))
     tree_operand_check_failed (__i, __u, __f, __l, __g);
-  return CONST_CAST (const_tree *, &__u->exp.operands[__i]);
+  return const_cast<const_tree *> (&__u->exp.operands[__i]);
 }
 
 inline const_tree *
@@ -4364,7 +4364,7 @@ tree_operand_check_code (const_tree __t, enum tree_code __code, int __i,
     tree_check_failed (__t, __f, __l, __g, __code, 0);
   if (__i < 0 || __i >= TREE_OPERAND_LENGTH (__t))
     tree_operand_check_failed (__i, __t, __f, __l, __g);
-  return CONST_CAST (const_tree *, &__t->exp.operands[__i]);
+  return const_cast<const_tree *> (&__t->exp.operands[__i]);
 }
 
 #endif
index a33c92e41c608944fe3ae61b80efbf3790b8c868..9a93c0306220a7888aa92cfea2cd5bfa6e01013f 100644 (file)
@@ -136,9 +136,6 @@ extern int errno;
    unreachable default case of a switch.  Do not use gcc_assert(0).  */
 #define gcc_unreachable() (abort ())
 
-#define CONST_CAST2(TOTYPE,FROMTYPE,X) ((__extension__(union {FROMTYPE _q; TOTYPE _nq;})(X))._nq)
-#define CONST_CAST(TYPE,X) CONST_CAST2 (TYPE, const TYPE, (X))
-
 /* Filename handling macros.  */
 #include "filenames.h"
 
index 7265c18c60f4dce6818a4322870edde3fdc000c3..0d4cffd0c3a61b10843951fdeb09209485d0a6b2 100644 (file)
--- a/gcc/vec.h
+++ b/gcc/vec.h
@@ -985,7 +985,7 @@ vec<T, A, vl_embed>::iterate (unsigned ix, T **ptr) const
 {
   if (ix < m_vecpfx.m_num)
     {
-      *ptr = CONST_CAST (T *, &address ()[ix]);
+      *ptr = const_cast<T *> (&address ()[ix]);
       return true;
     }
   else