]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
middle-end: replace CONST_CAST_TREE with const_cast<tree> [PR123892]
authorTorbjörn SVENSSON <torbjorn.svensson@foss.st.com>
Wed, 4 Feb 2026 09:31:04 +0000 (10:31 +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_TREE with const_cast<tree>.
* config/aarch64/aarch64.cc: Likewise.
* config/arm/arm.cc: Likewise.
* config/darwin.cc: Likewise.
* fold-const.cc: Likewise.
* gimple-expr.cc: Likewise.
* print-rtl.cc: Likewise.
* tree-object-size.cc: Likewise.
* tree.cc: Likewise.
* varasm.cc: Likewise.
* tree.h: Likewise.

gcc/c-family/ChangeLog:

PR middle-end/123892
* c-gimplify.cc: Replace CONST_CAST_TREE with const_cast<tree>.

gcc/cp/ChangeLog:

PR middle-end/123892
* call.cc: Replace CONST_CAST_TREE with const_cast<tree>.
* constraint.cc: Likewise.
* cp-lang.cc: Likewise.
* cp-tree.h: Likewise.
* cp-objcp-common.cc: Likewise.
* decl.cc: Likewise.
* init.cc: Likewise.
* pt.cc: Likewise.
* reflect.cc: Likewise.
* tree.cc: Likewise.
* typeck.cc: Likewise.
* typeck2.cc: Likewise.

gcc/lto/ChangeLog:

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

gcc/rust/ChangeLog:

PR middle-end/123892
* backend/rust-tree.cc: Replace CONST_CAST_TREE with const_cast<tree>.

Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
26 files changed:
gcc/attribs.cc
gcc/c-family/c-gimplify.cc
gcc/config/aarch64/aarch64.cc
gcc/config/arm/arm.cc
gcc/config/darwin.cc
gcc/cp/call.cc
gcc/cp/constraint.cc
gcc/cp/cp-lang.cc
gcc/cp/cp-objcp-common.cc
gcc/cp/cp-tree.h
gcc/cp/decl.cc
gcc/cp/init.cc
gcc/cp/pt.cc
gcc/cp/reflect.cc
gcc/cp/tree.cc
gcc/cp/typeck.cc
gcc/cp/typeck2.cc
gcc/fold-const.cc
gcc/gimple-expr.cc
gcc/lto/lto-common.cc
gcc/print-rtl.cc
gcc/rust/backend/rust-tree.cc
gcc/tree-object-size.cc
gcc/tree.cc
gcc/tree.h
gcc/varasm.cc

index 29cf28af1639fdce53cca547139053d279e5b372..ab79ca379ac4524d371f0c9c67e501d87c56d8f5 100644 (file)
@@ -1509,7 +1509,7 @@ comp_type_attributes (const_tree type1, const_tree type2)
       if (!as || as->affects_type_identity == false)
        continue;
 
-      attr = find_same_attribute (a, CONST_CAST_TREE (a2));
+      attr = find_same_attribute (a, const_cast<tree> (a2));
       if (!attr || !attribute_value_equal (a, attr))
        break;
     }
@@ -1523,7 +1523,7 @@ comp_type_attributes (const_tree type1, const_tree type2)
          if (!as || as->affects_type_identity == false)
            continue;
 
-         if (!find_same_attribute (a, CONST_CAST_TREE (a1)))
+         if (!find_same_attribute (a, const_cast<tree> (a1)))
            break;
          /* We don't need to compare trees again, as we did this
             already in first loop.  */
@@ -1533,13 +1533,13 @@ comp_type_attributes (const_tree type1, const_tree type2)
       if (!a)
        return 1;
     }
-  if (lookup_attribute ("transaction_safe", CONST_CAST_TREE (a)))
+  if (lookup_attribute ("transaction_safe", const_cast<tree> (a)))
     return 0;
   if ((lookup_attribute ("nocf_check", TYPE_ATTRIBUTES (type1)) != NULL)
       ^ (lookup_attribute ("nocf_check", TYPE_ATTRIBUTES (type2)) != NULL))
     return 0;
-  int strub_ret = strub_comptypes (CONST_CAST_TREE (type1),
-                                  CONST_CAST_TREE (type2));
+  int strub_ret = strub_comptypes (const_cast<tree> (type1),
+                                  const_cast<tree> (type2));
   if (strub_ret == 0)
     return strub_ret;
   /* As some type combinations - like default calling-convention - might
@@ -2113,7 +2113,7 @@ attribute_list_contained (const_tree l1, const_tree l2)
         modify its argument and the return value is assigned to a
         const_tree.  */
       for (attr = lookup_ident_attribute (get_attribute_name (t2),
-                                         CONST_CAST_TREE (l1));
+                                         const_cast<tree> (l1));
           attr != NULL_TREE && !attribute_value_equal (t2, attr);
           attr = lookup_ident_attribute (get_attribute_name (t2),
                                          TREE_CHAIN (attr)))
index 182e80f55295b32ea83d03ef0d462b312274c48b..716c39936c48e4987a493eadd835c577e8b71ff7 100644 (file)
@@ -267,7 +267,7 @@ get_bc_label (enum bc_t bc)
 location_t
 expr_loc_or_loc (const_tree expr, location_t or_loc)
 {
-  tree t = CONST_CAST_TREE (expr);
+  tree t = const_cast<tree> (expr);
   location_t loc = UNKNOWN_LOCATION;
   if (t)
     loc = EXPR_LOCATION (t);
index 90e2e7e04c9ee5669edc350d8931e2e21b622edb..57aa83de3fbfea8f0f70f509d903c36c084114b3 100644 (file)
@@ -23728,7 +23728,7 @@ aarch64_mangle_type (const_tree type)
      The Windows Arm64 ABI uses just an address of the first variadic
      argument.  */
   if (!TARGET_AARCH64_MS_ABI
-      && lang_hooks.types_compatible_p (CONST_CAST_TREE (type), va_list_type))
+      && lang_hooks.types_compatible_p (const_cast<tree> (type), va_list_type))
     return "St9__va_list";
 
   /* Half-precision floating point types.  */
index ff3400ae0353520f9ec0f7c6e11de02cc1d963f1..a8ab7a4fb821e24be43593fdf72df9ee6cfe54a5 100644 (file)
@@ -6348,9 +6348,9 @@ arm_get_pcs_model (const_tree type, const_tree decl ATTRIBUTE_UNUSED)
          /* Local functions never leak outside this compilation unit,
             so we are free to use whatever conventions are
             appropriate.  */
-         /* FIXME: remove CONST_CAST_TREE when cgraph is constified.  */
+         /* FIXME: remove const_cast<tree> when cgraph is constified.  */
          cgraph_node *local_info_node
-           = cgraph_node::local_info_node (CONST_CAST_TREE (decl));
+           = cgraph_node::local_info_node (const_cast<tree> (decl));
          if (local_info_node && local_info_node->local)
            return ARM_PCS_AAPCS_LOCAL;
        }
@@ -30577,7 +30577,7 @@ arm_mangle_type (const_tree type)
   /* The ARM ABI documents (10th October 2008) say that "__va_list"
      has to be managled as if it is in the "std" namespace.  */
   if (TARGET_AAPCS_BASED
-      && lang_hooks.types_compatible_p (CONST_CAST_TREE (type), va_list_type))
+      && lang_hooks.types_compatible_p (const_cast<tree> (type), va_list_type))
     return "St9__va_list";
 
   /* Half-precision floating point types.  */
index b748c359ff7ba68d3481226d84bf00348c502e67..6008ee7304e7bbbd4e70a24e7849aee40193862e 100644 (file)
@@ -1317,7 +1317,7 @@ darwin_encode_section_info (tree decl, rtx rtl, int first)
       if (is_str)
        {
          bool for_asan = (flag_sanitize & SANITIZE_ADDRESS)
-                          && asan_protect_global (CONST_CAST_TREE (decl));
+                          && asan_protect_global (const_cast<tree> (decl));
          /* When we are generating code for sanitized strings, the string
             internal symbols are made visible in the object.  */
          buf = xasprintf ("*%c.str.%s", for_asan ? 'l' : 'L', &name[3]);
@@ -1722,7 +1722,7 @@ machopic_select_section (tree decl,
   if (flag_sanitize & SANITIZE_ADDRESS)
     {
       if (TREE_CODE (decl) == STRING_CST
-         && asan_protect_global (CONST_CAST_TREE (decl)))
+         && asan_protect_global (const_cast<tree> (decl)))
        {
          return darwin_sections[asan_string_section];
        }
@@ -1745,7 +1745,7 @@ machopic_select_section (tree decl,
 
     case SECCAT_RODATA_MERGE_STR_INIT:
       if ((flag_sanitize & SANITIZE_ADDRESS)
-          && asan_protect_global (CONST_CAST_TREE (decl)))
+          && asan_protect_global (const_cast<tree> (decl)))
        /* or !flag_merge_constants */
        return darwin_sections[asan_string_section];
       else
index 62d25ce6ebed623d71cc281226c74caf3b5a3454..979343e8329a3e635e6254d960e90e3172988e67 100644 (file)
@@ -2671,7 +2671,7 @@ add_function_candidate (struct z_candidate **candidates,
       if (i == 0 && first_arg != NULL_TREE)
        arg = first_arg;
       else
-       arg = CONST_CAST_TREE (
+       arg = const_cast<tree> (
                (*args)[i + skip - (first_arg != NULL_TREE ? 1 : 0)]);
       argtype = lvalue_type (arg);
 
index 0b91e8785631384221aecf8235ee9c1c02cf5411..c0f75a01b076b709a368109c96c118b66b475459 100644 (file)
@@ -1033,7 +1033,7 @@ get_constraints (const_tree t)
   gcc_assert (DECL_P (t));
   if (TREE_CODE (t) == TEMPLATE_DECL)
     t = DECL_TEMPLATE_RESULT (t);
-  tree* found = decl_constraints->get (CONST_CAST_TREE (t));
+  tree* found = decl_constraints->get (const_cast<tree> (t));
   if (found)
     return *found;
   else
index d63032f093a5d28962eb0f068a20ed849e8f04fe..c9d02cc73024ae2a8280117b64594aed4fc6947a 100644 (file)
@@ -186,7 +186,7 @@ template_arg_needs_folding (const_tree t)
 static tree
 fold_cplus_constants (const_tree c)
 {
-  tree folded_elems, elems = CONST_CAST_TREE (c);
+  tree folded_elems, elems = const_cast<tree> (c);
   int vec_len, i;
 
   if (elems == NULL_TREE || elems == error_mark_node)
index 921d3abb3fa0757b8a9c827ffaf20df0b0170733..e8f1a7e8c3465684b8884b36deb589a05ab7b859 100644 (file)
@@ -289,7 +289,7 @@ cp_get_debug_type (const_tree type)
      the debug info depend on the collection points.  */
   if (dtype)
     {
-      tree ktype = CONST_CAST_TREE (type);
+      tree ktype = const_cast<tree> (type);
       if (tree *slot = hash_map_safe_get (debug_type_map, ktype))
        return *slot;
       hash_map_safe_put<hm_ggc> (debug_type_map, ktype, dtype);
index 3867b7b0d2c925444cefb1e22299931914ef78fc..fcad67a662ccabead08a8af8609a70113a6af002 100644 (file)
@@ -5418,20 +5418,22 @@ get_vec_init_expr (tree t)
    DECL_INITIAL (for a PARM_DECL) or as the TREE_TYPE (for a
    TYPE_DECL).
 
-   FIXME: CONST_CAST_TREE is a hack that hopefully will go away after
+   FIXME: const_cast<tree> is a hack that hopefully will go away after
    tree is converted to C++ class hiearchy.  */
 #define DECL_TEMPLATE_PARMS(NODE)       \
-   ((struct tree_template_decl *)CONST_CAST_TREE (TEMPLATE_DECL_CHECK (NODE)))->arguments
+   ((struct tree_template_decl *)const_cast<tree> (TEMPLATE_DECL_CHECK \
+                                                  (NODE)))->arguments
 #define DECL_INNERMOST_TEMPLATE_PARMS(NODE) \
    INNERMOST_TEMPLATE_PARMS (DECL_TEMPLATE_PARMS (NODE))
 #define DECL_NTPARMS(NODE) \
    TREE_VEC_LENGTH (DECL_INNERMOST_TEMPLATE_PARMS (NODE))
 /* For function, method, class-data templates.
 
-   FIXME: CONST_CAST_TREE is a hack that hopefully will go away after
+   FIXME: const_cast<tree> is a hack that hopefully will go away after
    tree is converted to C++ class hiearchy.  */
 #define DECL_TEMPLATE_RESULT(NODE)      \
-   ((struct tree_template_decl *)CONST_CAST_TREE(TEMPLATE_DECL_CHECK (NODE)))->result
+   ((struct tree_template_decl *)const_cast<tree> (TEMPLATE_DECL_CHECK \
+                                                  (NODE)))->result
 /* For a forward-declared function template at namespace scope, or for any
    function template in an exporting module, DECL_TEMPLATE_INSTANTIATIONS lists
    all instantiations and specializations of the function so that
@@ -8942,7 +8944,7 @@ loc_or_input_loc (location_t loc)
 inline location_t
 cp_expr_location (const_tree t_)
 {
-  tree t = CONST_CAST_TREE (t_);
+  tree t = const_cast<tree> (t_);
   if (t == NULL_TREE)
     return UNKNOWN_LOCATION;
   switch (TREE_CODE (t))
index c6aac6a8779e8148c0247420e03be7ab17ef04b7..fb0bc3cccddfdeaaf552f85ec36ace03eb7b053c 100644 (file)
@@ -641,7 +641,7 @@ automatic_var_with_nontrivial_dtor_p (const_tree t)
     return false;
 
   return (VAR_P (t)
-         && decl_storage_duration (CONST_CAST_TREE (t)) == dk_auto
+         && decl_storage_duration (const_cast<tree> (t)) == dk_auto
          && TYPE_HAS_NONTRIVIAL_DESTRUCTOR (TREE_TYPE (t)));
 }
 
index 7b17220ee9b0e16af9270718f4d709c96c6d037d..437797fef0c637b5a7d988eee8f8b5c710bd2d11 100644 (file)
@@ -3705,7 +3705,7 @@ build_new_1 (vec<tree, va_gc> **placement, tree type, tree nelts,
            {
              tree dom
                = compute_array_index_type (NULL_TREE,
-                                           CONST_CAST_TREE (cst_outer_nelts),
+                                           const_cast<tree> (cst_outer_nelts),
                                            complain);
              ttype = build_cplus_array_type (type, dom);
              tree ptype = build_pointer_type (ttype);
index 08c6b42ef05ba0389af4c4af9c6f51b80c962fc4..50966de76f8d1d30f6578b4624603974dd992c0a 100644 (file)
@@ -6662,7 +6662,7 @@ alias_template_specialization_p (const_tree t,
     {
       if (tree tinfo = TYPE_ALIAS_TEMPLATE_INFO (t))
        if (PRIMARY_TEMPLATE_P (TI_TEMPLATE (tinfo)))
-         return CONST_CAST_TREE (t);
+         return const_cast<tree> (t);
       if (transparent_typedefs && !dependent_opaque_alias_p (t))
        return alias_template_specialization_p (DECL_ORIGINAL_TYPE
                                                (TYPE_NAME (t)),
@@ -6760,7 +6760,7 @@ complex_alias_template_p (const_tree tmpl, tree *seen_out)
     return false;
 
   /* A renaming alias isn't complex.  */
-  if (get_underlying_template (CONST_CAST_TREE (tmpl)) != tmpl)
+  if (get_underlying_template (const_cast<tree> (tmpl)) != tmpl)
     return false;
 
   /* Any other constrained alias is complex.  */
@@ -6843,7 +6843,7 @@ dependent_alias_template_spec_p (const_tree t, bool transparent_typedefs)
          if (!seen)
            {
              if (any_dependent_template_arguments_p (args))
-               return CONST_CAST_TREE (t);
+               return const_cast<tree> (t);
            }
          else
            {
@@ -6851,7 +6851,7 @@ dependent_alias_template_spec_p (const_tree t, bool transparent_typedefs)
              for (int i = 0, len = TREE_VEC_LENGTH (args); i < len; ++i)
                if (TREE_VEC_ELT (seen, i) != boolean_true_node
                    && dependent_template_arg_p (TREE_VEC_ELT (args, i)))
-                 return CONST_CAST_TREE (t);
+                 return const_cast<tree> (t);
            }
 
          return NULL_TREE;
@@ -27465,7 +27465,7 @@ most_general_template (const_tree decl)
       decl = DECL_TI_TEMPLATE (decl);
     }
 
-  return CONST_CAST_TREE (decl);
+  return const_cast<tree> (decl);
 }
 
 /* Return the most specialized of the template partial specializations
@@ -30434,7 +30434,7 @@ any_dependent_template_arguments_p (const_tree args)
   for (int i = 0, depth = TMPL_ARGS_DEPTH (args); i < depth; ++i)
     {
       const_tree level = TMPL_ARGS_LEVEL (args, i + 1);
-      for (tree arg : tree_vec_range (CONST_CAST_TREE (level)))
+      for (tree arg : tree_vec_range (const_cast<tree> (level)))
        if (dependent_template_arg_p (arg))
          return true;
     }
index 4557560779ed4eab46d349f6234e3a4b45195d20..b6b7556e4247c3a57688bdd411e5b6af266a094f 100644 (file)
@@ -1576,7 +1576,7 @@ static tree
 eval_has_static_storage_duration (const_tree r, reflect_kind kind)
 {
   if (eval_is_variable (r, kind) == boolean_true_node
-      && decl_storage_duration (CONST_CAST_TREE (r)) == dk_static)
+      && decl_storage_duration (const_cast<tree> (r)) == dk_static)
     return boolean_true_node;
   /* This includes DECL_NTTP_OBJECT_P objects.  */
   else if (eval_is_object (kind) == boolean_true_node)
@@ -1593,7 +1593,7 @@ static tree
 eval_has_thread_storage_duration (const_tree r, reflect_kind kind)
 {
   if (eval_is_variable (r, kind) == boolean_true_node
-      && decl_storage_duration (CONST_CAST_TREE (r)) == dk_thread)
+      && decl_storage_duration (const_cast<tree> (r)) == dk_thread)
     return boolean_true_node;
   else
     return boolean_false_node;
@@ -1607,7 +1607,7 @@ static tree
 eval_has_automatic_storage_duration (const_tree r, reflect_kind kind)
 {
   if (eval_is_variable (r, kind) == boolean_true_node
-      && decl_storage_duration (CONST_CAST_TREE (r)) == dk_auto)
+      && decl_storage_duration (const_cast<tree> (r)) == dk_auto)
     return boolean_true_node;
   else
     return boolean_false_node;
index f364d525f23eeee0fb847d3a786058f55badd025..b8820baf203f901de318b73527a9fded04c799a9 100644 (file)
@@ -206,7 +206,7 @@ lvalue_kind (const_tree ref)
       /* FALLTHRU */
     case VAR_DECL:
       if (VAR_P (ref) && DECL_HAS_VALUE_EXPR_P (ref))
-       return lvalue_kind (DECL_VALUE_EXPR (CONST_CAST_TREE (ref)));
+       return lvalue_kind (DECL_VALUE_EXPR (const_cast<tree> (ref)));
 
       if (TREE_READONLY (ref) && ! TREE_STATIC (ref)
          && DECL_LANG_SPECIFIC (ref)
@@ -227,7 +227,7 @@ lvalue_kind (const_tree ref)
       /* A scope ref in a template, left as SCOPE_REF to support later
         access checking.  */
     case SCOPE_REF:
-      gcc_assert (!type_dependent_expression_p (CONST_CAST_TREE (ref)));
+      gcc_assert (!type_dependent_expression_p (const_cast<tree> (ref)));
       {
        tree op = TREE_OPERAND (ref, 1);
        if (TREE_CODE (op) == FIELD_DECL)
@@ -255,7 +255,7 @@ lvalue_kind (const_tree ref)
             point, we know we got a plain rvalue.  Unless we have a
             type-dependent expr, that is, but we shouldn't be testing
             lvalueness if we can't even tell the types yet!  */
-         gcc_assert (!type_dependent_expression_p (CONST_CAST_TREE (ref)));
+         gcc_assert (!type_dependent_expression_p (const_cast<tree> (ref)));
          goto default_;
        }
       {
@@ -316,7 +316,7 @@ lvalue_kind (const_tree ref)
         with a BASELINK.  */
       /* This CONST_CAST is okay because BASELINK_FUNCTIONS returns
         its argument unmodified and we assign it to a const_tree.  */
-      return lvalue_kind (BASELINK_FUNCTIONS (CONST_CAST_TREE (ref)));
+      return lvalue_kind (BASELINK_FUNCTIONS (const_cast<tree> (ref)));
 
     case PAREN_EXPR:
       return lvalue_kind (TREE_OPERAND (ref, 0));
@@ -4715,7 +4715,7 @@ scalarish_type_p (const_tree t)
 bool
 type_has_nontrivial_default_init (const_tree t)
 {
-  t = strip_array_types (CONST_CAST_TREE (t));
+  t = strip_array_types (const_cast<tree> (t));
 
   if (CLASS_TYPE_P (t))
     return TYPE_HAS_COMPLEX_DFLT (t);
@@ -4732,7 +4732,7 @@ remember_deleted_copy (const_tree t)
 {
   if (!deleted_copy_types)
     deleted_copy_types = hash_set<tree>::create_ggc(37);
-  deleted_copy_types->add (CONST_CAST_TREE (t));
+  deleted_copy_types->add (const_cast<tree> (t));
 }
 void
 maybe_warn_parm_abi (tree t, location_t loc)
@@ -4775,7 +4775,7 @@ maybe_warn_parm_abi (tree t, location_t loc)
 bool
 type_has_nontrivial_copy_init (const_tree type)
 {
-  tree t = strip_array_types (CONST_CAST_TREE (type));
+  tree t = strip_array_types (const_cast<tree> (type));
 
   if (CLASS_TYPE_P (t))
     {
@@ -4862,7 +4862,7 @@ type_has_nontrivial_copy_init (const_tree type)
 bool
 trivially_copyable_p (const_tree t)
 {
-  t = strip_array_types (CONST_CAST_TREE (t));
+  t = strip_array_types (const_cast<tree> (t));
 
   if (CLASS_TYPE_P (t))
     return ((!TYPE_HAS_COPY_CTOR (t)
@@ -4883,12 +4883,12 @@ trivially_copyable_p (const_tree t)
 bool
 trivial_type_p (const_tree t)
 {
-  t = strip_array_types (CONST_CAST_TREE (t));
+  t = strip_array_types (const_cast<tree> (t));
 
   if (CLASS_TYPE_P (t))
     /* A trivial class is a class that is trivially copyable and has one or
        more eligible default constructors, all of which are trivial.  */
-    return (type_has_non_deleted_trivial_default_ctor (CONST_CAST_TREE (t))
+    return (type_has_non_deleted_trivial_default_ctor (const_cast<tree> (t))
            && trivially_copyable_p (t));
   else
     return scalarish_type_p (t);
@@ -4943,7 +4943,7 @@ pod_type_p (const_tree t)
 {
   /* This CONST_CAST is okay because strip_array_types returns its
      argument unmodified and we assign it to a const_tree.  */
-  t = strip_array_types (CONST_CAST_TREE(t));
+  t = strip_array_types (const_cast<tree>(t));
 
   if (!CLASS_TYPE_P (t))
     return scalarish_type_p (t);
@@ -4966,7 +4966,7 @@ pod_type_p (const_tree t)
 bool
 layout_pod_type_p (const_tree t)
 {
-  t = strip_array_types (CONST_CAST_TREE (t));
+  t = strip_array_types (const_cast<tree> (t));
 
   if (CLASS_TYPE_P (t))
     return !CLASSTYPE_NON_LAYOUT_POD_P (t);
@@ -4980,7 +4980,7 @@ layout_pod_type_p (const_tree t)
 bool
 std_layout_type_p (const_tree t)
 {
-  t = strip_array_types (CONST_CAST_TREE (t));
+  t = strip_array_types (const_cast<tree> (t));
 
   if (CLASS_TYPE_P (t))
     return !CLASSTYPE_NON_STD_LAYOUT (t);
@@ -4998,7 +4998,7 @@ type_has_unique_obj_representations (const_tree t, bool explain/*=false*/)
 {
   bool ret;
 
-  t = strip_array_types (CONST_CAST_TREE (t));
+  t = strip_array_types (const_cast<tree> (t));
 
   if (t == error_mark_node)
     return false;
@@ -5238,7 +5238,7 @@ zero_init_p (const_tree t)
 {
   /* This CONST_CAST is okay because strip_array_types returns its
      argument unmodified and we assign it to a const_tree.  */
-  t = strip_array_types (CONST_CAST_TREE(t));
+  t = strip_array_types (const_cast<tree> (t));
 
   if (t == error_mark_node)
     return 1;
@@ -6005,7 +6005,7 @@ cxx_type_hash_eq (const_tree typea, const_tree typeb)
 tree
 cxx_copy_lang_qualifiers (const_tree typea, const_tree typeb)
 {
-  tree type = CONST_CAST_TREE (typea);
+  tree type = const_cast<tree> (typea);
   if (FUNC_OR_METHOD_TYPE_P (type))
     type = build_cp_fntype_variant (type, type_memfn_rqual (typeb),
                                    TYPE_RAISES_EXCEPTIONS (typeb),
index 40bb9828bcc6d8643cc09aa6a1f6697ddc0a4bb1..20ef2a4d6df5550d1f5e22dcc6289c4541239f3c 100644 (file)
@@ -1227,8 +1227,8 @@ comp_except_specs (const_tree t1, const_tree t2, int exact)
   if (exact < ce_exact)
     {
       if (exact == ce_type
-         && (canonical_eh_spec (CONST_CAST_TREE (t1))
-             == canonical_eh_spec (CONST_CAST_TREE (t2))))
+         && (canonical_eh_spec (const_cast<tree> (t1))
+             == canonical_eh_spec (const_cast<tree> (t2))))
        return true;
 
       /* noexcept(false) is compatible with no exception-specification,
@@ -2556,7 +2556,7 @@ is_bitfield_expr_with_lowered_type (const_tree exp)
     case VAR_DECL:
       if (DECL_HAS_VALUE_EXPR_P (exp))
        return is_bitfield_expr_with_lowered_type (DECL_VALUE_EXPR
-                                                  (CONST_CAST_TREE (exp)));
+                                                  (const_cast<tree> (exp)));
       return NULL_TREE;
 
     case VIEW_CONVERT_EXPR:
@@ -12025,7 +12025,7 @@ cp_type_quals (const_tree type)
   int quals;
   /* This CONST_CAST is okay because strip_array_types returns its
      argument unmodified and we assign it to a const_tree.  */
-  type = strip_array_types (CONST_CAST_TREE (type));
+  type = strip_array_types (const_cast<tree> (type));
   if (type == error_mark_node
       /* Quals on a FUNCTION_TYPE are memfn quals.  */
       || TREE_CODE (type) == FUNCTION_TYPE)
@@ -12102,7 +12102,7 @@ cp_has_mutable_p (const_tree type)
 {
   /* This CONST_CAST is okay because strip_array_types returns its
      argument unmodified and we assign it to a const_tree.  */
-  type = strip_array_types (CONST_CAST_TREE(type));
+  type = strip_array_types (const_cast<tree> (type));
 
   return CLASS_TYPE_P (type) && CLASSTYPE_HAS_MUTABLE (type);
 }
index f18c5a7499e8a7289e99143fa05920c6f08bdede..a5567e7de180bce7ce5b4a12c9065b0a5890e3eb 100644 (file)
@@ -280,7 +280,7 @@ cxx_incomplete_type_inform (const_tree type)
     return;
 
   location_t loc = DECL_SOURCE_LOCATION (TYPE_MAIN_DECL (type));
-  tree ptype = strip_top_quals (CONST_CAST_TREE (type));
+  tree ptype = strip_top_quals (const_cast<tree> (type));
 
   /* When defining a template, current_class_type will be the pattern on
      the template definition, while non-self-reference usages of this
index 82d8ef5092e827c7d349db3bd77b20c321cde02c..41681d38570f1d50c06e46593082dec86c4d6a55 100644 (file)
@@ -3659,13 +3659,14 @@ operand_compare::operand_equal_p (tree type0, const_tree arg0,
                  && (TREE_TYPE (TREE_OPERAND (arg0, 0))
                      == TREE_TYPE (TREE_OPERAND (arg1, 0))
                      || (operand_equal_p (array_ref_low_bound
-                                            (CONST_CAST_TREE (arg0)),
+                                            (const_cast<tree> (arg0)),
                                           array_ref_low_bound
-                                            (CONST_CAST_TREE (arg1)), flags)
+                                            (const_cast<tree> (arg1)),
+                                          flags)
                          && operand_equal_p (array_ref_element_size
-                                               (CONST_CAST_TREE (arg0)),
+                                               (const_cast<tree> (arg0)),
                                              array_ref_element_size
-                                               (CONST_CAST_TREE (arg1)),
+                                               (const_cast<tree> (arg1)),
                                              flags))));
 
        case COMPONENT_REF:
@@ -3951,8 +3952,8 @@ operand_compare::operand_equal_p (tree type0, const_tree arg0,
        {
          /* Compare the STATEMENT_LISTs.  */
          tree_stmt_iterator tsi1, tsi2;
-         tree body1 = CONST_CAST_TREE (arg0);
-         tree body2 = CONST_CAST_TREE (arg1);
+         tree body1 = const_cast<tree> (arg0);
+         tree body2 = const_cast<tree> (arg1);
          for (tsi1 = tsi_start (body1), tsi2 = tsi_start (body2); ;
               tsi_next (&tsi1), tsi_next (&tsi2))
            {
@@ -4109,7 +4110,7 @@ operand_compare::hash_operand (const_tree t, inchash::hash &hstate,
     case STATEMENT_LIST:
       {
        tree_stmt_iterator i;
-       for (i = tsi_start (CONST_CAST_TREE (t));
+       for (i = tsi_start (const_cast<tree> (t));
             !tsi_end_p (i); tsi_next (&i))
          hash_operand (tsi_stmt (i), hstate, flags);
        return;
index 92f6f9999edece296e721bd571c8da5fc9fcac87..96f9fc720afba771e6593dc60083afe70b4743c6 100644 (file)
@@ -865,7 +865,7 @@ is_gimple_asm_val (tree t)
 bool
 is_gimple_min_lval (tree t)
 {
-  if (!(t = CONST_CAST_TREE (strip_invariant_refs (t))))
+  if (!(t = const_cast<tree> (strip_invariant_refs (t))))
     return false;
   return (is_gimple_id (t) || TREE_CODE (t) == MEM_REF);
 }
index e5c5bc6c675e45c13a2cc1948a2ec59f70f8f85d..17bbc8d84120cf1327b1341196e965f0643a5605 100644 (file)
@@ -397,8 +397,8 @@ gimple_canonical_type_eq (const void *p1, const void *p2)
 {
   const_tree t1 = (const_tree) p1;
   const_tree t2 = (const_tree) p2;
-  return gimple_canonical_types_compatible_p (CONST_CAST_TREE (t1),
-                                             CONST_CAST_TREE (t2));
+  return gimple_canonical_types_compatible_p (const_cast<tree> (t1),
+                                             const_cast<tree> (t2));
 }
 
 /* Main worker for gimple_register_canonical_type.  */
index 56a3f52895f250e4c4dd8aebe6fe52d0f8695806..57ef67b08f87a1e83b760dff025528c5d390c238 100644 (file)
@@ -190,8 +190,7 @@ void
 print_mem_expr (FILE *outfile, const_tree expr)
 {
   fputc (' ', outfile);
-  print_generic_expr (outfile, CONST_CAST_TREE (expr),
-                     dump_flags | TDF_SLIM);
+  print_generic_expr (outfile, const_cast<tree> (expr), dump_flags | TDF_SLIM);
 }
 #endif
 
index 346fc9f6a3890d066119109ab1f6e67969d05c1b..b7a50376ecd8499f3fd8148bc541365f69bb3397 100644 (file)
@@ -796,7 +796,7 @@ out:
 location_t
 rs_expr_location (const_tree t_)
 {
-  tree t = CONST_CAST_TREE (t_);
+  tree t = const_cast<tree> (t_);
   if (t == NULL_TREE)
     return UNKNOWN_LOCATION;
 
@@ -957,7 +957,7 @@ rs_type_quals (const_tree type)
   int quals;
   /* This CONST_CAST is okay because strip_array_types returns its
      argument unmodified and we assign it to a const_tree.  */
-  type = strip_array_types (CONST_CAST_TREE (type));
+  type = strip_array_types (const_cast<tree> (type));
   if (type == error_mark_node
       /* Quals on a FUNCTION_TYPE are memfn quals.  */
       || TREE_CODE (type) == FUNCTION_TYPE)
@@ -2179,8 +2179,8 @@ comp_except_specs (const_tree t1, const_tree t2, int exact)
   if (exact < ce_exact)
     {
       if (exact == ce_type
-         && (canonical_eh_spec (CONST_CAST_TREE (t1))
-             == canonical_eh_spec (CONST_CAST_TREE (t2))))
+         && (canonical_eh_spec (const_cast<tree> (t1))
+             == canonical_eh_spec (const_cast<tree> (t2))))
        return true;
 
       /* noexcept(false) is compatible with no exception-specification,
@@ -3563,7 +3563,7 @@ is_bitfield_expr_with_lowered_type (const_tree exp)
     case VAR_DECL:
       if (DECL_HAS_VALUE_EXPR_P (exp))
        return is_bitfield_expr_with_lowered_type (
-         DECL_VALUE_EXPR (CONST_CAST_TREE (exp)));
+         DECL_VALUE_EXPR (const_cast<tree> (exp)));
       return NULL_TREE;
 
     case VIEW_CONVERT_EXPR:
@@ -3857,7 +3857,7 @@ strip_top_quals (tree t)
 //     return;
 
 //   location_t loc = DECL_SOURCE_LOCATION (TYPE_MAIN_DECL (type));
-//   tree ptype = strip_top_quals (CONST_CAST_TREE (type));
+//   tree ptype = strip_top_quals (const_cast<tree> (type));
 
 //   if (current_class_type && TYPE_BEING_DEFINED (current_class_type)
 //       && same_type_p (ptype, current_class_type))
@@ -4530,7 +4530,7 @@ lvalue_kind (const_tree ref)
       /* FALLTHRU */
     case VAR_DECL:
       if (VAR_P (ref) && DECL_HAS_VALUE_EXPR_P (ref))
-       return lvalue_kind (DECL_VALUE_EXPR (CONST_CAST_TREE (ref)));
+       return lvalue_kind (DECL_VALUE_EXPR (const_cast<tree> (ref)));
 
       if (TREE_READONLY (ref) && !TREE_STATIC (ref) && DECL_LANG_SPECIFIC (ref)
          && DECL_IN_AGGR_P (ref))
@@ -5193,7 +5193,7 @@ complete_type_or_else (tree type, tree value)
 bool
 std_layout_type_p (const_tree t)
 {
-  t = strip_array_types (CONST_CAST_TREE (t));
+  t = strip_array_types (const_cast<tree> (t));
 
   if (CLASS_TYPE_P (t))
     return !CLASSTYPE_NON_STD_LAYOUT (t);
index 908647b8401697f962ae2df1cc6d1868f8faa04d..ab2ba4abb85fc4aa195b25ec52975b38b0a058b7 100644 (file)
@@ -442,8 +442,8 @@ compute_object_offset (tree expr, const_tree var)
 
       t = TREE_OPERAND (expr, 1);
       tree low_bound, unit_size;
-      low_bound = array_ref_low_bound (CONST_CAST_TREE (expr));
-      unit_size = array_ref_element_size (CONST_CAST_TREE (expr));
+      low_bound = array_ref_low_bound (const_cast<tree> (expr));
+      unit_size = array_ref_element_size (const_cast<tree> (expr));
       if (! integer_zerop (low_bound))
        t = fold_build2 (MINUS_EXPR, TREE_TYPE (t), t, low_bound);
       if (TREE_CODE (t) == INTEGER_CST && tree_int_cst_sgn (t) < 0)
index a007bbeb3ea403e65015cacab04b9234999438f4..cf47f0ee64da6d0072d253399f4e57426ec9de37 100644 (file)
@@ -3283,7 +3283,7 @@ tree_ctz (const_tree expr)
     case COMPOUND_EXPR:
       return tree_ctz (TREE_OPERAND (expr, 1));
     case ADDR_EXPR:
-      ret1 = get_pointer_alignment (CONST_CAST_TREE (expr));
+      ret1 = get_pointer_alignment (const_cast<tree> (expr));
       if (ret1 > BITS_PER_UNIT)
        {
          ret1 = ctz_hwi (ret1 / BITS_PER_UNIT);
@@ -12962,7 +12962,7 @@ block_may_fallthru (const_tree block)
 {
   /* This CONST_CAST is okay because expr_last returns its argument
      unmodified and we assign it to a const_tree.  */
-  const_tree stmt = expr_last (CONST_CAST_TREE (block));
+  const_tree stmt = expr_last (const_cast<tree> (block));
 
   switch (stmt ? TREE_CODE (stmt) : ERROR_MARK)
     {
index dcd3ff85d04f388766063f3ca6882e7daf856993..16ad3996784190c3e3629f3ea43844fc6c0f6f63 100644 (file)
@@ -568,12 +568,12 @@ extern void omp_clause_range_check_failed (const_tree, const char *, int,
    we are not modifying the tree itself.  */
 
 #define STRIP_NOPS(EXP) \
-  (EXP) = tree_strip_nop_conversions (CONST_CAST_TREE (EXP))
+  (EXP) = tree_strip_nop_conversions (const_cast<tree> (EXP))
 
 /* Like STRIP_NOPS, but don't let the signedness change either.  */
 
 #define STRIP_SIGN_NOPS(EXP) \
-  (EXP) = tree_strip_sign_nop_conversions (CONST_CAST_TREE (EXP))
+  (EXP) = tree_strip_sign_nop_conversions (const_cast<tree> (EXP))
 
 /* Like STRIP_NOPS, but don't alter the TREE_TYPE either.  */
 
@@ -595,7 +595,7 @@ extern void omp_clause_range_check_failed (const_tree, const char *, int,
    in use to provide a location_t.  */
 
 #define STRIP_ANY_LOCATION_WRAPPER(EXP) \
-  (EXP) = tree_strip_any_location_wrapper (CONST_CAST_TREE (EXP))
+  (EXP) = tree_strip_any_location_wrapper (const_cast<tree> (EXP))
 
 /* Nonzero if TYPE represents a vector type.  */
 
@@ -3991,7 +3991,7 @@ tree_int_cst_elt_check (const_tree __t, int __i,
   if (__i < 0 || __i >= __t->base.u.int_length.extended)
     tree_int_cst_elt_check_failed (__i, __t->base.u.int_length.extended,
                                   __f, __l, __g);
-  return &CONST_CAST_TREE (__t)->int_cst.val[__i];
+  return &const_cast<tree> (__t)->int_cst.val[__i];
 }
 
 inline HOST_WIDE_INT *
@@ -4003,7 +4003,7 @@ tree_int_cst_elt_check (tree __t, int __i,
   if (__i < 0 || __i >= __t->base.u.int_length.extended)
     tree_int_cst_elt_check_failed (__i, __t->base.u.int_length.extended,
                                   __f, __l, __g);
-  return &CONST_CAST_TREE (__t)->int_cst.val[__i];
+  return &const_cast<tree> (__t)->int_cst.val[__i];
 }
 
 /* Workaround -Wstrict-overflow false positive during profiledbootstrap.  */
@@ -4021,7 +4021,7 @@ tree_vec_elt_check (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_TREE (__t)->vec.a[__i];
+  return &const_cast<tree> (__t)->vec.a[__i];
 }
 
 # if GCC_VERSION >= 4006
@@ -4332,7 +4332,7 @@ tree_operand_check (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_TREE (__u)->exp.operands[__i];
+  return &const_cast<tree> (__u)->exp.operands[__i];
 }
 
 inline tree *
index dc5439be3ca32ab48108f0712217f2f06ad782c3..5999f1e5420c440e0ebb09ce43da58b13a5850b5 100644 (file)
@@ -7374,7 +7374,7 @@ categorize_decl_for_section (const_tree decl, int reloc)
   else if (TREE_CODE (decl) == STRING_CST)
     {
       if ((flag_sanitize & SANITIZE_ADDRESS)
-         && asan_protect_global (CONST_CAST_TREE (decl)))
+         && asan_protect_global (const_cast<tree> (decl)))
       /* or !flag_merge_constants */
         return SECCAT_RODATA;
       else
@@ -7382,7 +7382,7 @@ categorize_decl_for_section (const_tree decl, int reloc)
     }
   else if (VAR_P (decl))
     {
-      tree d = CONST_CAST_TREE (decl);
+      tree d = const_cast<tree> (decl);
       if (bss_initializer_p (decl))
        ret = SECCAT_BSS;
       else if (! TREE_READONLY (decl)