* 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
+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.
/* 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;
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. */
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);
+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.
{
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:
/* 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. */
|| 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))
{
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;
}
}
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;
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)
"array declarator");
array_ptr_quals = TYPE_UNQUALIFIED;
array_ptr_attrs = NULL_TREE;
- array_parm_static = 0;
+ array_parm_static = false;
}
orig_qual_indirect++;
break;
{
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. */
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)
if (DECL_NAME (x)
|| RECORD_OR_UNION_TYPE_P (TREE_TYPE (x)))
- saw_named_field = 1;
+ saw_named_field = true;
}
detect_field_duplicates (fieldlist);
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)
{
cause a syntax error. */
if (decl1 == NULL_TREE
|| TREE_CODE (decl1) != FUNCTION_DECL)
- return 0;
+ return false;
loc = DECL_SOURCE_LOCATION (decl1);
start_fname_decls ();
- return 1;
+ return true;
}
\f
/* Subroutine of store_parm_decls which handles new-style function
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:
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,
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);
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 *);
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)
}
/* 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)
{
/* 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)
{
last_init_list_comma),
true, braced_init_obstack);
constructor_designated = 1;
- return 0;
+ return false;
}
switch (TREE_CODE (constructor_type))
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