Commit 3205a71e by Zack Weinberg

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
parent e8d8a034
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> 2004-03-04 David Edelsohn <edelsohn@gnu.org>
* doc/install.texi (*-ibm-aix*): Document use of Bash to speed up * doc/install.texi (*-ibm-aix*): Document use of Bash to speed up
......
...@@ -1211,8 +1211,18 @@ diagnose_mismatched_decls (tree newdecl, tree olddecl, ...@@ -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. */ /* These bits are only type qualifiers when applied to objects. */
if (TREE_THIS_VOLATILE (newdecl) != TREE_THIS_VOLATILE (olddecl)) if (TREE_THIS_VOLATILE (newdecl) != TREE_THIS_VOLATILE (olddecl))
{ {
...@@ -1244,7 +1254,10 @@ diagnose_mismatched_decls (tree newdecl, tree olddecl, ...@@ -1244,7 +1254,10 @@ diagnose_mismatched_decls (tree newdecl, tree olddecl,
&& !(TREE_CODE (newdecl) == FUNCTION_DECL && !(TREE_CODE (newdecl) == FUNCTION_DECL
&& DECL_INITIAL (newdecl) && !DECL_INITIAL (olddecl)) && DECL_INITIAL (newdecl) && !DECL_INITIAL (olddecl))
/* Don't warn about an extern followed by a definition. */ /* Don't warn about an extern followed by a definition. */
&& !(DECL_EXTERNAL (olddecl) && !DECL_EXTERNAL (newdecl))) && !(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); warning ("%Jredundant redeclaration of '%D'", newdecl, newdecl);
warned = true; warned = true;
......
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> 2004-03-03 Kazu Hirata <kazu@cs.umass.edu>
* gcc.dg/torture/builtin-explog-1.c (PREC): Make it the same * gcc.dg/torture/builtin-explog-1.c (PREC): Make it the same
......
/* 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" "" } */
{
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment