From: Zack Weinberg Date: Wed, 21 Jan 2004 10:32:10 +0000 (+0000) Subject: c-decl.c (merge_decls): Kill different_binding_level and different_tu arguments;... X-Git-Tag: releases/gcc-4.0.0~10878 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1ef82ef2e4438959b1385c20bd47a1febed98221;p=thirdparty%2Fgcc.git c-decl.c (merge_decls): Kill different_binding_level and different_tu arguments; simplify throughout. * c-decl.c (merge_decls): Kill different_binding_level and different_tu arguments; simplify throughout. (duplicate_decls): Likewise. (pushdecl, merge_translation_unit_decls): Update calls to duplicate_decls. testsuite: * gcc.dg/noncompile/20020213-1.c: Add another dg-warning line. From-SVN: r76269 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 3112521249cb..79e592437028 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2004-01-21 Zack Weinberg + + * c-decl.c (merge_decls): Kill different_binding_level and + different_tu arguments; simplify throughout. + (duplicate_decls): Likewise. + (pushdecl, merge_translation_unit_decls): Update calls to + duplicate_decls. + 2004-01-20 Kaveh R. Ghazi * Makefile.in (pretty-print.o): Depend on $(CONFIG_H) and @@ -133,7 +141,7 @@ 2004-01-20 Hartmut Penner - * gcc/config/rs6000/rs6000.c (function_arg) Handle + * gcc/config/rs6000/rs6000.c (function_arg) Handle vector register special in function without prototype. (function_arg_advance): Vector parameters get always GPRs allocated for the linux64 target. @@ -189,9 +197,9 @@ 2004-01-20 Kelley Cook - * Makefile.in (target_noncanonical, program_transform_name): Use + * Makefile.in (target_noncanonical, program_transform_name): Use immediate define instead of deferred. - (GCC_INSTALL_NAME, GCC_TARGET_INSTALL_NAME, CPP_INSTALL_NAME, + (GCC_INSTALL_NAME, GCC_TARGET_INSTALL_NAME, CPP_INSTALL_NAME, PROTOIZE_INSTALL_NAME, UNPROTOIZE_INSTALL_NAME, GCOV_INSTALL_NAME, GCCBUG_INSTALL_NAME): Define via a immediate $(shell) instead of deferred backquote. @@ -227,23 +235,23 @@ 2004-01-19 Richard Henderson - * config/alpha/alpha.c (aligned_memory_operand): Check MEM_ALIGN, - don't check memory mode. - (unaligned_memory_operand): Likewise. - (reload_inqi, reload_inhi, reload_outqi, reload_outhi): Don't - abort for op0 not MEM. + * config/alpha/alpha.c (aligned_memory_operand): Check MEM_ALIGN, + don't check memory mode. + (unaligned_memory_operand): Likewise. + (reload_inqi, reload_inhi, reload_outqi, reload_outhi): Don't + abort for op0 not MEM. - * config/alpha/alpha.c (alpha_expand_mov_nobwx): If the destination - is not a reg, copy to a scratch first. - (aligned_loadqi, aligned_loadhi, unaligned_loadqi, unaligned_loadhi, - unaligned_loadqi_le, unaligned_loadqi_be, unaligned_loadhi_le, - unaligned_loadhi_be): Expect op0 in DImode; don't SUBREG. - (reload_inqi, reload_inhi): Fix mode of op0. - (reload_inqi_help, reload_inhi_help, reload_outqi_help, - reload_outhi_help): Likewise. Use define_insn_and_split. + * config/alpha/alpha.c (alpha_expand_mov_nobwx): If the destination + is not a reg, copy to a scratch first. + (aligned_loadqi, aligned_loadhi, unaligned_loadqi, unaligned_loadhi, + unaligned_loadqi_le, unaligned_loadqi_be, unaligned_loadhi_le, + unaligned_loadhi_be): Expect op0 in DImode; don't SUBREG. + (reload_inqi, reload_inhi): Fix mode of op0. + (reload_inqi_help, reload_inhi_help, reload_outqi_help, + reload_outhi_help): Likewise. Use define_insn_and_split. - * config/alpha/alpha.md (call peepholes): Check for REG_NORETURN - as well as $29 dead. + * config/alpha/alpha.md (call peepholes): Check for REG_NORETURN + as well as $29 dead. 2004-01-19 Eric Botcazou @@ -260,7 +268,7 @@ * contrib.texi: Update Paolo Carlini's entry. New entries for Jerry Quinn and Petur Runolfsson. - + 2004-01-19 Roger Sayle * config/i386/i386.md (*movhi_1, *movqi_1): When optimizing for @@ -425,7 +433,7 @@ 2004-01-17 Ziemowit Laski * objc/objc-act.c (build_objc_method_call): Use target - hooks instead of macros to determine if ..._stret + hooks instead of macros to determine if ..._stret dispatchers should be used (NeXT runtime only). 2004-01-17 Roger Sayle diff --git a/gcc/c-decl.c b/gcc/c-decl.c index 93360bebbc0b..9316c62cb326 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 @@ -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); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 9577cda1a32a..9b022b87dcf2 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,11 +1,15 @@ +2004-01-21 Zack Weinberg + + * gcc.dg/noncompile/20020213-1.c: Add another dg-warning line. + 2004-01-20 Hartmut Penner * gcc.dg/ppc64-abi-2.c: New test. 2004-01-18 James A. Morrison - * lib/treelang.exp: Fill out this file. - * lib/treelang-dg.exp: New File. + * lib/treelang.exp: Fill out this file. + * lib/treelang-dg.exp: New File. 2004-01-20 Joseph S. Myers diff --git a/gcc/testsuite/gcc.dg/noncompile/20020213-1.c b/gcc/testsuite/gcc.dg/noncompile/20020213-1.c index 079daf01e2fc..77798b57c4b2 100644 --- a/gcc/testsuite/gcc.dg/noncompile/20020213-1.c +++ b/gcc/testsuite/gcc.dg/noncompile/20020213-1.c @@ -24,6 +24,7 @@ int main () return 0; } +/* { dg-warning "passing arg 2 of" "2nd incompatible" { target *-*-* } 15 } */ /* { dg-warning "passing arg 1 of" "1st incompatible" { target *-*-* } 16 } */ /* { dg-warning "passing arg 2 of" "2nd incompatible" { target *-*-* } 16 } */ /* { dg-warning "passing arg 1 of" "1st incompatible" { target *-*-* } 18 } */