* c-common.c (c_common_truthvalue_conversion): Use false instead of 0.
* c-common.h (build_unary_op): Change nonconvert parameter type to bool.
* c-omp.c (c_finish_omp_atomic): Use false instead of 0.
* c-array-notation.c (create_cmp_incr): Use false instead of 0.
(fix_array_notation_expr): Likewise.
* c-decl.c (finish_decl): Likewise.
* c-parser.c (c_parser_postfix_expression_after_primary): Likewise.
* c-typeck.c (array_to_pointer_conversion): Use true instead of 1.
(function_to_pointer_conversion): Use false instead of 0.
(convert_lvalue_to_rvalue): Likewise.
(parser_build_unary_op): Likewise.
(build_atomic_assign): Likewise.
(build_unary_op): Change nonconvert parameter type to bool, use
true/false instead of 1/0.
(build_binary_op): Use true instead of 1.
* cp-tree.h (cp_build_unary_op): Change nonconvert parameter type to
bool.
* decl2.c (one_static_initialization_or_destruction): Use true instead
of 1.
* init.c (build_vec_init): Use false instead of 0.
* pt.c (tsubst_copy_and_build): Likewise.
* semantics.c (simplify_loop_decl_cond): Likewise.
* typeck.c (rationalize_conditional_expr): Likewise.
(cp_build_binary_op): Use true instead of 1.
(cp_build_unary_op): Change nonconvert parameter type to bool. Use true
instead of 1.
(build_unary_op): Change nonconvert parameter type to bool.
(unary_complex_lvalue): Use false instead of 0.
From-SVN: r240137
+2016-09-14 Marek Polacek <polacek@redhat.com>
+
+ * c-common.c (c_common_truthvalue_conversion): Use false instead of 0.
+ * c-common.h (build_unary_op): Change nonconvert parameter type to bool.
+ * c-omp.c (c_finish_omp_atomic): Use false instead of 0.
+
2016-09-13 David Malcolm <dmalcolm@redhat.com>
* c-common.c (warn_logical_not_parentheses): Replace
: truthvalue_false_node;
case FUNCTION_DECL:
- expr = build_unary_op (location, ADDR_EXPR, expr, 0);
+ expr = build_unary_op (location, ADDR_EXPR, expr, false);
/* Fall through. */
case ADDR_EXPR:
? TRUTH_OR_EXPR : TRUTH_ORIF_EXPR),
c_common_truthvalue_conversion
(location,
- build_unary_op (location, REALPART_EXPR, t, 0)),
+ build_unary_op (location, REALPART_EXPR, t, false)),
c_common_truthvalue_conversion
(location,
- build_unary_op (location, IMAGPART_EXPR, t, 0)),
+ build_unary_op (location, IMAGPART_EXPR, t, false)),
0));
goto ret;
}
/* These functions must be defined by each front-end which implements
a variant of the C language. They are used in c-common.c. */
-extern tree build_unary_op (location_t, enum tree_code, tree, int);
+extern tree build_unary_op (location_t, enum tree_code, tree, bool);
extern tree build_binary_op (location_t, enum tree_code, tree, tree, int);
extern tree perform_integral_promotions (tree);
/* Take and save the address of the lhs. From then on we'll reference it
via indirection. */
- addr = build_unary_op (loc, ADDR_EXPR, lhs, 0);
+ addr = build_unary_op (loc, ADDR_EXPR, lhs, false);
if (addr == error_mark_node)
return error_mark_node;
if (!test)
loc, x, NULL_TREE);
if (rhs1 && rhs1 != lhs)
{
- tree rhs1addr = build_unary_op (loc, ADDR_EXPR, rhs1, 0);
+ tree rhs1addr = build_unary_op (loc, ADDR_EXPR, rhs1, false);
if (rhs1addr == error_mark_node)
return error_mark_node;
x = omit_one_operand_loc (loc, type, x, rhs1addr);
}
if (lhs1 && lhs1 != lhs)
{
- tree lhs1addr = build_unary_op (loc, ADDR_EXPR, lhs1, 0);
+ tree lhs1addr = build_unary_op (loc, ADDR_EXPR, lhs1, false);
if (lhs1addr == error_mark_node)
return error_mark_node;
if (code == OMP_ATOMIC_CAPTURE_OLD)
}
else if (rhs1 && rhs1 != lhs)
{
- tree rhs1addr = build_unary_op (loc, ADDR_EXPR, rhs1, 0);
+ tree rhs1addr = build_unary_op (loc, ADDR_EXPR, rhs1, false);
if (rhs1addr == error_mark_node)
return error_mark_node;
x = omit_one_operand_loc (loc, type, x, rhs1addr);
+2016-09-14 Marek Polacek <polacek@redhat.com>
+
+ * c-array-notation.c (create_cmp_incr): Use false instead of 0.
+ (fix_array_notation_expr): Likewise.
+ * c-decl.c (finish_decl): Likewise.
+ * c-parser.c (c_parser_postfix_expression_after_primary): Likewise.
+ * c-typeck.c (array_to_pointer_conversion): Use true instead of 1.
+ (function_to_pointer_conversion): Use false instead of 0.
+ (convert_lvalue_to_rvalue): Likewise.
+ (parser_build_unary_op): Likewise.
+ (build_atomic_assign): Likewise.
+ (build_unary_op): Change nonconvert parameter type to bool, use
+ true/false instead of 1/0.
+ (build_binary_op): Use true instead of 1.
+
2016-09-13 David Malcolm <dmalcolm@redhat.com>
* c-parser.c (c_parser_declaration_or_fndef): Update for renaming
{
tree var = (*node)[ii].var;
tree length = an_info[0][ii].length;
- (*node)[ii].incr = build_unary_op (loc, POSTINCREMENT_EXPR, var, 0);
+ (*node)[ii].incr = build_unary_op (loc, POSTINCREMENT_EXPR, var, false);
(*node)[ii].cmp = build2 (LT_EXPR, boolean_type_node, var, length);
}
}
arg = default_function_array_read_conversion (location, arg);
if (code == POSTINCREMENT_EXPR || code == POSTDECREMENT_EXPR)
- arg.value = build_unary_op (location, code, arg.value, 0);
+ arg.value = build_unary_op (location, code, arg.value, false);
else if (code == PREINCREMENT_EXPR || code == PREDECREMENT_EXPR)
arg = parser_build_unary_op (location, code, arg);
vec<tree, va_gc> *v;
/* Build "cleanup(&decl)" for the destructor. */
- cleanup = build_unary_op (input_location, ADDR_EXPR, decl, 0);
+ cleanup = build_unary_op (input_location, ADDR_EXPR, decl, false);
vec_alloc (v, 1);
v->quick_push (cleanup);
cleanup = c_build_function_call_vec (DECL_SOURCE_LOCATION (decl),
else
{
expr = default_function_array_read_conversion (expr_loc, expr);
- expr.value = build_unary_op (op_loc,
- POSTINCREMENT_EXPR, expr.value, 0);
+ expr.value = build_unary_op (op_loc, POSTINCREMENT_EXPR,
+ expr.value, false);
}
set_c_expr_source_range (&expr, start, finish);
expr.original_code = ERROR_MARK;
else
{
expr = default_function_array_read_conversion (expr_loc, expr);
- expr.value = build_unary_op (op_loc,
- POSTDECREMENT_EXPR, expr.value, 0);
+ expr.value = build_unary_op (op_loc, POSTDECREMENT_EXPR,
+ expr.value, false);
}
set_c_expr_source_range (&expr, start, finish);
expr.original_code = ERROR_MARK;
"is ill-formed in C++");
}
- adr = build_unary_op (loc, ADDR_EXPR, exp, 1);
+ adr = build_unary_op (loc, ADDR_EXPR, exp, true);
return convert (ptrtype, adr);
}
if (TREE_NO_WARNING (orig_exp))
TREE_NO_WARNING (exp) = 1;
- return build_unary_op (loc, ADDR_EXPR, exp, 0);
+ return build_unary_op (loc, ADDR_EXPR, exp, false);
}
/* Mark EXP as read, not just set, for set but not used -Wunused
vec<tree, va_gc> *params;
tree nonatomic_type, tmp, tmp_addr, fndecl, func_call;
tree expr_type = TREE_TYPE (exp.value);
- tree expr_addr = build_unary_op (loc, ADDR_EXPR, exp.value, 0);
+ tree expr_addr = build_unary_op (loc, ADDR_EXPR, exp.value, false);
tree seq_cst = build_int_cst (integer_type_node, MEMMODEL_SEQ_CST);
gcc_assert (TYPE_ATOMIC (expr_type));
create the VAL temp variable to hold the RHS. */
nonatomic_type = build_qualified_type (expr_type, TYPE_UNQUALIFIED);
tmp = create_tmp_var_raw (nonatomic_type);
- tmp_addr = build_unary_op (loc, ADDR_EXPR, tmp, 0);
+ tmp_addr = build_unary_op (loc, ADDR_EXPR, tmp, false);
TREE_ADDRESSABLE (tmp) = 1;
TREE_NO_WARNING (tmp) = 1;
}
else
{
- result.value = build_unary_op (loc, code, arg.value, 0);
+ result.value = build_unary_op (loc, code, arg.value, false);
if (TREE_OVERFLOW_P (result.value) && !TREE_OVERFLOW_P (arg.value))
overflow_warning (loc, result.value);
tree loop_label, loop_decl, done_label, done_decl;
tree lhs_type = TREE_TYPE (lhs);
- tree lhs_addr = build_unary_op (loc, ADDR_EXPR, lhs, 0);
+ tree lhs_addr = build_unary_op (loc, ADDR_EXPR, lhs, false);
tree seq_cst = build_int_cst (integer_type_node, MEMMODEL_SEQ_CST);
tree rhs_type = TREE_TYPE (rhs);
if (modifycode == NOP_EXPR)
{
/* Build __atomic_store (&lhs, &val, SEQ_CST) */
- rhs = build_unary_op (loc, ADDR_EXPR, val, 0);
+ rhs = build_unary_op (loc, ADDR_EXPR, val, false);
fndecl = builtin_decl_explicit (BUILT_IN_ATOMIC_STORE);
params->quick_push (lhs_addr);
params->quick_push (rhs);
cas_loop:
/* Create the variables and labels required for the op= form. */
old = create_tmp_var_raw (nonatomic_lhs_type);
- old_addr = build_unary_op (loc, ADDR_EXPR, old, 0);
+ old_addr = build_unary_op (loc, ADDR_EXPR, old, false);
TREE_ADDRESSABLE (old) = 1;
TREE_NO_WARNING (old) = 1;
newval = create_tmp_var_raw (nonatomic_lhs_type);
- newval_addr = build_unary_op (loc, ADDR_EXPR, newval, 0);
+ newval_addr = build_unary_op (loc, ADDR_EXPR, newval, false);
TREE_ADDRESSABLE (newval) = 1;
TREE_NO_WARNING (newval) = 1;
/* Construct and perhaps optimize a tree representation
for a unary operation. CODE, a tree_code, specifies the operation
and XARG is the operand.
- For any CODE other than ADDR_EXPR, NOCONVERT nonzero suppresses
- the default promotions (such as from short to int).
- For ADDR_EXPR, the default promotions are not applied; NOCONVERT nonzero
- allows non-lvalues; this is only used to handle conversion of non-lvalue
- arrays to pointers in C99.
+ For any CODE other than ADDR_EXPR, NOCONVERT suppresses the default
+ promotions (such as from short to int).
+ For ADDR_EXPR, the default promotions are not applied; NOCONVERT allows
+ non-lvalues; this is only used to handle conversion of non-lvalue arrays
+ to pointers in C99.
LOCATION is the location of the operator. */
tree
build_unary_op (location_t location, enum tree_code code, tree xarg,
- int noconvert)
+ bool noconvert)
{
/* No default_conversion here. It causes trouble for ADDR_EXPR. */
tree arg = xarg;
if (!atomic_op)
{
arg = stabilize_reference (arg);
- real = build_unary_op (EXPR_LOCATION (arg), REALPART_EXPR, arg, 1);
- imag = build_unary_op (EXPR_LOCATION (arg), IMAGPART_EXPR, arg, 1);
- real = build_unary_op (EXPR_LOCATION (arg), code, real, 1);
+ real = build_unary_op (EXPR_LOCATION (arg), REALPART_EXPR, arg,
+ true);
+ imag = build_unary_op (EXPR_LOCATION (arg), IMAGPART_EXPR, arg,
+ true);
+ real = build_unary_op (EXPR_LOCATION (arg), code, real, true);
if (real == error_mark_node || imag == error_mark_node)
return error_mark_node;
ret = build2 (COMPLEX_EXPR, TREE_TYPE (arg),
{
op0 = c_save_expr (op0);
real = build_unary_op (EXPR_LOCATION (orig_op0), REALPART_EXPR,
- op0, 1);
+ op0, true);
imag = build_unary_op (EXPR_LOCATION (orig_op0), IMAGPART_EXPR,
- op0, 1);
+ op0, true);
switch (code)
{
case MULT_EXPR:
{
op1 = c_save_expr (op1);
real = build_unary_op (EXPR_LOCATION (orig_op1), REALPART_EXPR,
- op1, 1);
+ op1, true);
imag = build_unary_op (EXPR_LOCATION (orig_op1), IMAGPART_EXPR,
- op1, 1);
+ op1, true);
switch (code)
{
case MULT_EXPR:
+2016-09-14 Marek Polacek <polacek@redhat.com>
+
+ * cp-tree.h (cp_build_unary_op): Change nonconvert parameter type to
+ bool.
+ * decl2.c (one_static_initialization_or_destruction): Use true instead
+ of 1.
+ * init.c (build_vec_init): Use false instead of 0.
+ * pt.c (tsubst_copy_and_build): Likewise.
+ * semantics.c (simplify_loop_decl_cond): Likewise.
+ * typeck.c (rationalize_conditional_expr): Likewise.
+ (cp_build_binary_op): Use true instead of 1.
+ (cp_build_unary_op): Change nonconvert parameter type to bool. Use true
+ instead of 1.
+ (build_unary_op): Change nonconvert parameter type to bool.
+ (unary_complex_lvalue): Use false instead of 0.
+
2016-09-13 Jakub Jelinek <jakub@redhat.com>
Implement P0028R4, C++17 using attribute namespaces without repetition
enum tree_code, cp_expr,
tsubst_flags_t);
extern tree cp_build_addr_expr (tree, tsubst_flags_t);
-extern tree cp_build_unary_op (enum tree_code, tree, int,
+extern tree cp_build_unary_op (enum tree_code, tree, bool,
tsubst_flags_t);
extern tree unary_complex_lvalue (enum tree_code, tree);
extern tree build_x_conditional_expr (location_t, tree, tree, tree,
EQ_EXPR,
cp_build_unary_op (PREINCREMENT_EXPR,
guard,
- /*noconvert=*/1,
+ /*noconvert=*/true,
tf_warning_or_error),
integer_one_node,
tf_warning_or_error);
EQ_EXPR,
cp_build_unary_op (PREDECREMENT_EXPR,
guard,
- /*noconvert=*/1,
+ /*noconvert=*/true,
tf_warning_or_error),
integer_zero_node,
tf_warning_or_error);
finish_expr_stmt (one_init);
current_stmt_tree ()->stmts_are_full_exprs_p = 0;
- one_init = cp_build_unary_op (PREINCREMENT_EXPR, base, 0, complain);
+ one_init = cp_build_unary_op (PREINCREMENT_EXPR, base, false,
+ complain);
if (one_init == error_mark_node)
errors = true;
else
finish_expr_stmt (one_init);
- one_init = cp_build_unary_op (PREDECREMENT_EXPR, iterator, 0,
+ one_init = cp_build_unary_op (PREDECREMENT_EXPR, iterator, false,
complain);
if (one_init == error_mark_node)
errors = true;
finish_for_cond (build2 (GT_EXPR, boolean_type_node, iterator,
build_int_cst (TREE_TYPE (iterator), -1)),
for_stmt, false);
- elt_init = cp_build_unary_op (PREDECREMENT_EXPR, iterator, 0,
+ elt_init = cp_build_unary_op (PREDECREMENT_EXPR, iterator, false,
complain);
if (elt_init == error_mark_node)
errors = true;
finish_expr_stmt (elt_init);
current_stmt_tree ()->stmts_are_full_exprs_p = 0;
- finish_expr_stmt (cp_build_unary_op (PREINCREMENT_EXPR, base, 0,
+ finish_expr_stmt (cp_build_unary_op (PREINCREMENT_EXPR, base, false,
complain));
if (base2)
- finish_expr_stmt (cp_build_unary_op (PREINCREMENT_EXPR, base2, 0,
+ finish_expr_stmt (cp_build_unary_op (PREINCREMENT_EXPR, base2, false,
complain));
finish_for_stmt (for_stmt);
case FIX_TRUNC_EXPR:
RETURN (cp_build_unary_op (FIX_TRUNC_EXPR, RECUR (TREE_OPERAND (t, 0)),
- 0, complain));
+ false, complain));
case ADDR_EXPR:
op1 = TREE_OPERAND (t, 0);
*cond_p = boolean_true_node;
if_stmt = begin_if_stmt ();
- cond = cp_build_unary_op (TRUTH_NOT_EXPR, cond, 0, tf_warning_or_error);
+ cond = cp_build_unary_op (TRUTH_NOT_EXPR, cond, false, tf_warning_or_error);
finish_if_stmt_cond (cond, if_stmt);
finish_break_stmt ();
finish_then_clause (if_stmt);
op1, TREE_CODE (op1),
/*overload=*/NULL,
complain),
- cp_build_unary_op (code, op0, 0, complain),
- cp_build_unary_op (code, op1, 0, complain),
+ cp_build_unary_op (code, op0, false, complain),
+ cp_build_unary_op (code, op1, false, complain),
complain);
}
return
build_conditional_expr (loc, TREE_OPERAND (t, 0),
- cp_build_unary_op (code, TREE_OPERAND (t, 1), 0,
+ cp_build_unary_op (code, TREE_OPERAND (t, 1), false,
complain),
- cp_build_unary_op (code, TREE_OPERAND (t, 2), 0,
+ cp_build_unary_op (code, TREE_OPERAND (t, 2), false,
complain),
complain);
}
if (first_complex)
{
op0 = save_expr (op0);
- real = cp_build_unary_op (REALPART_EXPR, op0, 1, complain);
- imag = cp_build_unary_op (IMAGPART_EXPR, op0, 1, complain);
+ real = cp_build_unary_op (REALPART_EXPR, op0, true, complain);
+ imag = cp_build_unary_op (IMAGPART_EXPR, op0, true, complain);
switch (code)
{
case MULT_EXPR:
else
{
op1 = save_expr (op1);
- real = cp_build_unary_op (REALPART_EXPR, op1, 1, complain);
- imag = cp_build_unary_op (IMAGPART_EXPR, op1, 1, complain);
+ real = cp_build_unary_op (REALPART_EXPR, op1, true, complain);
+ imag = cp_build_unary_op (IMAGPART_EXPR, op1, true, complain);
switch (code)
{
case MULT_EXPR:
from aggregates to types we don't yet know we want? (Or are those
cases typically errors which should be reported?)
- NOCONVERT nonzero suppresses the default promotions
- (such as from short to int). */
+ NOCONVERT suppresses the default promotions (such as from short to int). */
tree
-cp_build_unary_op (enum tree_code code, tree xarg, int noconvert,
+cp_build_unary_op (enum tree_code code, tree xarg, bool noconvert,
tsubst_flags_t complain)
{
/* No default_conversion here. It causes trouble for ADDR_EXPR. */
tree real, imag;
arg = cp_stabilize_reference (arg);
- real = cp_build_unary_op (REALPART_EXPR, arg, 1, complain);
- imag = cp_build_unary_op (IMAGPART_EXPR, arg, 1, complain);
- real = cp_build_unary_op (code, real, 1, complain);
+ real = cp_build_unary_op (REALPART_EXPR, arg, true, complain);
+ imag = cp_build_unary_op (IMAGPART_EXPR, arg, true, complain);
+ real = cp_build_unary_op (code, real, true, complain);
if (real == error_mark_node || imag == error_mark_node)
return error_mark_node;
return build2 (COMPLEX_EXPR, TREE_TYPE (arg),
/* Hook for the c-common bits that build a unary op. */
tree
build_unary_op (location_t /*location*/,
- enum tree_code code, tree xarg, int noconvert)
+ enum tree_code code, tree xarg, bool noconvert)
{
return cp_build_unary_op (code, xarg, noconvert, tf_warning_or_error);
}
/* Handle (a, b) used as an "lvalue". */
if (TREE_CODE (arg) == COMPOUND_EXPR)
{
- tree real_result = cp_build_unary_op (code, TREE_OPERAND (arg, 1), 0,
+ tree real_result = cp_build_unary_op (code, TREE_OPERAND (arg, 1), false,
tf_warning_or_error);
return build2 (COMPOUND_EXPR, TREE_TYPE (real_result),
TREE_OPERAND (arg, 0), real_result);
if (TREE_CODE (arg) == MODIFY_EXPR
|| TREE_CODE (arg) == INIT_EXPR)
{
- tree real_result = cp_build_unary_op (code, TREE_OPERAND (arg, 0), 0,
+ tree real_result = cp_build_unary_op (code, TREE_OPERAND (arg, 0), false,
tf_warning_or_error);
arg = build2 (COMPOUND_EXPR, TREE_TYPE (real_result),
arg, real_result);