tree.def (VOID_CST): New.

gcc/
	* tree.def (VOID_CST): New.
	* tree-core.h (TI_VOID): New.
	* tree.h (void_node): New.
	* tree.c (tree_node_structure_for_code, tree_code_size)
	(iterative_hash_expr): Handle VOID_CST.
	(build_common_tree_nodes): Initialize void_node.

gcc/c-family/
	* c-common.h (CTI_VOID_ZERO, void_zero_node): Delete.
	* c-common.c (c_common_nodes_and_builtins): Don't initialize
	void_zero_node.
	* c-pretty-print.c (pp_c_void_constant): New function.
	(c_pretty_printer::constant, c_pretty_printer::primary_expression)
	(c_pretty_printer::expression): Handle VOID_CST.
	* cilk.c (extract_free_variables): Likewise.
	* c-ubsan.c (ubsan_instrument_division, ubsan_instrument_shift)
	(ubsan_instrument_vla): Use void_node instead of void_zero_node.

gcc/c/
	* c-array-notation.c (expand_array_notations): Use void_node
	instead of void_zero_node.

gcc/cp/
	* cvt.c (convert_to_void): Use void_node instead of void_zero_node.
	* cp-array-notation.c (replace_invariant_exprs): Likewise.
	(expand_array_notation): Handle VOID_CST.
	* error.c (dump_expr): Likewise.
	* cxx-pretty-print.c (cxx_pretty_printer::primary_expression)
	(cxx_pretty_printer::expression): Likewise.
	(pp_cxx_new_expression): Use void_node instead of void_zero_node.
	* decl.c (register_dtor_fn): Likewise.
	* init.c (build_raw_new_expr, build_new_1, build_vec_init)
	(build_delete, push_base_cleanups): Likewise.
	* mangle.c (write_expression): Likewise.
	* semantics.c (finish_break_stmt, empty_expr_stmt_p): Likewise.
	* pt.c (tsubst_decl, tsubst_copy_and_build): Likewise.
	(tsubst, tsubst_copy, build_non_dependent_expr): Handle VOID_CST.
	* tree.c (cp_tree_equal): Likewise.
	(build_dummy_object, is_dummy_object, stabilize_expr): Use void_node
	instead of void_zero_node.
	* typeck.c (check_return_expr): Likewise.
	* typeck2.c (build_functional_cast): Likewise.

From-SVN: r210692
This commit is contained in:
Richard Sandiford 2014-05-21 11:00:35 +00:00 committed by Richard Sandiford
parent 313822494e
commit 632f2871ed
26 changed files with 127 additions and 41 deletions

View File

@ -1,3 +1,12 @@
2014-05-21 Richard Sandiford <rsandifo@linux.vnet.ibm.com>
* tree.def (VOID_CST): New.
* tree-core.h (TI_VOID): New.
* tree.h (void_node): New.
* tree.c (tree_node_structure_for_code, tree_code_size)
(iterative_hash_expr): Handle VOID_CST.
(build_common_tree_nodes): Initialize void_node.
2014-05-21 Bernd Schmidt <bernds@codesourcery.com>
* reload1.c (remove_init_insns, will_delete_init_insn_p): New static

View File

@ -1,3 +1,15 @@
2014-05-21 Richard Sandiford <rsandifo@linux.vnet.ibm.com>
* c-common.h (CTI_VOID_ZERO, void_zero_node): Delete.
* c-common.c (c_common_nodes_and_builtins): Don't initialize
void_zero_node.
* c-pretty-print.c (pp_c_void_constant): New function.
(c_pretty_printer::constant, c_pretty_printer::primary_expression)
(c_pretty_printer::expression): Handle VOID_CST.
* cilk.c (extract_free_variables): Likewise.
* c-ubsan.c (ubsan_instrument_division, ubsan_instrument_shift)
(ubsan_instrument_vla): Use void_node instead of void_zero_node.
2014-05-17 Trevor Saunders <tsaunders@mozilla.com>
* c-common.h (sorted_fields_type): Remove variable_size GTY attribute.

View File

@ -5524,10 +5524,6 @@ c_common_nodes_and_builtins (void)
TYPE_NAME (void_type_node) = void_name;
}
/* This node must not be shared. */
void_zero_node = make_int_cst (1, 1);
TREE_TYPE (void_zero_node) = void_type_node;
void_list_node = build_void_list_node ();
/* Make a type to be the domain of a few array types

View File

@ -297,8 +297,6 @@ enum c_tree_index
CTI_C99_FUNCTION_NAME_DECL,
CTI_SAVED_FUNCTION_NAME_DECLS,
CTI_VOID_ZERO,
CTI_NULL,
CTI_MAX
@ -430,9 +428,6 @@ extern const unsigned int num_c_common_reswords;
#define c99_function_name_decl_node c_global_trees[CTI_C99_FUNCTION_NAME_DECL]
#define saved_function_name_decls c_global_trees[CTI_SAVED_FUNCTION_NAME_DECLS]
/* A node for `((void) 0)'. */
#define void_zero_node c_global_trees[CTI_VOID_ZERO]
/* The node for C++ `__null'. */
#define null_node c_global_trees[CTI_NULL]

View File

@ -906,6 +906,15 @@ pp_c_string_literal (c_pretty_printer *pp, tree s)
pp_doublequote (pp);
}
/* Pretty-print a VOID_CST (void_node). */
static void
pp_c_void_constant (c_pretty_printer *pp)
{
pp_c_type_cast (pp, void_type_node);
pp_string (pp, "0");
}
/* Pretty-print an INTEGER literal. */
static void
@ -1136,6 +1145,10 @@ c_pretty_printer::constant (tree e)
switch (code)
{
case VOID_CST:
pp_c_void_constant (this);
break;
case INTEGER_CST:
{
tree type = TREE_TYPE (e);
@ -1241,6 +1254,7 @@ c_pretty_printer::primary_expression (tree e)
translate_string ("<return-value>");
break;
case VOID_CST:
case INTEGER_CST:
case REAL_CST:
case FIXED_CST:
@ -2131,6 +2145,10 @@ c_pretty_printer::expression (tree e)
{
switch (TREE_CODE (e))
{
case VOID_CST:
pp_c_void_constant (this);
break;
case INTEGER_CST:
pp_c_integer_constant (this, e);
break;

View File

@ -95,7 +95,7 @@ ubsan_instrument_division (location_t loc, tree op0, tree op1)
tt = build_call_expr_loc (loc, tt, 3, data, ubsan_encode_value (op0),
ubsan_encode_value (op1));
}
t = fold_build3 (COND_EXPR, void_type_node, t, tt, void_zero_node);
t = fold_build3 (COND_EXPR, void_type_node, t, tt, void_node);
return t;
}
@ -178,7 +178,7 @@ ubsan_instrument_shift (location_t loc, enum tree_code code,
tt = build_call_expr_loc (loc, tt, 3, data, ubsan_encode_value (op0),
ubsan_encode_value (op1));
}
t = fold_build3 (COND_EXPR, void_type_node, t, tt, void_zero_node);
t = fold_build3 (COND_EXPR, void_type_node, t, tt, void_node);
return t;
}
@ -207,7 +207,7 @@ ubsan_instrument_vla (location_t loc, tree size)
tt = builtin_decl_explicit (bcode);
tt = build_call_expr_loc (loc, tt, 2, data, ubsan_encode_value (size));
}
t = fold_build3 (COND_EXPR, void_type_node, t, tt, void_zero_node);
t = fold_build3 (COND_EXPR, void_type_node, t, tt, void_node);
return t;
}

View File

@ -997,6 +997,7 @@ extract_free_variables (tree t, struct wrapper_data *wd,
{
case ERROR_MARK:
case IDENTIFIER_NODE:
case VOID_CST:
case INTEGER_CST:
case REAL_CST:
case FIXED_CST:

View File

@ -1,3 +1,8 @@
2014-05-21 Richard Sandiford <rsandifo@linux.vnet.ibm.com>
* c-array-notation.c (expand_array_notations): Use void_node
instead of void_zero_node.
2014-05-17 Trevor Saunders <tsaunders@mozilla.com>
* c-decl.c (finish_struct): Adjust.

View File

@ -1279,7 +1279,7 @@ expand_array_notations (tree *tp, int *walk_subtrees, void *)
A[x:y:z];
A[x:y];
Replace those with just void zero node. */
*tp = void_zero_node;
*tp = void_node;
default:
break;
}

View File

@ -1,3 +1,25 @@
2014-05-21 Richard Sandiford <rsandifo@linux.vnet.ibm.com>
* cvt.c (convert_to_void): Use void_node instead of void_zero_node.
* cp-array-notation.c (replace_invariant_exprs): Likewise.
(expand_array_notation): Handle VOID_CST.
* error.c (dump_expr): Likewise.
* cxx-pretty-print.c (cxx_pretty_printer::primary_expression)
(cxx_pretty_printer::expression): Likewise.
(pp_cxx_new_expression): Use void_node instead of void_zero_node.
* decl.c (register_dtor_fn): Likewise.
* init.c (build_raw_new_expr, build_new_1, build_vec_init)
(build_delete, push_base_cleanups): Likewise.
* mangle.c (write_expression): Likewise.
* semantics.c (finish_break_stmt, empty_expr_stmt_p): Likewise.
* pt.c (tsubst_decl, tsubst_copy_and_build): Likewise.
(tsubst, tsubst_copy, build_non_dependent_expr): Handle VOID_CST.
* tree.c (cp_tree_equal): Likewise.
(build_dummy_object, is_dummy_object, stabilize_expr): Use void_node
instead of void_zero_node.
* typeck.c (check_return_expr): Likewise.
* typeck2.c (build_functional_cast): Likewise.
2014-05-21 Igor Zamyatin <igor.zamyatin@intel.com>
PR c/60189

View File

@ -181,7 +181,7 @@ replace_invariant_exprs (tree *node)
if (VOID_TYPE_P (TREE_TYPE (t)))
{
finish_expr_stmt (t);
new_var = void_zero_node;
new_var = void_node;
}
else
new_var = get_temp_regvar (TREE_TYPE (t), t);
@ -1126,6 +1126,7 @@ expand_array_notation_exprs (tree t)
{
case ERROR_MARK:
case IDENTIFIER_NODE:
case VOID_CST:
case INTEGER_CST:
case REAL_CST:
case FIXED_CST:

View File

@ -1285,7 +1285,7 @@ convert_to_void (tree expr, impl_conv_void implicit, tsubst_flags_t complain)
}
else
return error_mark_node;
expr = void_zero_node;
expr = void_node;
}
else if (implicit != ICV_CAST && probe == expr && is_overloaded_fn (probe))
{
@ -1415,7 +1415,7 @@ convert_to_void (tree expr, impl_conv_void implicit, tsubst_flags_t complain)
expr = build1 (CONVERT_EXPR, void_type_node, expr);
}
if (! TREE_SIDE_EFFECTS (expr))
expr = void_zero_node;
expr = void_node;
return expr;
}

View File

@ -403,6 +403,7 @@ cxx_pretty_printer::primary_expression (tree t)
{
switch (TREE_CODE (t))
{
case VOID_CST:
case INTEGER_CST:
case REAL_CST:
case COMPLEX_CST:
@ -690,7 +691,7 @@ pp_cxx_new_expression (cxx_pretty_printer *pp, tree t)
pp_left_paren (pp);
if (TREE_CODE (init) == TREE_LIST)
pp_c_expression_list (pp, init);
else if (init == void_zero_node)
else if (init == void_node)
; /* OK, empty initializer list. */
else
pp->expression (init);
@ -1028,6 +1029,7 @@ cxx_pretty_printer::expression (tree t)
switch (TREE_CODE (t))
{
case STRING_CST:
case VOID_CST:
case INTEGER_CST:
case REAL_CST:
case COMPLEX_CST:

View File

@ -6830,7 +6830,7 @@ register_dtor_fn (tree decl)
type = TREE_TYPE (decl);
if (TYPE_HAS_TRIVIAL_DESTRUCTOR (type))
return void_zero_node;
return void_node;
/* If we're using "__cxa_atexit" (or "__cxa_thread_atexit" or
"__aeabi_atexit"), and DECL is a class object, we can just pass the
@ -7077,7 +7077,7 @@ expand_static_init (tree decl, tree init)
TARGET_EXPR_CLEANUP (begin)
= build3 (COND_EXPR, void_type_node, flag,
void_zero_node,
void_node,
build_call_n (abort_fn, 1, guard_addr));
CLEANUP_EH_ONLY (begin) = 1;
@ -8425,7 +8425,7 @@ compute_array_index_type (tree name, tree size, tsubst_flags_t complain)
tree comp = build2 (LT_EXPR, boolean_type_node, itype,
ssize_int (-1));
comp = build3 (COND_EXPR, void_type_node, comp,
throw_bad_array_length (), void_zero_node);
throw_bad_array_length (), void_node);
finish_expr_stmt (comp);
}
else if (flag_sanitize & SANITIZE_VLA)

View File

@ -1913,6 +1913,7 @@ dump_expr (cxx_pretty_printer *pp, tree t, int flags)
pp_cxx_ws_string (pp, M_("<unknown>"));
break;
case VOID_CST:
case INTEGER_CST:
case REAL_CST:
case STRING_CST:

View File

@ -2120,7 +2120,7 @@ build_raw_new_expr (vec<tree, va_gc> *placement, tree type, tree nelts,
if (init == NULL)
init_list = NULL_TREE;
else if (init->is_empty ())
init_list = void_zero_node;
init_list = void_node;
else
init_list = build_tree_list_vec (init);
@ -2935,7 +2935,7 @@ build_new_1 (vec<tree, va_gc> **placement, tree type, tree nelts,
TARGET_EXPR_CLEANUP (begin)
= build3 (COND_EXPR, void_type_node, sentry,
cleanup, void_zero_node);
cleanup, void_node);
end = build2 (MODIFY_EXPR, TREE_TYPE (sentry),
sentry, boolean_false_node);
@ -3598,7 +3598,7 @@ build_vec_init (tree base, tree maxindex, tree init,
else
throw_call = throw_bad_array_new_length ();
length_check = build3 (COND_EXPR, void_type_node, length_check,
throw_call, void_zero_node);
throw_call, void_node);
finish_expr_stmt (length_check);
}
@ -4020,7 +4020,7 @@ build_delete (tree otype, tree addr, special_function_kind auto_delete,
}
if (auto_delete != sfk_deleting_destructor)
return void_zero_node;
return void_node;
return build_op_delete_call (DELETE_EXPR, addr,
cxx_sizeof_nowarn (type),
@ -4108,8 +4108,7 @@ build_delete (tree otype, tree addr, special_function_kind auto_delete,
}
if (ifexp != integer_one_node)
expr = build3 (COND_EXPR, void_type_node,
ifexp, expr, void_zero_node);
expr = build3 (COND_EXPR, void_type_node, ifexp, expr, void_node);
return expr;
}
@ -4154,7 +4153,7 @@ push_base_cleanups (void)
if (TYPE_HAS_NONTRIVIAL_DESTRUCTOR (BINFO_TYPE (base_binfo)))
{
expr = build3 (COND_EXPR, void_type_node, cond,
expr, void_zero_node);
expr, void_node);
finish_decl_cleanup (NULL_TREE, expr);
}
}

View File

@ -2812,7 +2812,7 @@ write_expression (tree expr)
{
if (init)
write_string ("pi");
if (init && init != void_zero_node)
if (init && init != void_node)
for (t = init; t; t = TREE_CHAIN (t))
write_expression (TREE_VALUE (t));
write_char ('E');

View File

@ -10911,7 +10911,7 @@ tsubst_decl (tree t, tree args, tsubst_flags_t complain)
/* Set up DECL_TEMPLATE_INFO so that we can get at the
NSDMI in perform_member_init. Still set DECL_INITIAL
so that we know there is one. */
DECL_INITIAL (r) = void_zero_node;
DECL_INITIAL (r) = void_node;
gcc_assert (DECL_LANG_SPECIFIC (r) == NULL);
retrofit_lang_decl (r);
DECL_TEMPLATE_INFO (r) = build_template_info (t, args);
@ -12286,6 +12286,7 @@ tsubst (tree t, tree args, tsubst_flags_t complain, tree in_decl)
}
break;
case VOID_CST:
case INTEGER_CST:
case REAL_CST:
case STRING_CST:
@ -13054,6 +13055,10 @@ tsubst_copy (tree t, tree args, tsubst_flags_t complain, tree in_decl)
error ("use %<...%> to expand argument pack");
return error_mark_node;
case VOID_CST:
gcc_checking_assert (t == void_node && VOID_TYPE_P (TREE_TYPE (t)));
return t;
case INTEGER_CST:
case REAL_CST:
case STRING_CST:
@ -14600,7 +14605,7 @@ tsubst_copy_and_build (tree t,
else
{
init_vec = make_tree_vector ();
if (init == void_zero_node)
if (init == void_node)
gcc_assert (init_vec != NULL);
else
{
@ -15261,9 +15266,9 @@ tsubst_copy_and_build (tree t,
cur_stmt_expr = old_stmt_expr;
/* If the resulting list of expression statement is empty,
fold it further into void_zero_node. */
fold it further into void_node. */
if (empty_expr_stmt_p (stmt_expr))
stmt_expr = void_zero_node;
stmt_expr = void_node;
RETURN (stmt_expr);
}
@ -21550,9 +21555,11 @@ build_non_dependent_expr (tree expr)
cannot be used to initialize a "char *". */
if (TREE_CODE (expr) == STRING_CST)
return expr;
/* Preserve arithmetic constants, as an optimization -- there is no
/* Preserve void and arithmetic constants, as an optimization -- there is no
reason to create a new node. */
if (TREE_CODE (expr) == INTEGER_CST || TREE_CODE (expr) == REAL_CST)
if (TREE_CODE (expr) == VOID_CST
|| TREE_CODE (expr) == INTEGER_CST
|| TREE_CODE (expr) == REAL_CST)
return expr;
/* Preserve THROW_EXPRs -- all throw-expressions have type "void".
There is at least one place where we want to know that a

View File

@ -1083,7 +1083,7 @@ finish_break_stmt (void)
block_may_fallthru returns true when given something it does not
understand. */
if (!block_may_fallthru (cur_stmt_list))
return void_zero_node;
return void_node;
return add_stmt (build_stmt (input_location, BREAK_STMT));
}
@ -2095,7 +2095,7 @@ empty_expr_stmt_p (tree expr_stmt)
{
tree body = NULL_TREE;
if (expr_stmt == void_zero_node)
if (expr_stmt == void_node)
return true;
if (expr_stmt)

View File

@ -2620,6 +2620,11 @@ cp_tree_equal (tree t1, tree t2)
switch (code1)
{
case VOID_CST:
/* There's only a single VOID_CST node, so we should never reach
here. */
gcc_unreachable ();
case INTEGER_CST:
return tree_int_cst_equal (t1, t2);
@ -2947,7 +2952,7 @@ member_p (const_tree decl)
tree
build_dummy_object (tree type)
{
tree decl = build1 (NOP_EXPR, build_pointer_type (type), void_zero_node);
tree decl = build1 (NOP_EXPR, build_pointer_type (type), void_node);
return cp_build_indirect_ref (decl, RO_NULL, tf_warning_or_error);
}
@ -2997,7 +3002,7 @@ is_dummy_object (const_tree ob)
if (INDIRECT_REF_P (ob))
ob = TREE_OPERAND (ob, 0);
return (TREE_CODE (ob) == NOP_EXPR
&& TREE_OPERAND (ob, 0) == void_zero_node);
&& TREE_OPERAND (ob, 0) == void_node);
}
/* Returns 1 iff type T is something we want to treat as a scalar type for
@ -3775,7 +3780,7 @@ stabilize_expr (tree exp, tree* initp)
else if (VOID_TYPE_P (TREE_TYPE (exp)))
{
init_expr = exp;
exp = void_zero_node;
exp = void_node;
}
/* There are no expressions with REFERENCE_TYPE, but there can be call
arguments with such a type; just treat it as a pointer. */

View File

@ -8424,7 +8424,7 @@ check_return_expr (tree retval, bool *no_warning)
else
{
if (!retval)
retval = void_zero_node;
retval = void_node;
auto_node = type_uses_auto (current_function_auto_return_pattern);
type = do_auto_deduction (current_function_auto_return_pattern,
retval, auto_node);

View File

@ -1888,7 +1888,7 @@ build_functional_cast (tree exp, tree parms, tsubst_flags_t complain)
if (parms == NULL_TREE)
{
if (VOID_TYPE_P (type))
return void_zero_node;
return void_node;
return build_value_init (cv_unqualified (type), complain);
}

View File

@ -410,6 +410,8 @@ enum tree_index {
TI_UINT32_TYPE,
TI_UINT64_TYPE,
TI_VOID,
TI_INTEGER_ZERO,
TI_INTEGER_ONE,
TI_INTEGER_THREE,

View File

@ -383,6 +383,7 @@ tree_node_structure_for_code (enum tree_code code)
switch (code)
{
/* tcc_constant cases. */
case VOID_CST: return TS_TYPED;
case INTEGER_CST: return TS_INT_CST;
case REAL_CST: return TS_REAL_CST;
case FIXED_CST: return TS_FIXED_CST;
@ -652,6 +653,7 @@ tree_code_size (enum tree_code code)
case tcc_constant: /* a constant */
switch (code)
{
case VOID_CST: return sizeof (struct tree_typed);
case INTEGER_CST: gcc_unreachable ();
case REAL_CST: return sizeof (struct tree_real_cst);
case FIXED_CST: return sizeof (struct tree_fixed_cst);
@ -7360,6 +7362,8 @@ iterative_hash_expr (const_tree t, hashval_t val)
{
/* Alas, constants aren't shared, so we can't rely on pointer
identity. */
case VOID_CST:
return iterative_hash_hashval_t (0, val);
case INTEGER_CST:
for (i = 0; i < TREE_INT_CST_NUNITS (t); i++)
val = iterative_hash_host_wide_int (TREE_INT_CST_ELT (t, i), val);
@ -9631,6 +9635,9 @@ build_common_tree_nodes (bool signed_char, bool short_double)
TYPE_ALIGN (void_type_node) = BITS_PER_UNIT;
TYPE_USER_ALIGN (void_type_node) = 0;
void_node = make_node (VOID_CST);
TREE_TYPE (void_node) = void_type_node;
null_pointer_node = build_int_cst (build_pointer_type (void_type_node), 0);
layout_type (TREE_TYPE (null_pointer_node));

View File

@ -257,6 +257,8 @@ DEFTREECODE (LANG_TYPE, "lang_type", tcc_type, 0)
/* First, the constants. */
DEFTREECODE (VOID_CST, "void_cst", tcc_constant, 0)
/* Contents are in an array of HOST_WIDE_INTs.
We often access these constants both in their native precision and

View File

@ -3246,6 +3246,8 @@ tree_operand_check_code (const_tree __t, enum tree_code __code, int __i,
#define uint32_type_node global_trees[TI_UINT32_TYPE]
#define uint64_type_node global_trees[TI_UINT64_TYPE]
#define void_node global_trees[TI_VOID]
#define integer_zero_node global_trees[TI_INTEGER_ZERO]
#define integer_one_node global_trees[TI_INTEGER_ONE]
#define integer_three_node global_trees[TI_INTEGER_THREE]