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 <[email protected]>
---
gcc/attribs.cc | 12 ++++++------
gcc/c-family/c-gimplify.cc | 2 +-
gcc/config/aarch64/aarch64.cc | 2 +-
gcc/config/arm/arm.cc | 6 +++---
gcc/config/darwin.cc | 6 +++---
gcc/cp/call.cc | 2 +-
gcc/cp/constraint.cc | 2 +-
gcc/cp/cp-lang.cc | 2 +-
gcc/cp/cp-objcp-common.cc | 2 +-
gcc/cp/cp-tree.h | 12 +++++++-----
gcc/cp/decl.cc | 2 +-
gcc/cp/init.cc | 2 +-
gcc/cp/pt.cc | 12 ++++++------
gcc/cp/reflect.cc | 6 +++---
gcc/cp/tree.cc | 32 ++++++++++++++++----------------
gcc/cp/typeck.cc | 10 +++++-----
gcc/cp/typeck2.cc | 2 +-
gcc/fold-const.cc | 15 ++++++++-------
gcc/gimple-expr.cc | 2 +-
gcc/lto/lto-common.cc | 4 ++--
gcc/print-rtl.cc | 3 +--
gcc/rust/backend/rust-tree.cc | 16 ++++++++--------
gcc/tree-object-size.cc | 4 ++--
gcc/tree.cc | 4 ++--
gcc/tree.h | 14 +++++++-------
gcc/varasm.cc | 4 ++--
26 files changed, 91 insertions(+), 89 deletions(-)
diff --git a/gcc/attribs.cc b/gcc/attribs.cc
index 94227375701..097efb7a33b 100644
--- a/gcc/attribs.cc
+++ b/gcc/attribs.cc
@@ -1512,7 +1512,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;
}
@@ -1526,7 +1526,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. */
@@ -1536,13 +1536,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
@@ -2116,7 +2116,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)))
diff --git a/gcc/c-family/c-gimplify.cc b/gcc/c-family/c-gimplify.cc
index 182e80f5529..716c39936c4 100644
--- a/gcc/c-family/c-gimplify.cc
+++ b/gcc/c-family/c-gimplify.cc
@@ -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);
diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc
index 059311e7d20..82785dec3da 100644
--- a/gcc/config/aarch64/aarch64.cc
+++ b/gcc/config/aarch64/aarch64.cc
@@ -23727,7 +23727,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. */
diff --git a/gcc/config/arm/arm.cc b/gcc/config/arm/arm.cc
index 0a1f6612d07..328b1d131cf 100644
--- a/gcc/config/arm/arm.cc
+++ b/gcc/config/arm/arm.cc
@@ -6345,9 +6345,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;
}
@@ -30574,7 +30574,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. */
diff --git a/gcc/config/darwin.cc b/gcc/config/darwin.cc
index b748c359ff7..6008ee7304e 100644
--- a/gcc/config/darwin.cc
+++ b/gcc/config/darwin.cc
@@ -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
diff --git a/gcc/cp/call.cc b/gcc/cp/call.cc
index 62d25ce6ebe..979343e8329 100644
--- a/gcc/cp/call.cc
+++ b/gcc/cp/call.cc
@@ -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);
diff --git a/gcc/cp/constraint.cc b/gcc/cp/constraint.cc
index 0b91e878563..c0f75a01b07 100644
--- a/gcc/cp/constraint.cc
+++ b/gcc/cp/constraint.cc
@@ -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
diff --git a/gcc/cp/cp-lang.cc b/gcc/cp/cp-lang.cc
index d63032f093a..c9d02cc7302 100644
--- a/gcc/cp/cp-lang.cc
+++ b/gcc/cp/cp-lang.cc
@@ -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)
diff --git a/gcc/cp/cp-objcp-common.cc b/gcc/cp/cp-objcp-common.cc
index 921d3abb3fa..e8f1a7e8c34 100644
--- a/gcc/cp/cp-objcp-common.cc
+++ b/gcc/cp/cp-objcp-common.cc
@@ -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);
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index 59ab4e40430..1b88fe77e96 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -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
@@ -8943,7 +8945,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))
diff --git a/gcc/cp/decl.cc b/gcc/cp/decl.cc
index 6dabf349bef..cdc16bb75d6 100644
--- a/gcc/cp/decl.cc
+++ b/gcc/cp/decl.cc
@@ -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)));
}
diff --git a/gcc/cp/init.cc b/gcc/cp/init.cc
index 7b17220ee9b..437797fef0c 100644
--- a/gcc/cp/init.cc
+++ b/gcc/cp/init.cc
@@ -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);
diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc
index de101b180e3..beffd47209f 100644
--- a/gcc/cp/pt.cc
+++ b/gcc/cp/pt.cc
@@ -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;
@@ -27460,7 +27460,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
@@ -30429,7 +30429,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;
}
diff --git a/gcc/cp/reflect.cc b/gcc/cp/reflect.cc
index 5b6ad8be14b..f0b5ac1b4ef 100644
--- a/gcc/cp/reflect.cc
+++ b/gcc/cp/reflect.cc
@@ -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;
diff --git a/gcc/cp/tree.cc b/gcc/cp/tree.cc
index 2f386e16b9c..ed4cc815479 100644
--- a/gcc/cp/tree.cc
+++ b/gcc/cp/tree.cc
@@ -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));
@@ -4735,7 +4735,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);
@@ -4752,7 +4752,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)
@@ -4795,7 +4795,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))
{
@@ -4882,7 +4882,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)
@@ -4903,12 +4903,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);
@@ -4963,7 +4963,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);
@@ -4986,7 +4986,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);
@@ -5000,7 +5000,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);
@@ -5018,7 +5018,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;
@@ -5258,7 +5258,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;
@@ -6025,7 +6025,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),
diff --git a/gcc/cp/typeck.cc b/gcc/cp/typeck.cc
index 40bb9828bcc..20ef2a4d6df 100644
--- a/gcc/cp/typeck.cc
+++ b/gcc/cp/typeck.cc
@@ -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);
}
diff --git a/gcc/cp/typeck2.cc b/gcc/cp/typeck2.cc
index f18c5a7499e..a5567e7de18 100644
--- a/gcc/cp/typeck2.cc
+++ b/gcc/cp/typeck2.cc
@@ -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
diff --git a/gcc/fold-const.cc b/gcc/fold-const.cc
index 82d8ef5092e..41681d38570 100644
--- a/gcc/fold-const.cc
+++ b/gcc/fold-const.cc
@@ -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;
diff --git a/gcc/gimple-expr.cc b/gcc/gimple-expr.cc
index 92f6f9999ed..96f9fc720af 100644
--- a/gcc/gimple-expr.cc
+++ b/gcc/gimple-expr.cc
@@ -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);
}
diff --git a/gcc/lto/lto-common.cc b/gcc/lto/lto-common.cc
index e5c5bc6c675..17bbc8d8412 100644
--- a/gcc/lto/lto-common.cc
+++ b/gcc/lto/lto-common.cc
@@ -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. */
diff --git a/gcc/print-rtl.cc b/gcc/print-rtl.cc
index 56a3f52895f..57ef67b08f8 100644
--- a/gcc/print-rtl.cc
+++ b/gcc/print-rtl.cc
@@ -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
diff --git a/gcc/rust/backend/rust-tree.cc b/gcc/rust/backend/rust-tree.cc
index 346fc9f6a38..b7a50376ecd 100644
--- a/gcc/rust/backend/rust-tree.cc
+++ b/gcc/rust/backend/rust-tree.cc
@@ -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);
diff --git a/gcc/tree-object-size.cc b/gcc/tree-object-size.cc
index 908647b8401..ab2ba4abb85 100644
--- a/gcc/tree-object-size.cc
+++ b/gcc/tree-object-size.cc
@@ -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)
diff --git a/gcc/tree.cc b/gcc/tree.cc
index ca713cec4d6..69209077415 100644
--- a/gcc/tree.cc
+++ b/gcc/tree.cc
@@ -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);
@@ -12948,7 +12948,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)
{
diff --git a/gcc/tree.h b/gcc/tree.h
index dcd3ff85d04..16ad3996784 100644
--- a/gcc/tree.h
+++ b/gcc/tree.h
@@ -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 *
diff --git a/gcc/varasm.cc b/gcc/varasm.cc
index dc5439be3ca..5999f1e5420 100644
--- a/gcc/varasm.cc
+++ b/gcc/varasm.cc
@@ -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)
--
2.43.0