diff options
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/c-family/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/c-family/c-common.c | 12 | ||||
-rw-r--r-- | gcc/c-family/c-common.h | 2 | ||||
-rw-r--r-- | gcc/c/ChangeLog | 13 | ||||
-rw-r--r-- | gcc/c/c-decl.c | 38 | ||||
-rw-r--r-- | gcc/c/c-tree.h | 4 | ||||
-rw-r--r-- | gcc/c/c-typeck.c | 21 |
7 files changed, 57 insertions, 39 deletions
diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index 28c97be..23a6afe 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,9 @@ +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> * c-common.c: Use NULL_TREE instead of 0 where appropriate. diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c index bd9b512..a9e2408 100644 --- a/gcc/c-family/c-common.c +++ b/gcc/c-family/c-common.c @@ -4640,7 +4640,7 @@ c_promoting_integer_type_p (const_tree t) /* Return 1 if PARMS specifies a fixed number of parameters and none of their types is affected by default promotions. */ -int +bool self_promoting_args_p (const_tree parms) { const_tree t; @@ -4652,18 +4652,18 @@ self_promoting_args_p (const_tree parms) continue; if (TREE_CHAIN (t) == NULL_TREE && type != void_type_node) - return 0; + return false; if (type == NULL_TREE) - return 0; + return false; if (TYPE_MAIN_VARIANT (type) == float_type_node) - return 0; + return false; if (c_promoting_integer_type_p (type)) - return 0; + return false; } - return 1; + return true; } /* Recursively remove any '*' or '&' operator from TYPE. */ diff --git a/gcc/c-family/c-common.h b/gcc/c-family/c-common.h index 3023b07..502dc2f 100644 --- a/gcc/c-family/c-common.h +++ b/gcc/c-family/c-common.h @@ -908,7 +908,7 @@ extern FILE *get_dump_info (int, dump_flags_t *); extern alias_set_type c_common_get_alias_set (tree); extern void c_register_builtin_type (tree, const char*); 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_or_array_types (tree); extern HOST_WIDE_INT c_common_to_target_charset (HOST_WIDE_INT); diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index 8d55031..4dbeedf 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,16 @@ +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> * c-decl.c: Use NULL_TREE instead of 0 where appropriate. diff --git a/gcc/c/c-decl.c b/gcc/c/c-decl.c index 55fc53e..52d89f8 100644 --- a/gcc/c/c-decl.c +++ b/gcc/c/c-decl.c @@ -4663,18 +4663,18 @@ start_decl (struct c_declarator *declarator, struct c_declspecs *declspecs, { case TYPE_DECL: error ("typedef %qD is initialized (use __typeof__ instead)", decl); - initialized = 0; + initialized = false; break; case FUNCTION_DECL: error ("function %qD is initialized like a variable", decl); - initialized = 0; + initialized = false; break; case PARM_DECL: /* DECL_INITIAL in a PARM_DECL is really DECL_ARG_TYPE. */ error ("parameter %qD is initialized", decl); - initialized = 0; + initialized = false; break; default: @@ -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. We already gave a warning, so we don't need another one. */ if (TREE_TYPE (decl) == error_mark_node) - initialized = 0; + initialized = false; else if (COMPLETE_TYPE_P (TREE_TYPE (decl))) { /* A complete type is ok if size is fixed. */ @@ -4693,13 +4693,13 @@ start_decl (struct c_declarator *declarator, struct c_declspecs *declspecs, || C_DECL_VARIABLE_SIZE (decl)) { error ("variable-sized object may not be initialized"); - initialized = 0; + initialized = false; } } else if (TREE_CODE (TREE_TYPE (decl)) != ARRAY_TYPE) { error ("variable %qD has initializer but incomplete type", decl); - initialized = 0; + initialized = false; } else if (C_DECL_VARIABLE_SIZE (decl)) { @@ -4708,7 +4708,7 @@ start_decl (struct c_declarator *declarator, struct c_declspecs *declspecs, sense to permit them to be initialized given that ordinary VLAs 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, tree decl_attr = declspecs->decl_attr; int array_ptr_quals = TYPE_UNQUALIFIED; tree array_ptr_attrs = NULL_TREE; - int array_parm_static = 0; + bool array_parm_static = false; bool array_parm_vla_unspec_p = false; tree returned_attrs = NULL_TREE; bool bitfield = width != NULL; @@ -5907,7 +5907,7 @@ grokdeclarator (const struct c_declarator *declarator, error_at (loc, "static or type qualifiers in non-parameter array declarator"); array_ptr_quals = TYPE_UNQUALIFIED; array_ptr_attrs = NULL_TREE; - array_parm_static = 0; + array_parm_static = false; } switch (declarator->kind) @@ -6277,7 +6277,7 @@ grokdeclarator (const struct c_declarator *declarator, "array declarator"); array_ptr_quals = TYPE_UNQUALIFIED; array_ptr_attrs = NULL_TREE; - array_parm_static = 0; + array_parm_static = false; } orig_qual_indirect++; break; @@ -7862,7 +7862,6 @@ finish_struct (location_t loc, tree t, tree fieldlist, tree attributes, { tree x; bool toplevel = file_scope == current_scope; - int saw_named_field; /* If this type was previously laid out as a forward reference, make sure we lay it out again. */ @@ -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 until now.) */ - saw_named_field = 0; + bool saw_named_field = false; for (x = fieldlist; x; x = DECL_CHAIN (x)) { if (TREE_TYPE (x) == error_mark_node) @@ -7982,7 +7981,7 @@ finish_struct (location_t loc, tree t, tree fieldlist, tree attributes, if (DECL_NAME (x) || RECORD_OR_UNION_TYPE_P (TREE_TYPE (x))) - saw_named_field = 1; + saw_named_field = true; } detect_field_duplicates (fieldlist); @@ -8518,11 +8517,10 @@ build_enumerator (location_t decl_loc, location_t loc, This function creates a binding context for the function body 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 - (it defines a datum instead), we return 0, which tells - yyparse to report a parse error. */ + Returns true on success. If the DECLARATOR is not suitable for a function + (it defines a datum instead), we return false to report a parse error. */ -int +bool start_function (struct c_declspecs *declspecs, struct c_declarator *declarator, tree attributes) { @@ -8549,7 +8547,7 @@ start_function (struct c_declspecs *declspecs, struct c_declarator *declarator, cause a syntax error. */ if (decl1 == NULL_TREE || TREE_CODE (decl1) != FUNCTION_DECL) - return 0; + return false; loc = DECL_SOURCE_LOCATION (decl1); @@ -8749,7 +8747,7 @@ start_function (struct c_declspecs *declspecs, struct c_declarator *declarator, start_fname_decls (); - return 1; + return true; } /* Subroutine of store_parm_decls which handles new-style function @@ -9773,7 +9771,7 @@ declspecs_add_qual (source_location loc, gcc_assert (TREE_CODE (qual) == IDENTIFIER_NODE && C_IS_RESERVED_WORD (qual)); i = C_RID_CODE (qual); - location_t prev_loc = 0; + location_t prev_loc = UNKNOWN_LOCATION; switch (i) { case RID_CONST: diff --git a/gcc/c/c-tree.h b/gcc/c/c-tree.h index 42172f8..17a8897 100644 --- a/gcc/c/c-tree.h +++ b/gcc/c/c-tree.h @@ -561,7 +561,7 @@ extern tree c_builtin_function_ext_scope (tree); extern void shadow_tag (const struct c_declspecs *); extern void shadow_tag_warned (const struct c_declspecs *, int); 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, tree); extern tree start_struct (location_t, enum tree_code, tree, @@ -616,7 +616,7 @@ extern struct c_switch *c_switch_stack; extern tree c_objc_common_truthvalue_conversion (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_check_different_types (tree, tree, bool *); extern bool c_vla_type_p (const_tree); diff --git a/gcc/c/c-typeck.c b/gcc/c/c-typeck.c index 4c75c32..96f7a5c 100644 --- a/gcc/c/c-typeck.c +++ b/gcc/c/c-typeck.c @@ -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, bool, 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 add_pending_init (location_t, tree, tree, tree, bool, struct obstack *); @@ -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 being parsed, so if two trees have context chains ending in null, they're in the same translation unit. */ -int + +bool same_translation_unit_p (const_tree t1, const_tree t2) { while (t1 && TREE_CODE (t1) != TRANSLATION_UNIT_DECL) @@ -8176,9 +8177,9 @@ pop_init_level (location_t loc, int implicit, } /* 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, struct obstack *braced_init_obstack) { @@ -8188,12 +8189,12 @@ set_designator (location_t loc, int array, /* Don't die if an entire brace-pair level is superfluous in the containing level. */ if (constructor_type == NULL_TREE) - return 1; + return true; /* If there were errors in this designator list already, bail out silently. */ if (designator_erroneous) - return 1; + return true; if (!designator_depth) { @@ -8207,7 +8208,7 @@ set_designator (location_t loc, int array, last_init_list_comma), true, braced_init_obstack); constructor_designated = 1; - return 0; + return false; } switch (TREE_CODE (constructor_type)) @@ -8229,18 +8230,18 @@ set_designator (location_t loc, int array, if (array && subcode != ARRAY_TYPE) { error_init (loc, "array index in non-array initializer"); - return 1; + return true; } else if (!array && subcode != RECORD_TYPE && subcode != UNION_TYPE) { error_init (loc, "field name not in record or union initializer"); - return 1; + return true; } constructor_designated = 1; finish_implicit_inits (loc, 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 |