aboutsummaryrefslogtreecommitdiff
path: root/gcc/c-decl.c
diff options
context:
space:
mode:
authorZack Weinberg <zack@gcc.gnu.org>2004-03-04 05:49:06 +0000
committerZack Weinberg <zack@gcc.gnu.org>2004-03-04 05:49:06 +0000
commit3205a71e4c6b228e3b7ea99a657b4b42ffa3db69 (patch)
tree53b0c86b0cf1541d9e8b95a2eb630d9d8c0f69fe /gcc/c-decl.c
parente8d8a0344bb901cfa7e19c4f7f85bed9f38dd1f8 (diff)
downloadgcc-3205a71e4c6b228e3b7ea99a657b4b42ffa3db69.zip
gcc-3205a71e4c6b228e3b7ea99a657b4b42ffa3db69.tar.gz
gcc-3205a71e4c6b228e3b7ea99a657b4b42ffa3db69.tar.bz2
re PR c/13728 (Duplicate parameter names not detected)
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. * gcc.dg/decl-4.c: New testcase. From-SVN: r78888
Diffstat (limited to 'gcc/c-decl.c')
-rw-r--r--gcc/c-decl.c23
1 files changed, 18 insertions, 5 deletions
diff --git a/gcc/c-decl.c b/gcc/c-decl.c
index 1145363..5a4a28f 100644
--- a/gcc/c-decl.c
+++ b/gcc/c-decl.c
@@ -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;