X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=gcc%2Fc-decl.c;h=9316c62cb3263878915d2f7060241a316b792a12;hb=1ef82ef2e4438959b1385c20bd47a1febed98221;hp=77f6cfbb69f83ca71450f943d7d7259909d68037;hpb=bc298aa7113959bd1f2f119cfab18e1b94d39468;p=gcc.git diff --git a/gcc/c-decl.c b/gcc/c-decl.c index 77f6cfbb69f..9316c62cb32 100644 --- a/gcc/c-decl.c +++ b/gcc/c-decl.c @@ -1252,23 +1252,15 @@ diagnose_mismatched_decls (tree newdecl, tree olddecl, /* Subroutine of duplicate_decls. NEWDECL has been found to be consistent with OLDDECL, but carries new information. Merge the - new information into OLDDECL. If DIFFERENT_BINDING_LEVEL or - DIFFERENT_TU is true, avoid completely merging the decls, as this - will break assumptions elsewhere. This function issues no + new information into OLDDECL. This function issues no diagnostics. */ static void -merge_decls (tree newdecl, tree olddecl, tree newtype, tree oldtype, - bool different_binding_level, bool different_tu) +merge_decls (tree newdecl, tree olddecl, tree newtype, tree oldtype) { int new_is_definition = (TREE_CODE (newdecl) == FUNCTION_DECL && DECL_INITIAL (newdecl) != 0); - /* When copying info to olddecl, we store into write_olddecl - instead. This allows us to avoid modifying olddecl when - different_binding_level is true. */ - tree write_olddecl = different_binding_level ? newdecl : olddecl; - /* For real parm decl following a forward decl, return 1 so old decl will be reused. Only allow this to happen once. */ if (TREE_CODE (newdecl) == PARM_DECL @@ -1282,25 +1274,9 @@ merge_decls (tree newdecl, tree olddecl, tree newtype, tree oldtype, = (*targetm.merge_decl_attributes) (olddecl, newdecl); /* Merge the data types specified in the two decls. */ - if (TREE_CODE (newdecl) != FUNCTION_DECL || !DECL_BUILT_IN (olddecl)) - { - if (different_binding_level) - { - if (TYPE_ARG_TYPES (oldtype) != 0 - && TYPE_ARG_TYPES (newtype) == 0) - TREE_TYPE (newdecl) = common_type (newtype, oldtype); - else - TREE_TYPE (newdecl) - = build_type_attribute_variant - (newtype, - merge_attributes (TYPE_ATTRIBUTES (newtype), - TYPE_ATTRIBUTES (oldtype))); - } - else - TREE_TYPE (newdecl) - = TREE_TYPE (olddecl) - = common_type (newtype, oldtype); - } + TREE_TYPE (newdecl) + = TREE_TYPE (olddecl) + = common_type (newtype, oldtype); /* Lay the type out, unless already done. */ if (oldtype != TREE_TYPE (newdecl)) @@ -1331,33 +1307,27 @@ merge_decls (tree newdecl, tree olddecl, tree newtype, tree oldtype, /* Merge the type qualifiers. */ if (TREE_READONLY (newdecl)) - TREE_READONLY (write_olddecl) = 1; + TREE_READONLY (olddecl) = 1; if (TREE_THIS_VOLATILE (newdecl)) { - TREE_THIS_VOLATILE (write_olddecl) = 1; + TREE_THIS_VOLATILE (olddecl) = 1; if (TREE_CODE (newdecl) == VAR_DECL) make_var_volatile (newdecl); } /* Keep source location of definition rather than declaration. */ - /* When called with different_binding_level set, keep the old - information so that meaningful diagnostics can be given. */ - if (DECL_INITIAL (newdecl) == 0 && DECL_INITIAL (olddecl) != 0 - && ! different_binding_level) + if (DECL_INITIAL (newdecl) == 0 && DECL_INITIAL (olddecl) != 0) DECL_SOURCE_LOCATION (newdecl) = DECL_SOURCE_LOCATION (olddecl); /* Merge the unused-warning information. */ if (DECL_IN_SYSTEM_HEADER (olddecl)) DECL_IN_SYSTEM_HEADER (newdecl) = 1; else if (DECL_IN_SYSTEM_HEADER (newdecl)) - DECL_IN_SYSTEM_HEADER (write_olddecl) = 1; + DECL_IN_SYSTEM_HEADER (olddecl) = 1; /* Merge the initialization information. */ - /* When called with different_binding_level set, don't copy over - DECL_INITIAL, so that we don't accidentally change function - declarations into function definitions. */ - if (DECL_INITIAL (newdecl) == 0 && ! different_binding_level) + if (DECL_INITIAL (newdecl) == 0) DECL_INITIAL (newdecl) = DECL_INITIAL (olddecl); /* Merge the section attribute. @@ -1397,8 +1367,6 @@ merge_decls (tree newdecl, tree olddecl, tree newtype, tree oldtype, TREE_PUBLIC (newdecl) &= TREE_PUBLIC (olddecl); /* This is since we don't automatically copy the attributes of NEWDECL into OLDDECL. */ - /* No need to worry about different_binding_level here because - then TREE_PUBLIC (newdecl) was true. */ TREE_PUBLIC (olddecl) = TREE_PUBLIC (newdecl); /* If this clears `static', clear it in the identifier too. */ if (! TREE_PUBLIC (olddecl)) @@ -1406,24 +1374,15 @@ merge_decls (tree newdecl, tree olddecl, tree newtype, tree oldtype, } if (DECL_EXTERNAL (newdecl)) { - if (! different_binding_level || different_tu) - { - /* Don't mess with these flags on local externs; they remain - external even if there's a declaration at file scope which - isn't. */ - TREE_STATIC (newdecl) = TREE_STATIC (olddecl); - DECL_EXTERNAL (newdecl) = DECL_EXTERNAL (olddecl); - } + TREE_STATIC (newdecl) = TREE_STATIC (olddecl); + DECL_EXTERNAL (newdecl) = DECL_EXTERNAL (olddecl); + /* An extern decl does not override previous storage class. */ TREE_PUBLIC (newdecl) = TREE_PUBLIC (olddecl); if (! DECL_EXTERNAL (newdecl)) { DECL_CONTEXT (newdecl) = DECL_CONTEXT (olddecl); DECL_COMMON (newdecl) = DECL_COMMON (olddecl); - /* If we have two non-EXTERNAL file-scope decls that are - the same, only one of them should be written out. */ - if (different_tu) - TREE_ASM_WRITTEN (newdecl) = 1; } } else @@ -1469,11 +1428,8 @@ merge_decls (tree newdecl, tree olddecl, tree newtype, tree oldtype, definition. */ if (new_is_definition) { - if (! different_binding_level) - { - TREE_TYPE (olddecl) = TREE_TYPE (newdecl); - DECL_BUILT_IN_CLASS (olddecl) = NOT_BUILT_IN; - } + TREE_TYPE (olddecl) = TREE_TYPE (newdecl); + DECL_BUILT_IN_CLASS (olddecl) = NOT_BUILT_IN; } else { @@ -1488,11 +1444,7 @@ merge_decls (tree newdecl, tree olddecl, tree newtype, tree oldtype, if (! new_is_definition) { DECL_RESULT (newdecl) = DECL_RESULT (olddecl); - /* When called with different_binding_level set, don't copy over - DECL_INITIAL, so that we don't accidentally change function - declarations into function definitions. */ - if (! different_binding_level) - DECL_INITIAL (newdecl) = DECL_INITIAL (olddecl); + DECL_INITIAL (newdecl) = DECL_INITIAL (olddecl); DECL_SAVED_INSNS (newdecl) = DECL_SAVED_INSNS (olddecl); DECL_SAVED_TREE (newdecl) = DECL_SAVED_TREE (olddecl); DECL_ESTIMATED_INSNS (newdecl) = DECL_ESTIMATED_INSNS (olddecl); @@ -1504,9 +1456,7 @@ merge_decls (tree newdecl, tree olddecl, tree newtype, tree oldtype, { DECL_INLINE (newdecl) = 1; DECL_ABSTRACT_ORIGIN (newdecl) - = (different_binding_level - ? DECL_ORIGIN (olddecl) - : DECL_ABSTRACT_ORIGIN (olddecl)); + = DECL_ABSTRACT_ORIGIN (olddecl); } } else @@ -1518,8 +1468,6 @@ merge_decls (tree newdecl, tree olddecl, tree newtype, tree oldtype, DECL_INLINE (newdecl) = 1; } } - if (different_binding_level) - return; /* Copy most of the decl-specific fields of NEWDECL into OLDDECL. But preserve OLDDECL's DECL_UID. */ @@ -1547,24 +1495,18 @@ merge_decls (tree newdecl, tree olddecl, tree newtype, tree oldtype, if appropriate. If safely possible, alter OLDDECL to look like NEWDECL, and return - true. Otherwise, return false. - - When DIFFERENT_BINDING_LEVEL is true, NEWDECL is an external - declaration, and OLDDECL is in an outer scope and should thus not - be changed. */ + true. Otherwise, return false. */ static bool -duplicate_decls (tree newdecl, tree olddecl, - bool different_binding_level, bool different_tu) +duplicate_decls (tree newdecl, tree olddecl) { tree newtype, oldtype; if (!diagnose_mismatched_decls (newdecl, olddecl, &newtype, &oldtype)) return false; - merge_decls (newdecl, olddecl, newtype, oldtype, - different_binding_level, different_tu); - return !different_binding_level; + merge_decls (newdecl, olddecl, newtype, oldtype); + return true; } @@ -1745,7 +1687,7 @@ pushdecl (tree x) IDENTIFIER_POINTER (name)); old = lookup_name_current_level (name); - if (old && duplicate_decls (x, old, 0, false)) + if (old && duplicate_decls (x, old)) { /* For PARM_DECLs, old may be a forward declaration. If so, we want to remove it from its old location @@ -1773,8 +1715,7 @@ pushdecl (tree x) tree ext = any_external_decl (name); if (ext) { - if (duplicate_decls (x, ext, scope != global_scope, - false)) + if (duplicate_decls (x, ext)) x = copy_node (ext); } else @@ -2282,7 +2223,7 @@ c_init_decl_processing (void) input_location = save_loc; - pedantic_lvalues = pedantic; + pedantic_lvalues = true; make_fname_decl = c_make_fname_decl; start_fname_decls (); @@ -6606,7 +6547,7 @@ merge_translation_unit_decls (void) /* Print any appropriate error messages, and partially merge the decls. */ - (void) duplicate_decls (decl, global_decl, true, true); + (void) duplicate_decls (decl, global_decl); } htab_delete (link_hash_table);