PR 13728
authorzack <zack@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 4 Mar 2004 05:49:06 +0000 (05:49 +0000)
committerzack <zack@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 4 Mar 2004 05:49:06 +0000 (05:49 +0000)
* c-decl.c (diagnose_mismatched_decls): Issue an error for two
parameters with the same name, unless one is a forward decl.
Do not issue a redundant-redeclaration warning for forward
decls of parameters.
* gcc.dg/decl-4.c: New testcase.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@78888 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/c-decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/decl-4.c [new file with mode: 0644]

index 2b8701e..f1dd35f 100644 (file)
@@ -1,3 +1,11 @@
+2004-03-03  Zack Weinberg  <zack@codesourcery.com>
+
+       PR 13728
+       * c-decl.c (diagnose_mismatched_decls): Issue an error for two
+       parameters with the same name, unless one is a forward decl.
+       Do not issue a redundant-redeclaration warning for forward
+       decls of parameters.
+
 2004-03-04  David Edelsohn  <edelsohn@gnu.org>
 
        * doc/install.texi (*-ibm-aix*): Document use of Bash to speed up
 2004-03-03  Stuart Hastings  <stuart@apple.com>
 
        * gcc/config.gcc: Arrange for Darwin/x86 to build libgcc_eh.a.
-       
+
 2004-03-03  Eric Botcazou  <ebotcazou@libertysurf.fr>
 
        * config/sparc/sparc.c (noov_compare64_op): Fix typo.
 
 2004-03-02  Richard Henderson  <rth@redhat.com>
 
-        PR middle-end/11767
-        * coverage.c (coverage_counter_ref): Set MEM_NOTRAP_P.
-        * optabs.c (prepare_cmp_insn): Force trapping memories to registers
-        before the compare, if flag_non_call_exceptions.
+       PR middle-end/11767
+       * coverage.c (coverage_counter_ref): Set MEM_NOTRAP_P.
+       * optabs.c (prepare_cmp_insn): Force trapping memories to registers
+       before the compare, if flag_non_call_exceptions.
 
 2004-03-02  Richard Henderson  <rth@redhat.com>
 
        enable_rtl_dump_file): Declare.
 
 2004-02-27  Eric Botcazou  <ebotcazou@act-europe.fr>
-            Roger Sayle  <roger@eyesopen.com>
+           Roger Sayle  <roger@eyesopen.com>
 
        * fold-const.c (fold): Revert 2004-02-25 change.  Use the original
        operands to build a tree with swapped operands.
 
 2004-02-24  Aldy Hernandez  <aldyh@redhat.com>
 
-        * config/rs6000/spe.md (spe_fix_truncsfsi2): Delete.
-        (spe_fixuns_truncsfsi2): Delete.
+       * config/rs6000/spe.md (spe_fix_truncsfsi2): Delete.
+       (spe_fixuns_truncsfsi2): Delete.
 
-        * config/rs6000/rs6000.md (fix_truncsfsi2): Delete.
-        (fixuns_truncsfsi2): Delete.
+       * config/rs6000/rs6000.md (fix_truncsfsi2): Delete.
+       (fixuns_truncsfsi2): Delete.
 
 2004-02-24  Josef Zlomek  <zlomekj@suse.cz>
 
 
        * config/i386/i386.c: Rename pni to sse3.
        * config/i386/i386.h: Likewise.
-        * config/i386/i386.md: Likewise.
+       * config/i386/i386.md: Likewise.
        * config/i386/pmmintrin.h: Likewise.
        * doc/extend.texi: Likewise.
        * doc/invoke.texi: Likewise.
        (movdf_softfloat64):  Ditto.
 
 2004-02-23  Fariborz Jahanian <fjahanian@apple.com>
-        * config/rs6000/rs6000.c (function_arg): call to
+       * config/rs6000/rs6000.c (function_arg): call to
        rs6000_mixed_function_arg for DFmode moved to allow
        normal DFmode incoming register assignment.
 
        TARGET_DEFAULT_SHORT_ENUMS.  Update the description.
 
 2004-02-23  Eric Botcazou  <ebotcazou@libertysurf.fr>
-            Falk Hueffner  <falk@debian.org>
+           Falk Hueffner  <falk@debian.org>
 
        PR c/14188
        * builtins.c (expand_builtin_va_arg): Emit an informative message
 
 2004-02-20  John David Anglin  <dave.anglin@nrc-cnrc.gc.ca>
 
-        PR c++/12007
+       PR c++/12007
        * dbxout.c (dbxout_parms): Check that DECL_RTL and DECL_INCOMING_RTL
        are set for parameters before outputing debugging information.
 
 2004-02-20  Matt Kraai  <kraai@alumni.cmu.edu>
 
        * doc/install.texi (Building the Ada compiler): Remove
-        example.
+       example.
 
 2004-02-20  James E Wilson  <wilson@specifixinc.com>
 
index 1145363..5a4a28f 100644 (file)
@@ -1211,8 +1211,18 @@ diagnose_mismatched_decls (tree newdecl, tree olddecl,
            }
        }
     }
-  else /* VAR_DECL */
+  else /* PARM_DECL, VAR_DECL */
     {
+      /* Redeclaration of a PARM_DECL is invalid unless this is the
+        real position of a forward-declared parameter (GCC extension).  */
+      if (TREE_CODE (newdecl) == PARM_DECL
+         && (!TREE_ASM_WRITTEN (olddecl) || TREE_ASM_WRITTEN (newdecl)))
+       {
+         error ("%Jredefinition of parameter '%D'", newdecl, newdecl);
+         locate_old_decl (olddecl, error);
+         return false;
+       }
+
       /* These bits are only type qualifiers when applied to objects.  */
       if (TREE_THIS_VOLATILE (newdecl) != TREE_THIS_VOLATILE (olddecl))
        {
@@ -1241,10 +1251,13 @@ diagnose_mismatched_decls (tree newdecl, tree olddecl,
       && warn_redundant_decls
       /* Don't warn about a function declaration followed by a
         definition.  */
-    && !(TREE_CODE (newdecl) == FUNCTION_DECL
-        && DECL_INITIAL (newdecl) && !DECL_INITIAL (olddecl))
-    /* Don't warn about an extern followed by a definition.  */
-    && !(DECL_EXTERNAL (olddecl) && !DECL_EXTERNAL (newdecl)))
+      && !(TREE_CODE (newdecl) == FUNCTION_DECL
+          && DECL_INITIAL (newdecl) && !DECL_INITIAL (olddecl))
+      /* Don't warn about an extern followed by a definition.  */
+      && !(DECL_EXTERNAL (olddecl) && !DECL_EXTERNAL (newdecl))
+      /* Don't warn about forward parameter decls.  */
+      && !(TREE_CODE (newdecl) == PARM_DECL
+          && TREE_ASM_WRITTEN (olddecl) && !TREE_ASM_WRITTEN (newdecl)))
     {
       warning ("%Jredundant redeclaration of '%D'", newdecl, newdecl);
       warned = true;
index 07317d5..b0edee4 100644 (file)
@@ -1,3 +1,8 @@
+2004-03-03  Zack Weinberg  <zack@codesourcery.com>
+
+       PR 13728
+       * gcc.dg/decl-4.c: New testcase.
+
 2004-03-03  Kazu Hirata  <kazu@cs.umass.edu>
 
        * gcc.dg/torture/builtin-explog-1.c (PREC): Make it the same
@@ -23,7 +28,7 @@
 
        PR c++/14360
        * g++.old-deja/g++.ns/koenig5.C: Remove some error markers.
-       
+
        PR c++/14361
        * g++.dg/parse/defarg7.C: New test.
 
@@ -92,8 +97,8 @@
 
 2004-02-26  Richard Henderson  <rth@redhat.com>
 
-        * g++.dg/ext/attrib10.C: Mark for warning.
-        * gcc.dg/attr-alias-1.c: New.
+       * g++.dg/ext/attrib10.C: Mark for warning.
+       * gcc.dg/attr-alias-1.c: New.
 
 2004-02-26  Richard Henderson  <rth@redhat.com>
 
        * lib/target-supports.exp (check-iconv-available): New function.
        * lib/gcc-dg.exp (dg-require-iconv): New function.
        Use above.
-        * gcc.dg/charset: New directory.
-        * gcc.dg/charset/charset.exp: New file.
-        * gcc.dg/charset/asm1.c: Ditto.
-        * gcc.dg/charset/asm2.c: Ditto.
-        * gcc.dg/charset/asm3.c: Ditto.
-        * gcc.dg/charset/asm4.c: Ditto.
-        * gcc.dg/charset/asm5.c: Ditto.
-        * gcc.dg/charset/attribute1.c: Ditto.
-        * gcc.dg/charset/attribute2.c: Ditto.
-        * gcc.dg/charset/string1.c: Ditto.
-        * g++.dg/charset: New directory.
-        * g++.dg/dg.exp: Add here. Special options.
-        * g++.dg/charset/charset.exp: New file.
-        * g++.dg/charset/asm1.c: Ditto.
-        * g++.dg/charset/asm2.c: Ditto.
-        * g++.dg/charset/asm3.c: Ditto.
-        * g++.dg/charset/asm4.c: Ditto.
-        * g++.dg/charset/attribute1.c: Ditto.
-        * g++.dg/charset/attribute2.c: Ditto.
-        * g++.dg/charset/extern1.cc: Ditto.
-        * g++.dg/charset/extern2.cc: Ditto.
-        * g++.dg/charset/string1.c: Ditto.
+       * gcc.dg/charset: New directory.
+       * gcc.dg/charset/charset.exp: New file.
+       * gcc.dg/charset/asm1.c: Ditto.
+       * gcc.dg/charset/asm2.c: Ditto.
+       * gcc.dg/charset/asm3.c: Ditto.
+       * gcc.dg/charset/asm4.c: Ditto.
+       * gcc.dg/charset/asm5.c: Ditto.
+       * gcc.dg/charset/attribute1.c: Ditto.
+       * gcc.dg/charset/attribute2.c: Ditto.
+       * gcc.dg/charset/string1.c: Ditto.
+       * g++.dg/charset: New directory.
+       * g++.dg/dg.exp: Add here. Special options.
+       * g++.dg/charset/charset.exp: New file.
+       * g++.dg/charset/asm1.c: Ditto.
+       * g++.dg/charset/asm2.c: Ditto.
+       * g++.dg/charset/asm3.c: Ditto.
+       * g++.dg/charset/asm4.c: Ditto.
+       * g++.dg/charset/attribute1.c: Ditto.
+       * g++.dg/charset/attribute2.c: Ditto.
+       * g++.dg/charset/extern1.cc: Ditto.
+       * g++.dg/charset/extern2.cc: Ditto.
+       * g++.dg/charset/string1.c: Ditto.
 
 2004-02-26  Mark Mitchell  <mark@codesourcery.com>
 
diff --git a/gcc/testsuite/gcc.dg/decl-4.c b/gcc/testsuite/gcc.dg/decl-4.c
new file mode 100644 (file)
index 0000000..acc7e77
--- /dev/null
@@ -0,0 +1,10 @@
+/* Redeclaration of parameters is an error.  PR 13728.  */
+/* { dg-do compile } */
+
+void f (int fred,      /* { dg-error "previous definition" "" } */
+       int fred);      /* { dg-error "redefinition of parameter" "" } */
+
+void f2 (int fred,     /* { dg-error "previous definition" "" } */
+        int fred)      /* { dg-error "redefinition of parameter" "" } */
+{
+}