Commit e3455240 by Marek Polacek Committed by Marek Polacek

c-common.c (self_promoting_args_p): Change the return type to bool.

	* c-common.c (self_promoting_args_p): Change the return type to bool.
	Use false/true instead of 0/1.
	* c-common.h (self_promoting_args_p): Update.

	* c-decl.c (start_decl): Use false/true instead of 0/1.
	(grokdeclarator): Likewise.
	(finish_struct): Likewise.
	(start_function): Change the return type to bool.  Use false/true
	instead of 0/1.
	(declspecs_add_qual): Use UNKNOWN_LOCATION instead of 0.
	* c-tree.h (start_function): Update.
	* c-typeck.c (same_translation_unit_p): Change the return type to bool.
	(set_designator): Change the return type to bool.  Use false/true
	instead of 0/1.

From-SVN: r248192
parent 59a4ede9
2017-05-18 Marek Polacek <polacek@redhat.com>
* c-common.c (self_promoting_args_p): Change the return type to bool.
Use false/true instead of 0/1.
* c-common.h (self_promoting_args_p): Update.
2017-05-17 Marek Polacek <polacek@redhat.com> 2017-05-17 Marek Polacek <polacek@redhat.com>
* c-common.c: Use NULL_TREE instead of 0 where appropriate. * c-common.c: Use NULL_TREE instead of 0 where appropriate.
......
...@@ -4640,7 +4640,7 @@ c_promoting_integer_type_p (const_tree t) ...@@ -4640,7 +4640,7 @@ c_promoting_integer_type_p (const_tree t)
/* Return 1 if PARMS specifies a fixed number of parameters /* Return 1 if PARMS specifies a fixed number of parameters
and none of their types is affected by default promotions. */ and none of their types is affected by default promotions. */
int bool
self_promoting_args_p (const_tree parms) self_promoting_args_p (const_tree parms)
{ {
const_tree t; const_tree t;
...@@ -4652,18 +4652,18 @@ self_promoting_args_p (const_tree parms) ...@@ -4652,18 +4652,18 @@ self_promoting_args_p (const_tree parms)
continue; continue;
if (TREE_CHAIN (t) == NULL_TREE && type != void_type_node) if (TREE_CHAIN (t) == NULL_TREE && type != void_type_node)
return 0; return false;
if (type == NULL_TREE) if (type == NULL_TREE)
return 0; return false;
if (TYPE_MAIN_VARIANT (type) == float_type_node) if (TYPE_MAIN_VARIANT (type) == float_type_node)
return 0; return false;
if (c_promoting_integer_type_p (type)) if (c_promoting_integer_type_p (type))
return 0; return false;
} }
return 1; return true;
} }
/* Recursively remove any '*' or '&' operator from TYPE. */ /* Recursively remove any '*' or '&' operator from TYPE. */
......
...@@ -908,7 +908,7 @@ extern FILE *get_dump_info (int, dump_flags_t *); ...@@ -908,7 +908,7 @@ extern FILE *get_dump_info (int, dump_flags_t *);
extern alias_set_type c_common_get_alias_set (tree); extern alias_set_type c_common_get_alias_set (tree);
extern void c_register_builtin_type (tree, const char*); extern void c_register_builtin_type (tree, const char*);
extern bool c_promoting_integer_type_p (const_tree); extern bool c_promoting_integer_type_p (const_tree);
extern int self_promoting_args_p (const_tree); extern bool self_promoting_args_p (const_tree);
extern tree strip_pointer_operator (tree); extern tree strip_pointer_operator (tree);
extern tree strip_pointer_or_array_types (tree); extern tree strip_pointer_or_array_types (tree);
extern HOST_WIDE_INT c_common_to_target_charset (HOST_WIDE_INT); extern HOST_WIDE_INT c_common_to_target_charset (HOST_WIDE_INT);
......
2017-05-18 Marek Polacek <polacek@redhat.com>
* c-decl.c (start_decl): Use false/true instead of 0/1.
(grokdeclarator): Likewise.
(finish_struct): Likewise.
(start_function): Change the return type to bool. Use false/true
instead of 0/1.
(declspecs_add_qual): Use UNKNOWN_LOCATION instead of 0.
* c-tree.h (start_function): Update.
* c-typeck.c (same_translation_unit_p): Change the return type to bool.
(set_designator): Change the return type to bool. Use false/true
instead of 0/1.
2017-05-17 Marek Polacek <polacek@redhat.com> 2017-05-17 Marek Polacek <polacek@redhat.com>
* c-decl.c: Use NULL_TREE instead of 0 where appropriate. * c-decl.c: Use NULL_TREE instead of 0 where appropriate.
......
...@@ -4663,18 +4663,18 @@ start_decl (struct c_declarator *declarator, struct c_declspecs *declspecs, ...@@ -4663,18 +4663,18 @@ start_decl (struct c_declarator *declarator, struct c_declspecs *declspecs,
{ {
case TYPE_DECL: case TYPE_DECL:
error ("typedef %qD is initialized (use __typeof__ instead)", decl); error ("typedef %qD is initialized (use __typeof__ instead)", decl);
initialized = 0; initialized = false;
break; break;
case FUNCTION_DECL: case FUNCTION_DECL:
error ("function %qD is initialized like a variable", decl); error ("function %qD is initialized like a variable", decl);
initialized = 0; initialized = false;
break; break;
case PARM_DECL: case PARM_DECL:
/* DECL_INITIAL in a PARM_DECL is really DECL_ARG_TYPE. */ /* DECL_INITIAL in a PARM_DECL is really DECL_ARG_TYPE. */
error ("parameter %qD is initialized", decl); error ("parameter %qD is initialized", decl);
initialized = 0; initialized = false;
break; break;
default: default:
...@@ -4684,7 +4684,7 @@ start_decl (struct c_declarator *declarator, struct c_declspecs *declspecs, ...@@ -4684,7 +4684,7 @@ start_decl (struct c_declarator *declarator, struct c_declspecs *declspecs,
/* This can happen if the array size is an undefined macro. /* This can happen if the array size is an undefined macro.
We already gave a warning, so we don't need another one. */ We already gave a warning, so we don't need another one. */
if (TREE_TYPE (decl) == error_mark_node) if (TREE_TYPE (decl) == error_mark_node)
initialized = 0; initialized = false;
else if (COMPLETE_TYPE_P (TREE_TYPE (decl))) else if (COMPLETE_TYPE_P (TREE_TYPE (decl)))
{ {
/* A complete type is ok if size is fixed. */ /* A complete type is ok if size is fixed. */
...@@ -4693,13 +4693,13 @@ start_decl (struct c_declarator *declarator, struct c_declspecs *declspecs, ...@@ -4693,13 +4693,13 @@ start_decl (struct c_declarator *declarator, struct c_declspecs *declspecs,
|| C_DECL_VARIABLE_SIZE (decl)) || C_DECL_VARIABLE_SIZE (decl))
{ {
error ("variable-sized object may not be initialized"); error ("variable-sized object may not be initialized");
initialized = 0; initialized = false;
} }
} }
else if (TREE_CODE (TREE_TYPE (decl)) != ARRAY_TYPE) else if (TREE_CODE (TREE_TYPE (decl)) != ARRAY_TYPE)
{ {
error ("variable %qD has initializer but incomplete type", decl); error ("variable %qD has initializer but incomplete type", decl);
initialized = 0; initialized = false;
} }
else if (C_DECL_VARIABLE_SIZE (decl)) else if (C_DECL_VARIABLE_SIZE (decl))
{ {
...@@ -4708,7 +4708,7 @@ start_decl (struct c_declarator *declarator, struct c_declspecs *declspecs, ...@@ -4708,7 +4708,7 @@ start_decl (struct c_declarator *declarator, struct c_declspecs *declspecs,
sense to permit them to be initialized given that sense to permit them to be initialized given that
ordinary VLAs may not be initialized. */ ordinary VLAs may not be initialized. */
error ("variable-sized object may not be initialized"); error ("variable-sized object may not be initialized");
initialized = 0; initialized = false;
} }
} }
...@@ -5573,7 +5573,7 @@ grokdeclarator (const struct c_declarator *declarator, ...@@ -5573,7 +5573,7 @@ grokdeclarator (const struct c_declarator *declarator,
tree decl_attr = declspecs->decl_attr; tree decl_attr = declspecs->decl_attr;
int array_ptr_quals = TYPE_UNQUALIFIED; int array_ptr_quals = TYPE_UNQUALIFIED;
tree array_ptr_attrs = NULL_TREE; tree array_ptr_attrs = NULL_TREE;
int array_parm_static = 0; bool array_parm_static = false;
bool array_parm_vla_unspec_p = false; bool array_parm_vla_unspec_p = false;
tree returned_attrs = NULL_TREE; tree returned_attrs = NULL_TREE;
bool bitfield = width != NULL; bool bitfield = width != NULL;
...@@ -5907,7 +5907,7 @@ grokdeclarator (const struct c_declarator *declarator, ...@@ -5907,7 +5907,7 @@ grokdeclarator (const struct c_declarator *declarator,
error_at (loc, "static or type qualifiers in non-parameter array declarator"); error_at (loc, "static or type qualifiers in non-parameter array declarator");
array_ptr_quals = TYPE_UNQUALIFIED; array_ptr_quals = TYPE_UNQUALIFIED;
array_ptr_attrs = NULL_TREE; array_ptr_attrs = NULL_TREE;
array_parm_static = 0; array_parm_static = false;
} }
switch (declarator->kind) switch (declarator->kind)
...@@ -6277,7 +6277,7 @@ grokdeclarator (const struct c_declarator *declarator, ...@@ -6277,7 +6277,7 @@ grokdeclarator (const struct c_declarator *declarator,
"array declarator"); "array declarator");
array_ptr_quals = TYPE_UNQUALIFIED; array_ptr_quals = TYPE_UNQUALIFIED;
array_ptr_attrs = NULL_TREE; array_ptr_attrs = NULL_TREE;
array_parm_static = 0; array_parm_static = false;
} }
orig_qual_indirect++; orig_qual_indirect++;
break; break;
...@@ -7862,7 +7862,6 @@ finish_struct (location_t loc, tree t, tree fieldlist, tree attributes, ...@@ -7862,7 +7862,6 @@ finish_struct (location_t loc, tree t, tree fieldlist, tree attributes,
{ {
tree x; tree x;
bool toplevel = file_scope == current_scope; bool toplevel = file_scope == current_scope;
int saw_named_field;
/* If this type was previously laid out as a forward reference, /* If this type was previously laid out as a forward reference,
make sure we lay it out again. */ make sure we lay it out again. */
...@@ -7907,7 +7906,7 @@ finish_struct (location_t loc, tree t, tree fieldlist, tree attributes, ...@@ -7907,7 +7906,7 @@ finish_struct (location_t loc, tree t, tree fieldlist, tree attributes,
type. (Correct layout requires the original type to have been preserved type. (Correct layout requires the original type to have been preserved
until now.) */ until now.) */
saw_named_field = 0; bool saw_named_field = false;
for (x = fieldlist; x; x = DECL_CHAIN (x)) for (x = fieldlist; x; x = DECL_CHAIN (x))
{ {
if (TREE_TYPE (x) == error_mark_node) if (TREE_TYPE (x) == error_mark_node)
...@@ -7982,7 +7981,7 @@ finish_struct (location_t loc, tree t, tree fieldlist, tree attributes, ...@@ -7982,7 +7981,7 @@ finish_struct (location_t loc, tree t, tree fieldlist, tree attributes,
if (DECL_NAME (x) if (DECL_NAME (x)
|| RECORD_OR_UNION_TYPE_P (TREE_TYPE (x))) || RECORD_OR_UNION_TYPE_P (TREE_TYPE (x)))
saw_named_field = 1; saw_named_field = true;
} }
detect_field_duplicates (fieldlist); detect_field_duplicates (fieldlist);
...@@ -8518,11 +8517,10 @@ build_enumerator (location_t decl_loc, location_t loc, ...@@ -8518,11 +8517,10 @@ build_enumerator (location_t decl_loc, location_t loc,
This function creates a binding context for the function body This function creates a binding context for the function body
as well as setting up the FUNCTION_DECL in current_function_decl. as well as setting up the FUNCTION_DECL in current_function_decl.
Returns 1 on success. If the DECLARATOR is not suitable for a function Returns true on success. If the DECLARATOR is not suitable for a function
(it defines a datum instead), we return 0, which tells (it defines a datum instead), we return false to report a parse error. */
yyparse to report a parse error. */
int bool
start_function (struct c_declspecs *declspecs, struct c_declarator *declarator, start_function (struct c_declspecs *declspecs, struct c_declarator *declarator,
tree attributes) tree attributes)
{ {
...@@ -8549,7 +8547,7 @@ start_function (struct c_declspecs *declspecs, struct c_declarator *declarator, ...@@ -8549,7 +8547,7 @@ start_function (struct c_declspecs *declspecs, struct c_declarator *declarator,
cause a syntax error. */ cause a syntax error. */
if (decl1 == NULL_TREE if (decl1 == NULL_TREE
|| TREE_CODE (decl1) != FUNCTION_DECL) || TREE_CODE (decl1) != FUNCTION_DECL)
return 0; return false;
loc = DECL_SOURCE_LOCATION (decl1); loc = DECL_SOURCE_LOCATION (decl1);
...@@ -8749,7 +8747,7 @@ start_function (struct c_declspecs *declspecs, struct c_declarator *declarator, ...@@ -8749,7 +8747,7 @@ start_function (struct c_declspecs *declspecs, struct c_declarator *declarator,
start_fname_decls (); start_fname_decls ();
return 1; return true;
} }
/* Subroutine of store_parm_decls which handles new-style function /* Subroutine of store_parm_decls which handles new-style function
...@@ -9773,7 +9771,7 @@ declspecs_add_qual (source_location loc, ...@@ -9773,7 +9771,7 @@ declspecs_add_qual (source_location loc,
gcc_assert (TREE_CODE (qual) == IDENTIFIER_NODE gcc_assert (TREE_CODE (qual) == IDENTIFIER_NODE
&& C_IS_RESERVED_WORD (qual)); && C_IS_RESERVED_WORD (qual));
i = C_RID_CODE (qual); i = C_RID_CODE (qual);
location_t prev_loc = 0; location_t prev_loc = UNKNOWN_LOCATION;
switch (i) switch (i)
{ {
case RID_CONST: case RID_CONST:
......
...@@ -561,7 +561,7 @@ extern tree c_builtin_function_ext_scope (tree); ...@@ -561,7 +561,7 @@ extern tree c_builtin_function_ext_scope (tree);
extern void shadow_tag (const struct c_declspecs *); extern void shadow_tag (const struct c_declspecs *);
extern void shadow_tag_warned (const struct c_declspecs *, int); extern void shadow_tag_warned (const struct c_declspecs *, int);
extern tree start_enum (location_t, struct c_enum_contents *, tree); extern tree start_enum (location_t, struct c_enum_contents *, tree);
extern int start_function (struct c_declspecs *, struct c_declarator *, tree); extern bool start_function (struct c_declspecs *, struct c_declarator *, tree);
extern tree start_decl (struct c_declarator *, struct c_declspecs *, bool, extern tree start_decl (struct c_declarator *, struct c_declspecs *, bool,
tree); tree);
extern tree start_struct (location_t, enum tree_code, tree, extern tree start_struct (location_t, enum tree_code, tree,
...@@ -616,7 +616,7 @@ extern struct c_switch *c_switch_stack; ...@@ -616,7 +616,7 @@ extern struct c_switch *c_switch_stack;
extern tree c_objc_common_truthvalue_conversion (location_t, tree); extern tree c_objc_common_truthvalue_conversion (location_t, tree);
extern tree require_complete_type (location_t, tree); extern tree require_complete_type (location_t, tree);
extern int same_translation_unit_p (const_tree, const_tree); extern bool same_translation_unit_p (const_tree, const_tree);
extern int comptypes (tree, tree); extern int comptypes (tree, tree);
extern int comptypes_check_different_types (tree, tree, bool *); extern int comptypes_check_different_types (tree, tree, bool *);
extern bool c_vla_type_p (const_tree); extern bool c_vla_type_p (const_tree);
......
...@@ -105,7 +105,7 @@ static tree digest_init (location_t, tree, tree, tree, bool, bool, int); ...@@ -105,7 +105,7 @@ 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, int,
bool, struct obstack *); bool, struct obstack *);
static void output_pending_init_elements (int, struct obstack *); static void output_pending_init_elements (int, struct obstack *);
static int set_designator (location_t, int, struct obstack *); static bool set_designator (location_t, int, struct obstack *);
static void push_range_stack (tree, struct obstack *); static void push_range_stack (tree, struct obstack *);
static void add_pending_init (location_t, tree, tree, tree, bool, static void add_pending_init (location_t, tree, tree, tree, bool,
struct obstack *); struct obstack *);
...@@ -1306,7 +1306,8 @@ comp_target_types (location_t location, tree ttl, tree ttr) ...@@ -1306,7 +1306,8 @@ comp_target_types (location_t location, tree ttl, tree ttr)
If the CONTEXT chain ends in a null, that tree's context is still If the CONTEXT chain ends in a null, that tree's context is still
being parsed, so if two trees have context chains ending in null, being parsed, so if two trees have context chains ending in null,
they're in the same translation unit. */ they're in the same translation unit. */
int
bool
same_translation_unit_p (const_tree t1, const_tree t2) same_translation_unit_p (const_tree t1, const_tree t2)
{ {
while (t1 && TREE_CODE (t1) != TRANSLATION_UNIT_DECL) while (t1 && TREE_CODE (t1) != TRANSLATION_UNIT_DECL)
...@@ -8176,9 +8177,9 @@ pop_init_level (location_t loc, int implicit, ...@@ -8176,9 +8177,9 @@ pop_init_level (location_t loc, int implicit,
} }
/* Common handling for both array range and field name designators. /* Common handling for both array range and field name designators.
ARRAY argument is nonzero for array ranges. Returns zero for success. */ ARRAY argument is nonzero for array ranges. Returns false for success. */
static int static bool
set_designator (location_t loc, int array, set_designator (location_t loc, int array,
struct obstack *braced_init_obstack) struct obstack *braced_init_obstack)
{ {
...@@ -8188,12 +8189,12 @@ set_designator (location_t loc, int array, ...@@ -8188,12 +8189,12 @@ set_designator (location_t loc, int array,
/* Don't die if an entire brace-pair level is superfluous /* Don't die if an entire brace-pair level is superfluous
in the containing level. */ in the containing level. */
if (constructor_type == NULL_TREE) if (constructor_type == NULL_TREE)
return 1; return true;
/* If there were errors in this designator list already, bail out /* If there were errors in this designator list already, bail out
silently. */ silently. */
if (designator_erroneous) if (designator_erroneous)
return 1; return true;
if (!designator_depth) if (!designator_depth)
{ {
...@@ -8207,7 +8208,7 @@ set_designator (location_t loc, int array, ...@@ -8207,7 +8208,7 @@ set_designator (location_t loc, int array,
last_init_list_comma), last_init_list_comma),
true, braced_init_obstack); true, braced_init_obstack);
constructor_designated = 1; constructor_designated = 1;
return 0; return false;
} }
switch (TREE_CODE (constructor_type)) switch (TREE_CODE (constructor_type))
...@@ -8229,18 +8230,18 @@ set_designator (location_t loc, int array, ...@@ -8229,18 +8230,18 @@ set_designator (location_t loc, int array,
if (array && subcode != ARRAY_TYPE) if (array && subcode != ARRAY_TYPE)
{ {
error_init (loc, "array index in non-array initializer"); error_init (loc, "array index in non-array initializer");
return 1; return true;
} }
else if (!array && subcode != RECORD_TYPE && subcode != UNION_TYPE) else if (!array && subcode != RECORD_TYPE && subcode != UNION_TYPE)
{ {
error_init (loc, "field name not in record or union initializer"); error_init (loc, "field name not in record or union initializer");
return 1; return true;
} }
constructor_designated = 1; constructor_designated = 1;
finish_implicit_inits (loc, braced_init_obstack); finish_implicit_inits (loc, braced_init_obstack);
push_init_level (loc, 2, braced_init_obstack); push_init_level (loc, 2, braced_init_obstack);
return 0; return false;
} }
/* If there are range designators in designator list, push a new designator /* If there are range designators in designator list, push a new designator
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment