* C PATCH to boolify a few parameters
@ 2017-08-09 12:32 Marek Polacek
0 siblings, 0 replies; only message in thread
From: Marek Polacek @ 2017-08-09 12:32 UTC (permalink / raw)
To: GCC Patches
Bool bool bool.
Bootstrapped/regtested on x86_64-linux, applying to trunk.
2017-08-09 Marek Polacek <polacek@redhat.com>
* c-common.c (pointer_int_sum): Use true/false instead of 1/0.
(c_common_truthvalue_conversion): Likewise.
* c-omp.c (c_finish_omp_atomic): Likewise.
* c-common.h (build_binary_op): Update declaration.
* c-decl.c (build_enumerator): Use true/false instead of 1/0.
* c-tree.h (build_external_ref): Update declaration.
* c-typeck.c (build_array_ref): Use true/false instead of 1/0.
(build_external_ref): Change the type of a parameter to bool.
(parser_build_binary_op): Use true/false instead of 1/0.
(pointer_diff): Likewise.
(build_modify_expr): Likewise.
(set_designator): Change the type of a parameter to bool.
(set_init_index): Use true/false instead of 1/0.
(set_init_label): Likewise.
(output_init_element): Change the type of a parameter to bool.
(output_pending_init_elements): Use true/false instead of 1/0.
(process_init_element): Likewise.
(build_binary_op): Change the type of a parameter to bool.
* parser.c (cp_parser_perform_range_for_lookup): Use false instead of
0.
* typeck.c (build_binary_op): Change the type of a parameter to bool.
(cp_truthvalue_conversion): Use true instead of 1.
diff --git gcc/c-family/c-common.c gcc/c-family/c-common.c
index feb0904bcbf..a9c0614b436 100644
--- gcc/c-family/c-common.c
+++ gcc/c-family/c-common.c
@@ -3133,7 +3133,8 @@ pointer_int_sum (location_t loc, enum tree_code resultcode,
can result in a sum or difference with different type args. */
ptrop = build_binary_op (EXPR_LOCATION (TREE_OPERAND (intop, 1)),
subcode, ptrop,
- convert (int_type, TREE_OPERAND (intop, 1)), 1);
+ convert (int_type, TREE_OPERAND (intop, 1)),
+ true);
intop = convert (int_type, TREE_OPERAND (intop, 0));
}
@@ -3306,7 +3307,7 @@ c_common_truthvalue_conversion (location_t location, tree expr)
TREE_OPERAND (expr, 0)),
c_common_truthvalue_conversion (location,
TREE_OPERAND (expr, 1)),
- 0);
+ false);
goto ret;
case NEGATE_EXPR:
@@ -3457,7 +3458,7 @@ c_common_truthvalue_conversion (location_t location, tree expr)
c_common_truthvalue_conversion
(location,
build_unary_op (location, IMAGPART_EXPR, t, false)),
- 0));
+ false));
goto ret;
}
@@ -3466,10 +3467,10 @@ c_common_truthvalue_conversion (location_t location, tree expr)
tree fixed_zero_node = build_fixed (TREE_TYPE (expr),
FCONST0 (TYPE_MODE
(TREE_TYPE (expr))));
- return build_binary_op (location, NE_EXPR, expr, fixed_zero_node, 1);
+ return build_binary_op (location, NE_EXPR, expr, fixed_zero_node, true);
}
else
- return build_binary_op (location, NE_EXPR, expr, integer_zero_node, 1);
+ return build_binary_op (location, NE_EXPR, expr, integer_zero_node, true);
ret:
protected_set_expr_location (expr, location);
diff --git gcc/c-family/c-common.h gcc/c-family/c-common.h
index a29f1ade25d..b44e1bd78d6 100644
--- gcc/c-family/c-common.h
+++ gcc/c-family/c-common.h
@@ -960,7 +960,7 @@ extern tree build_real_imag_expr (location_t, enum tree_code, tree);
a variant of the C language. They are used in c-common.c. */
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 build_binary_op (location_t, enum tree_code, tree, tree, bool);
extern tree perform_integral_promotions (tree);
/* These functions must be defined by each front-end which implements
diff --git gcc/c-family/c-omp.c gcc/c-family/c-omp.c
index 900f5a33943..eef7ac0c769 100644
--- gcc/c-family/c-omp.c
+++ gcc/c-family/c-omp.c
@@ -276,14 +276,14 @@ c_finish_omp_atomic (location_t loc, enum tree_code code,
lhs = build3_loc (loc, BIT_FIELD_REF, TREE_TYPE (blhs), lhs,
bitsize_int (bitsize), bitsize_int (bitpos));
if (swapped)
- rhs = build_binary_op (loc, opcode, rhs, lhs, 1);
+ rhs = build_binary_op (loc, opcode, rhs, lhs, true);
else if (opcode != NOP_EXPR)
- rhs = build_binary_op (loc, opcode, lhs, rhs, 1);
+ rhs = build_binary_op (loc, opcode, lhs, rhs, true);
opcode = NOP_EXPR;
}
else if (swapped)
{
- rhs = build_binary_op (loc, opcode, rhs, lhs, 1);
+ rhs = build_binary_op (loc, opcode, rhs, lhs, true);
opcode = NOP_EXPR;
}
bool save = in_late_binary_op;
diff --git gcc/c/c-decl.c gcc/c/c-decl.c
index a54e1218434..d21fbc5883e 100644
--- gcc/c/c-decl.c
+++ gcc/c/c-decl.c
@@ -8475,7 +8475,7 @@ build_enumerator (location_t decl_loc, location_t loc,
/* Set basis for default for next value. */
the_enum->enum_next_value
= build_binary_op (EXPR_LOC_OR_LOC (value, input_location),
- PLUS_EXPR, value, integer_one_node, 0);
+ PLUS_EXPR, value, integer_one_node, false);
the_enum->enum_overflow = tree_int_cst_lt (the_enum->enum_next_value, value);
/* Now create a declaration for the enum value name. */
diff --git gcc/c/c-tree.h gcc/c/c-tree.h
index be2f272d2dd..92bcc70653e 100644
--- gcc/c/c-tree.h
+++ gcc/c/c-tree.h
@@ -634,7 +634,7 @@ extern void mark_exp_read (tree);
extern tree composite_type (tree, tree);
extern tree build_component_ref (location_t, tree, tree, location_t);
extern tree build_array_ref (location_t, tree, tree);
-extern tree build_external_ref (location_t, tree, int, tree *);
+extern tree build_external_ref (location_t, tree, bool, tree *);
extern void pop_maybe_used (bool);
extern struct c_expr c_expr_sizeof_expr (location_t, struct c_expr);
extern struct c_expr c_expr_sizeof_type (location_t, struct c_type_name *);
diff --git gcc/c/c-typeck.c gcc/c/c-typeck.c
index 8033a8190f3..f66fe5398d3 100644
--- gcc/c/c-typeck.c
+++ gcc/c/c-typeck.c
@@ -106,10 +106,10 @@ static int spelling_length (void);
static char *print_spelling (char *);
static void warning_init (location_t, int, const char *);
static tree digest_init (location_t, tree, tree, tree, bool, bool, int);
-static void output_init_element (location_t, tree, tree, bool, tree, tree, int,
+static void output_init_element (location_t, tree, tree, bool, tree, tree, bool,
bool, struct obstack *);
static void output_pending_init_elements (int, struct obstack *);
-static bool set_designator (location_t, int, struct obstack *);
+static bool set_designator (location_t, bool, struct obstack *);
static void push_range_stack (tree, struct obstack *);
static void add_pending_init (location_t, tree, tree, tree, bool,
struct obstack *);
@@ -2723,7 +2723,7 @@ build_array_ref (location_t loc, tree array, tree index)
gcc_assert (TREE_CODE (TREE_TYPE (TREE_TYPE (ar))) != FUNCTION_TYPE);
ret = build_indirect_ref (loc, build_binary_op (loc, PLUS_EXPR, ar,
- index, 0),
+ index, false),
RO_ARRAY_INDEXING);
if (non_lvalue)
ret = non_lvalue_loc (loc, ret);
@@ -2738,7 +2738,7 @@ build_array_ref (location_t loc, tree array, tree index)
for CONST_DECLs defined as enum constants. If the type of the
identifier is not available, *TYPE is set to NULL. */
tree
-build_external_ref (location_t loc, tree id, int fun, tree *type)
+build_external_ref (location_t loc, tree id, bool fun, tree *type)
{
tree ref;
tree decl = lookup_name (id);
@@ -3642,7 +3642,7 @@ parser_build_binary_op (location_t location, enum tree_code code,
: TREE_TYPE (arg2.value));
result.value = build_binary_op (location, code,
- arg1.value, arg2.value, 1);
+ arg1.value, arg2.value, true);
result.original_code = code;
result.original_type = NULL;
@@ -3831,7 +3831,7 @@ pointer_diff (location_t loc, tree op0, tree op1)
op0 = build_binary_op (loc,
MINUS_EXPR, convert (inttype, op0),
- convert (inttype, op1), 0);
+ convert (inttype, op1), false);
/* This generates an error if op1 is pointer to incomplete type. */
if (!COMPLETE_OR_VOID_TYPE_P (TREE_TYPE (TREE_TYPE (orig_op1))))
error_at (loc, "arithmetic on pointer to an incomplete type");
@@ -4098,7 +4098,7 @@ cas_loop:
add_stmt (loop_label);
/* newval = old + val; */
- rhs = build_binary_op (loc, modifycode, old, val, 1);
+ rhs = build_binary_op (loc, modifycode, old, val, true);
rhs = c_fully_fold (rhs, false, NULL);
rhs = convert_for_assignment (loc, UNKNOWN_LOCATION, nonatomic_lhs_type,
rhs, NULL_TREE, ic_assign, false, NULL_TREE,
@@ -5796,7 +5796,7 @@ build_modify_expr (location_t location, tree lhs, tree lhs_origtype,
rhseval = newrhs;
}
newrhs = build_binary_op (location,
- modifycode, lhs, newrhs, 1);
+ modifycode, lhs, newrhs, true);
/* The original type of the right hand side is no longer
meaningful. */
@@ -8194,7 +8194,7 @@ pop_init_level (location_t loc, int implicit,
ARRAY argument is nonzero for array ranges. Returns false for success. */
static bool
-set_designator (location_t loc, int array,
+set_designator (location_t loc, bool array,
struct obstack *braced_init_obstack)
{
tree subtype;
@@ -8290,7 +8290,7 @@ void
set_init_index (location_t loc, tree first, tree last,
struct obstack *braced_init_obstack)
{
- if (set_designator (loc, 1, braced_init_obstack))
+ if (set_designator (loc, true, braced_init_obstack))
return;
designator_erroneous = 1;
@@ -8380,7 +8380,7 @@ set_init_label (location_t loc, tree fieldname, location_t fieldname_loc,
{
tree field;
- if (set_designator (loc, 0, braced_init_obstack))
+ if (set_designator (loc, false, braced_init_obstack))
return;
designator_erroneous = 1;
@@ -8420,7 +8420,7 @@ set_init_label (location_t loc, tree fieldname, location_t fieldname_loc,
field = TREE_CHAIN (field);
if (field)
{
- if (set_designator (loc, 0, braced_init_obstack))
+ if (set_designator (loc, false, braced_init_obstack))
return;
}
}
@@ -8853,9 +8853,9 @@ find_init_member (tree field, struct obstack * braced_init_obstack)
unparenthesized or we should not warn here for it being parenthesized.
For other types of VALUE, STRICT_STRING is not used.
- PENDING if non-nil means output pending elements that belong
- right after this element. (PENDING is normally 1;
- it is 0 while outputting pending elements, to avoid recursion.)
+ PENDING if true means output pending elements that belong
+ right after this element. (PENDING is normally true;
+ it is false while outputting pending elements, to avoid recursion.)
IMPLICIT is true if value comes from pop_init_level (1),
the new initializer has been merged with the existing one
@@ -8864,7 +8864,7 @@ find_init_member (tree field, struct obstack * braced_init_obstack)
static void
output_init_element (location_t loc, tree value, tree origtype,
- bool strict_string, tree type, tree field, int pending,
+ bool strict_string, tree type, tree field, bool pending,
bool implicit, struct obstack * braced_init_obstack)
{
tree semantic_type = NULL_TREE;
@@ -9107,7 +9107,7 @@ output_pending_init_elements (int all, struct obstack * braced_init_obstack)
constructor_unfilled_index))
output_init_element (input_location, elt->value, elt->origtype,
true, TREE_TYPE (constructor_type),
- constructor_unfilled_index, 0, false,
+ constructor_unfilled_index, false, false,
braced_init_obstack);
else if (tree_int_cst_lt (constructor_unfilled_index,
elt->purpose))
@@ -9161,7 +9161,7 @@ output_pending_init_elements (int all, struct obstack * braced_init_obstack)
constructor_unfilled_fields = elt->purpose;
output_init_element (input_location, elt->value, elt->origtype,
true, TREE_TYPE (elt->purpose),
- elt->purpose, 0, false,
+ elt->purpose, false, false,
braced_init_obstack);
}
else if (tree_int_cst_lt (ctor_unfilled_bitpos, elt_bitpos))
@@ -9405,7 +9405,7 @@ process_init_element (location_t loc, struct c_expr value, bool implicit,
push_member_name (constructor_fields);
output_init_element (loc, value.value, value.original_type,
strict_string, fieldtype,
- constructor_fields, 1, implicit,
+ constructor_fields, true, implicit,
braced_init_obstack);
RESTORE_SPELLING_DEPTH (constructor_depth);
}
@@ -9497,7 +9497,7 @@ process_init_element (location_t loc, struct c_expr value, bool implicit,
push_member_name (constructor_fields);
output_init_element (loc, value.value, value.original_type,
strict_string, fieldtype,
- constructor_fields, 1, implicit,
+ constructor_fields, true, implicit,
braced_init_obstack);
RESTORE_SPELLING_DEPTH (constructor_depth);
}
@@ -9549,7 +9549,7 @@ process_init_element (location_t loc, struct c_expr value, bool implicit,
push_array_bounds (tree_to_uhwi (constructor_index));
output_init_element (loc, value.value, value.original_type,
strict_string, elttype,
- constructor_index, 1, implicit,
+ constructor_index, true, implicit,
braced_init_obstack);
RESTORE_SPELLING_DEPTH (constructor_depth);
}
@@ -9584,7 +9584,7 @@ process_init_element (location_t loc, struct c_expr value, bool implicit,
elttype = TYPE_MAIN_VARIANT (constructor_type);
output_init_element (loc, value.value, value.original_type,
strict_string, elttype,
- constructor_index, 1, implicit,
+ constructor_index, true, implicit,
braced_init_obstack);
}
@@ -9613,7 +9613,7 @@ process_init_element (location_t loc, struct c_expr value, bool implicit,
if (value.value)
output_init_element (loc, value.value, value.original_type,
strict_string, constructor_type,
- NULL_TREE, 1, implicit,
+ NULL_TREE, true, implicit,
braced_init_obstack);
constructor_fields = NULL_TREE;
}
@@ -10745,7 +10745,7 @@ build_vec_cmp (tree_code code, tree type,
tree
build_binary_op (location_t location, enum tree_code code,
- tree orig_op0, tree orig_op1, int convert_p)
+ tree orig_op0, tree orig_op1, bool convert_p)
{
tree type0, type1, orig_type0, orig_type1;
tree eptype;
diff --git gcc/cp/parser.c gcc/cp/parser.c
index 23bd2784ea4..28f32888312 100644
--- gcc/cp/parser.c
+++ gcc/cp/parser.c
@@ -11925,7 +11925,7 @@ cp_parser_perform_range_for_lookup (tree range, tree *begin, tree *end)
*end = build_binary_op (input_location, PLUS_EXPR,
range,
array_type_nelts_top (TREE_TYPE (range)),
- 0);
+ false);
return TREE_TYPE (*begin);
}
else
diff --git gcc/cp/typeck.c gcc/cp/typeck.c
index 074dae2dfee..3ce39061010 100644
--- gcc/cp/typeck.c
+++ gcc/cp/typeck.c
@@ -4050,7 +4050,7 @@ enum_cast_to_int (tree op)
/* For the c-common bits. */
tree
build_binary_op (location_t location, enum tree_code code, tree op0, tree op1,
- int /*convert_p*/)
+ bool /*convert_p*/)
{
return cp_build_binary_op (location, code, op0, op1, tf_warning_or_error);
}
@@ -5592,7 +5592,7 @@ cp_truthvalue_conversion (tree expr)
if (TYPE_PTR_OR_PTRMEM_P (type)
/* Avoid ICE on invalid use of non-static member function. */
|| TREE_CODE (expr) == FUNCTION_DECL)
- return build_binary_op (input_location, NE_EXPR, expr, nullptr_node, 1);
+ return build_binary_op (input_location, NE_EXPR, expr, nullptr_node, true);
else
return c_common_truthvalue_conversion (input_location, expr);
}
Marek
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2017-08-09 12:32 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-09 12:32 C PATCH to boolify a few parameters Marek Polacek
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).