diff options
Diffstat (limited to 'gcc/c/c-decl.c')
-rw-r--r-- | gcc/c/c-decl.c | 144 |
1 files changed, 73 insertions, 71 deletions
diff --git a/gcc/c/c-decl.c b/gcc/c/c-decl.c index bd6c4c1..55fc53e 100644 --- a/gcc/c/c-decl.c +++ b/gcc/c/c-decl.c @@ -809,7 +809,7 @@ c_finish_incomplete_decl (tree decl) if (type != error_mark_node && TREE_CODE (type) == ARRAY_TYPE && !DECL_EXTERNAL (decl) - && TYPE_DOMAIN (type) == 0) + && TYPE_DOMAIN (type) == NULL_TREE) { warning_at (DECL_SOURCE_LOCATION (decl), 0, "array %q+D assumed to have one element", decl); @@ -1146,7 +1146,7 @@ pop_scope (void) /* If appropriate, create a BLOCK to record the decls for the life of this function. */ - block = 0; + block = NULL_TREE; if (keep) { block = make_node (BLOCK); @@ -1157,7 +1157,7 @@ pop_scope (void) for (p = scope->blocks; p; p = BLOCK_CHAIN (p)) BLOCK_SUPERCONTEXT (p) = block; - BLOCK_VARS (block) = 0; + BLOCK_VARS (block) = NULL_TREE; } /* The TYPE_CONTEXTs for all of the tagged types belonging to this @@ -1230,9 +1230,9 @@ pop_scope (void) /* Propagate TREE_ADDRESSABLE from nested functions to their containing functions. */ if (!TREE_ASM_WRITTEN (p) - && DECL_INITIAL (p) != 0 + && DECL_INITIAL (p) != NULL_TREE && TREE_ADDRESSABLE (p) - && DECL_ABSTRACT_ORIGIN (p) != 0 + && DECL_ABSTRACT_ORIGIN (p) != NULL_TREE && DECL_ABSTRACT_ORIGIN (p) != p) TREE_ADDRESSABLE (DECL_ABSTRACT_ORIGIN (p)) = 1; if (!DECL_EXTERNAL (p) @@ -1677,18 +1677,18 @@ diagnose_arglist_conflict (tree newdecl, tree olddecl, if (TREE_CODE (olddecl) != FUNCTION_DECL || !comptypes (TREE_TYPE (oldtype), TREE_TYPE (newtype)) - || !((!prototype_p (oldtype) && DECL_INITIAL (olddecl) == 0) - || (!prototype_p (newtype) && DECL_INITIAL (newdecl) == 0))) + || !((!prototype_p (oldtype) && DECL_INITIAL (olddecl) == NULL_TREE) + || (!prototype_p (newtype) && DECL_INITIAL (newdecl) == NULL_TREE))) return; t = TYPE_ARG_TYPES (oldtype); - if (t == 0) + if (t == NULL_TREE) t = TYPE_ARG_TYPES (newtype); for (; t; t = TREE_CHAIN (t)) { tree type = TREE_VALUE (t); - if (TREE_CHAIN (t) == 0 + if (TREE_CHAIN (t) == NULL_TREE && TYPE_MAIN_VARIANT (type) != void_type_node) { inform (input_location, "a parameter list with an ellipsis can%'t match " @@ -2297,7 +2297,7 @@ static void merge_decls (tree newdecl, tree olddecl, tree newtype, tree oldtype) { bool new_is_definition = (TREE_CODE (newdecl) == FUNCTION_DECL - && DECL_INITIAL (newdecl) != 0); + && DECL_INITIAL (newdecl) != NULL_TREE); bool new_is_prototype = (TREE_CODE (newdecl) == FUNCTION_DECL && prototype_p (TREE_TYPE (newdecl))); bool old_is_prototype = (TREE_CODE (olddecl) == FUNCTION_DECL @@ -2412,13 +2412,14 @@ merge_decls (tree newdecl, tree olddecl, tree newtype, tree oldtype) && DECL_IN_SYSTEM_HEADER (newdecl) && !DECL_IN_SYSTEM_HEADER (olddecl)) DECL_SOURCE_LOCATION (olddecl) = DECL_SOURCE_LOCATION (newdecl); - else if ((DECL_INITIAL (newdecl) == 0 && DECL_INITIAL (olddecl) != 0) + else if ((DECL_INITIAL (newdecl) == NULL_TREE + && DECL_INITIAL (olddecl) != NULL_TREE) || (old_is_prototype && !new_is_prototype && !C_DECL_BUILTIN_PROTOTYPE (olddecl))) DECL_SOURCE_LOCATION (newdecl) = DECL_SOURCE_LOCATION (olddecl); /* Merge the initialization information. */ - if (DECL_INITIAL (newdecl) == 0) + if (DECL_INITIAL (newdecl) == NULL_TREE) DECL_INITIAL (newdecl) = DECL_INITIAL (olddecl); /* Merge the threadprivate attribute. */ @@ -2938,8 +2939,8 @@ pushdecl (tree x) if (DECL_EXTERNAL (x) || scope == file_scope) { tree type = TREE_TYPE (x); - tree vistype = 0; - tree visdecl = 0; + tree vistype = NULL_TREE; + tree visdecl = NULL_TREE; bool type_saved = false; if (b && !B_IN_EXTERNAL_SCOPE (b) && VAR_OR_FUNCTION_DECL_P (b->decl) @@ -3355,7 +3356,7 @@ tree implicitly_declare (location_t loc, tree functionid) { struct c_binding *b; - tree decl = 0; + tree decl = NULL_TREE; tree asmspec_tree; for (b = I_SYMBOL_BINDING (functionid); b; b = b->shadowed) @@ -3473,7 +3474,7 @@ undeclared_variable (location_t loc, tree id) static bool already = false; struct c_scope *scope; - if (current_function_decl == 0) + if (current_function_decl == NULL_TREE) { const char *guessed_id = lookup_name_fuzzy (id, FUZZY_LOOKUP_NAME); if (guessed_id) @@ -3767,7 +3768,7 @@ define_label (location_t location, tree name) if (label && ((DECL_CONTEXT (label) == current_function_decl - && DECL_INITIAL (label) != 0) + && DECL_INITIAL (label) != NULL_TREE) || (DECL_CONTEXT (label) != current_function_decl && C_DECLARED_LABEL_FLAG (label)))) { @@ -3960,10 +3961,10 @@ tag_exists_p (enum tree_code code, tree name) void pending_xref_error (void) { - if (pending_invalid_xref != 0) + if (pending_invalid_xref != NULL_TREE) error_at (pending_invalid_xref_location, "%qE defined as wrong kind of tag", pending_invalid_xref); - pending_invalid_xref = 0; + pending_invalid_xref = NULL_TREE; } @@ -4123,7 +4124,7 @@ c_init_decl_processing (void) /* Initialize reserved words for parser. */ c_parse_init (); - current_function_decl = 0; + current_function_decl = NULL_TREE; gcc_obstack_init (&parser_obstack); @@ -4297,7 +4298,7 @@ shadow_tag_warned (const struct c_declspecs *declspecs, int warned) warned = 1; } - if (name == 0) + if (name == NULL_TREE) { if (warned != 1 && code != ENUMERAL_TYPE) /* Empty unnamed enum OK */ @@ -4346,7 +4347,7 @@ shadow_tag_warned (const struct c_declspecs *declspecs, int warned) } else { - pending_invalid_xref = 0; + pending_invalid_xref = NULL_TREE; t = lookup_tag (code, name, true, NULL); if (t == NULL_TREE) @@ -4373,7 +4374,7 @@ shadow_tag_warned (const struct c_declspecs *declspecs, int warned) warned = 1; } - pending_invalid_xref = 0; + pending_invalid_xref = NULL_TREE; if (declspecs->inline_p) { @@ -4859,7 +4860,7 @@ finish_decl (tree decl, location_t init_loc, tree init, tree origtype, tree asmspec_tree) { tree type; - bool was_incomplete = (DECL_SIZE (decl) == 0); + bool was_incomplete = (DECL_SIZE (decl) == NULL_TREE); const char *asmspec = 0; /* If a name was specified, get the string. */ @@ -4877,12 +4878,12 @@ finish_decl (tree decl, location_t init_loc, tree init, record_types_used_by_current_var_decl (decl); /* If `start_decl' didn't like having an initialization, ignore it now. */ - if (init != 0 && DECL_INITIAL (decl) == 0) - init = 0; + if (init != NULL_TREE && DECL_INITIAL (decl) == NULL_TREE) + init = NULL_TREE; /* Don't crash if parm is initialized. */ if (TREE_CODE (decl) == PARM_DECL) - init = 0; + init = NULL_TREE; if (init) store_init_value (init_loc, decl, init, origtype); @@ -4895,7 +4896,7 @@ finish_decl (tree decl, location_t init_loc, tree init, /* Deduce size of array from initialization, if not already known. */ if (TREE_CODE (type) == ARRAY_TYPE - && TYPE_DOMAIN (type) == 0 + && TYPE_DOMAIN (type) == NULL_TREE && TREE_CODE (decl) != TYPE_DECL) { bool do_default @@ -4967,11 +4968,11 @@ finish_decl (tree decl, location_t init_loc, tree init, if (init && TREE_CODE (init) == CONSTRUCTOR) add_flexible_array_elts_to_size (decl, init); - if (DECL_SIZE (decl) == 0 && TREE_TYPE (decl) != error_mark_node + if (DECL_SIZE (decl) == NULL_TREE && TREE_TYPE (decl) != error_mark_node && COMPLETE_TYPE_P (TREE_TYPE (decl))) layout_decl (decl, 0); - if (DECL_SIZE (decl) == 0 + if (DECL_SIZE (decl) == NULL_TREE /* Don't give an error if we already gave one earlier. */ && TREE_TYPE (decl) != error_mark_node && (TREE_STATIC (decl) @@ -4980,7 +4981,7 @@ finish_decl (tree decl, location_t init_loc, tree init, Also if it is not file scope. Otherwise, let it through, but if it is not `extern' then it may cause an error message later. */ - ? (DECL_INITIAL (decl) != 0 + ? (DECL_INITIAL (decl) != NULL_TREE || !DECL_FILE_SCOPE_P (decl)) /* An automatic variable with an incomplete type is an error. */ @@ -4996,7 +4997,7 @@ finish_decl (tree decl, location_t init_loc, tree init, && TREE_STATIC (decl)) incomplete_record_decls.safe_push (decl); - if (is_global_var (decl) && DECL_SIZE (decl) != 0) + if (is_global_var (decl) && DECL_SIZE (decl) != NULL_TREE) { if (TREE_CODE (DECL_SIZE (decl)) == INTEGER_CST) constant_expression_warning (DECL_SIZE (decl)); @@ -5117,8 +5118,8 @@ finish_decl (tree decl, location_t init_loc, tree init, /* If we used it already as memory, it must stay in memory. */ TREE_ADDRESSABLE (decl) = TREE_USED (decl); /* If it's still incomplete now, no init will save it. */ - if (DECL_SIZE (decl) == 0) - DECL_INITIAL (decl) = 0; + if (DECL_SIZE (decl) == NULL_TREE) + DECL_INITIAL (decl) = NULL_TREE; } } } @@ -5647,7 +5648,7 @@ grokdeclarator (const struct c_declarator *declarator, default: gcc_unreachable (); } - if (name == 0) + if (name == NULL_TREE) { gcc_assert (decl_context == PARM || decl_context == TYPENAME @@ -7066,7 +7067,7 @@ grokparms (struct c_arg_info *arg_info, bool funcdef_flag) error ("%<[*]%> not allowed in other than function prototype scope"); } - if (arg_types == 0 && !funcdef_flag + if (arg_types == NULL_TREE && !funcdef_flag && !in_system_header_at (input_location)) warning (OPT_Wstrict_prototypes, "function declaration isn%'t a prototype"); @@ -7084,7 +7085,7 @@ grokparms (struct c_arg_info *arg_info, bool funcdef_flag) else arg_info->parms = arg_info->types; - arg_info->types = 0; + arg_info->types = NULL_TREE; return 0; } else @@ -7179,10 +7180,10 @@ get_parm_info (bool ellipsis, tree expr) struct c_binding *b = current_scope->bindings; struct c_arg_info *arg_info = build_arg_info (); - tree parms = 0; + tree parms = NULL_TREE; vec<c_arg_tag, va_gc> *tags = NULL; - tree types = 0; - tree others = 0; + tree types = NULL_TREE; + tree others = NULL_TREE; bool gave_void_only_once_err = false; @@ -7283,7 +7284,7 @@ get_parm_info (bool ellipsis, tree expr) (it's impossible to call such a function with type- correct arguments). An anonymous union parm type is meaningful as a GNU extension, so don't warn for that. */ - if (TREE_CODE (decl) != UNION_TYPE || b->id != 0) + if (TREE_CODE (decl) != UNION_TYPE || b->id != NULL_TREE) { if (b->id) /* The %s will be one of 'struct', 'union', or 'enum'. */ @@ -7686,7 +7687,7 @@ detect_field_duplicates_hash (tree fieldlist, tree_node **slot; for (x = fieldlist; x ; x = DECL_CHAIN (x)) - if ((y = DECL_NAME (x)) != 0) + if ((y = DECL_NAME (x)) != NULL_TREE) { slot = htab->find_slot (y, INSERT); if (*slot) @@ -7866,7 +7867,7 @@ finish_struct (location_t loc, tree t, tree fieldlist, tree attributes, /* If this type was previously laid out as a forward reference, make sure we lay it out again. */ - TYPE_SIZE (t) = 0; + TYPE_SIZE (t) = NULL_TREE; decl_attributes (&t, attributes, (int) ATTR_FLAG_TYPE_IN_PLACE); @@ -7874,13 +7875,13 @@ finish_struct (location_t loc, tree t, tree fieldlist, tree attributes, { for (x = fieldlist; x; x = DECL_CHAIN (x)) { - if (DECL_NAME (x) != 0) + if (DECL_NAME (x) != NULL_TREE) break; if (flag_isoc11 && RECORD_OR_UNION_TYPE_P (TREE_TYPE (x))) break; } - if (x == 0) + if (x == NULL_TREE) { if (TREE_CODE (t) == UNION_TYPE) { @@ -8018,7 +8019,7 @@ finish_struct (location_t loc, tree t, tree fieldlist, tree attributes, = c_build_bitfield_integer_type (width, TYPE_UNSIGNED (type)); SET_DECL_MODE (field, TYPE_MODE (TREE_TYPE (field))); } - DECL_INITIAL (field) = 0; + DECL_INITIAL (field) = NULL_TREE; } else if (TYPE_REVERSE_STORAGE_ORDER (t) && TREE_CODE (field) == FIELD_DECL @@ -8218,7 +8219,7 @@ start_enum (location_t loc, struct c_enum_contents *the_enum, tree name) C_TYPE_BEING_DEFINED (enumtype) = 1; - if (TYPE_VALUES (enumtype) != 0) + if (TYPE_VALUES (enumtype) != NULL_TREE) { /* This enum is a named one that has been declared already. */ error_at (loc, "redeclaration of %<enum %E%>", name); @@ -8227,7 +8228,7 @@ start_enum (location_t loc, struct c_enum_contents *the_enum, tree name) /* Completely replace its old definition. The old enumerators remain defined, however. */ - TYPE_VALUES (enumtype) = 0; + TYPE_VALUES (enumtype) = NULL_TREE; } the_enum->enum_next_value = integer_zero_node; @@ -8260,7 +8261,7 @@ tree finish_enum (tree enumtype, tree values, tree attributes) { tree pair, tem; - tree minnode = 0, maxnode = 0; + tree minnode = NULL_TREE, maxnode = NULL_TREE; int precision; signop sign; bool toplevel = (file_scope == current_scope); @@ -8326,7 +8327,7 @@ finish_enum (tree enumtype, tree values, tree attributes) TYPE_MAX_VALUE (enumtype) = TYPE_MAX_VALUE (tem); TYPE_UNSIGNED (enumtype) = TYPE_UNSIGNED (tem); SET_TYPE_ALIGN (enumtype, TYPE_ALIGN (tem)); - TYPE_SIZE (enumtype) = 0; + TYPE_SIZE (enumtype) = NULL_TREE; TYPE_PRECISION (enumtype) = TYPE_PRECISION (tem); layout_type (enumtype); @@ -8421,17 +8422,17 @@ build_enumerator (location_t decl_loc, location_t loc, /* Validate and default VALUE. */ - if (value != 0) + if (value != NULL_TREE) { /* Don't issue more errors for error_mark_node (i.e. an undeclared identifier) - just ignore the value expression. */ if (value == error_mark_node) - value = 0; + value = NULL_TREE; else if (!INTEGRAL_TYPE_P (TREE_TYPE (value))) { error_at (loc, "enumerator value for %qE is not an integer constant", name); - value = 0; + value = NULL_TREE; } else { @@ -8447,7 +8448,7 @@ build_enumerator (location_t decl_loc, location_t loc, { error ("enumerator value for %qE is not an integer constant", name); - value = 0; + value = NULL_TREE; } else { @@ -8460,7 +8461,7 @@ build_enumerator (location_t decl_loc, location_t loc, /* Default based on previous value. */ /* It should no longer be possible to have NON_LVALUE_EXPR in the default. */ - if (value == 0) + if (value == NULL_TREE) { value = the_enum->enum_next_value; if (the_enum->enum_overflow) @@ -8546,7 +8547,7 @@ start_function (struct c_declspecs *declspecs, struct c_declarator *declarator, /* If the declarator is not suitable for a function definition, cause a syntax error. */ - if (decl1 == 0 + if (decl1 == NULL_TREE || TREE_CODE (decl1) != FUNCTION_DECL) return 0; @@ -8594,20 +8595,21 @@ start_function (struct c_declspecs *declspecs, struct c_declarator *declarator, DECL_INITIAL (decl1) = error_mark_node; /* A nested function is not global. */ - if (current_function_decl != 0) + if (current_function_decl != NULL_TREE) TREE_PUBLIC (decl1) = 0; /* If this definition isn't a prototype and we had a prototype declaration before, copy the arg type info from that prototype. */ old_decl = lookup_name_in_scope (DECL_NAME (decl1), current_scope); if (old_decl && TREE_CODE (old_decl) != FUNCTION_DECL) - old_decl = 0; + old_decl = NULL_TREE; current_function_prototype_locus = UNKNOWN_LOCATION; current_function_prototype_built_in = false; current_function_prototype_arg_types = NULL_TREE; if (!prototype_p (TREE_TYPE (decl1))) { - if (old_decl != 0 && TREE_CODE (TREE_TYPE (old_decl)) == FUNCTION_TYPE + if (old_decl != NULL_TREE + && TREE_CODE (TREE_TYPE (old_decl)) == FUNCTION_TYPE && comptypes (TREE_TYPE (TREE_TYPE (decl1)), TREE_TYPE (TREE_TYPE (old_decl)))) { @@ -8676,7 +8678,7 @@ start_function (struct c_declspecs *declspecs, struct c_declarator *declarator, /* Optionally warn of any def with no previous prototype if the function has already been used. */ else if (warn_missing_prototypes - && old_decl != 0 + && old_decl != NULL_TREE && old_decl != error_mark_node && TREE_USED (old_decl) && !prototype_p (TREE_TYPE (old_decl))) @@ -8685,7 +8687,7 @@ start_function (struct c_declspecs *declspecs, struct c_declarator *declarator, /* Optionally warn of any global def with no previous declaration. */ else if (warn_missing_declarations && TREE_PUBLIC (decl1) - && old_decl == 0 + && old_decl == NULL_TREE && !MAIN_NAME_P (DECL_NAME (decl1)) && !DECL_DECLARED_INLINE_P (decl1)) warning_at (loc, OPT_Wmissing_declarations, @@ -8694,7 +8696,7 @@ start_function (struct c_declspecs *declspecs, struct c_declarator *declarator, /* Optionally warn of any def with no previous declaration if the function has already been used. */ else if (warn_missing_declarations - && old_decl != 0 + && old_decl != NULL_TREE && old_decl != error_mark_node && TREE_USED (old_decl) && C_DECL_IMPLICIT (old_decl)) @@ -8838,11 +8840,11 @@ store_parm_decls_oldstyle (tree fndecl, const struct c_arg_info *arg_info) decl in the appropriate TREE_PURPOSE slot of the parmids chain. */ for (parm = parmids; parm; parm = TREE_CHAIN (parm)) { - if (TREE_VALUE (parm) == 0) + if (TREE_VALUE (parm) == NULL_TREE) { error_at (DECL_SOURCE_LOCATION (fndecl), "parameter name missing from parameter list"); - TREE_PURPOSE (parm) = 0; + TREE_PURPOSE (parm) = NULL_TREE; continue; } @@ -8866,7 +8868,7 @@ store_parm_decls_oldstyle (tree fndecl, const struct c_arg_info *arg_info) { error_at (DECL_SOURCE_LOCATION (decl), "multiple parameters named %qD", decl); - TREE_PURPOSE (parm) = 0; + TREE_PURPOSE (parm) = NULL_TREE; continue; } /* If the declaration says "void", complain and turn it into @@ -8948,7 +8950,7 @@ store_parm_decls_oldstyle (tree fndecl, const struct c_arg_info *arg_info) /* Chain the declarations together in the order of the list of names. Store that chain in the function decl, replacing the list of names. Update the current scope to match. */ - DECL_ARGUMENTS (fndecl) = 0; + DECL_ARGUMENTS (fndecl) = NULL_TREE; for (parm = parmids; parm; parm = TREE_CHAIN (parm)) if (TREE_PURPOSE (parm)) @@ -8964,7 +8966,7 @@ store_parm_decls_oldstyle (tree fndecl, const struct c_arg_info *arg_info) DECL_CHAIN (last) = TREE_PURPOSE (parm); last = TREE_PURPOSE (parm); } - DECL_CHAIN (last) = 0; + DECL_CHAIN (last) = NULL_TREE; } /* If there was a previous prototype, @@ -9068,14 +9070,14 @@ store_parm_decls_oldstyle (tree fndecl, const struct c_arg_info *arg_info) } } } - TYPE_ACTUAL_ARG_TYPES (TREE_TYPE (fndecl)) = 0; + TYPE_ACTUAL_ARG_TYPES (TREE_TYPE (fndecl)) = NULL_TREE; } /* Otherwise, create a prototype that would match. */ else { - tree actual = 0, last = 0, type; + tree actual = NULL_TREE, last = NULL_TREE, type; for (parm = DECL_ARGUMENTS (fndecl); parm; parm = DECL_CHAIN (parm)) { @@ -9558,7 +9560,7 @@ c_pop_function_context (void) /* But DECL_INITIAL must remain nonzero so we know this was an actual function definition. */ DECL_INITIAL (current_function_decl) = error_mark_node; - DECL_ARGUMENTS (current_function_decl) = 0; + DECL_ARGUMENTS (current_function_decl) = NULL_TREE; } c_stmt_tree = p->base.x_stmt_tree; @@ -11122,7 +11124,7 @@ c_write_global_declarations_1 (tree globals) standard's definition of "used", and set TREE_NO_WARNING so that check_global_declaration doesn't repeat the check. */ if (TREE_CODE (decl) == FUNCTION_DECL - && DECL_INITIAL (decl) == 0 + && DECL_INITIAL (decl) == NULL_TREE && DECL_EXTERNAL (decl) && !TREE_PUBLIC (decl)) { |