diff options
author | Richard Stallman <rms@gnu.org> | 1992-07-31 06:14:04 +0000 |
---|---|---|
committer | Richard Stallman <rms@gnu.org> | 1992-07-31 06:14:04 +0000 |
commit | 27f427f88810b4026ab24cd438d5eecb6d7ec007 (patch) | |
tree | b76693f62a0fc7c9141f81126f84068b7ca58530 | |
parent | 412a4297f630d99ed5e671be0cf19d91b2cbff20 (diff) | |
download | gcc-27f427f88810b4026ab24cd438d5eecb6d7ec007.zip gcc-27f427f88810b4026ab24cd438d5eecb6d7ec007.tar.gz gcc-27f427f88810b4026ab24cd438d5eecb6d7ec007.tar.bz2 |
(duplicate_decls): Handle warn_redundant_decls here.
But don't warn if function definition follows a declaration.
(pushdecl): Don't handle it here.
(grokparms): Don't warn about non-prototype decl in system header.
From-SVN: r1726
-rw-r--r-- | gcc/c-decl.c | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/gcc/c-decl.c b/gcc/c-decl.c index ba07910..0155b12 100644 --- a/gcc/c-decl.c +++ b/gcc/c-decl.c @@ -1412,6 +1412,17 @@ duplicate_decls (newdecl, olddecl) } } + /* Optionally warn about more than one declaration for the same name. */ + if (warn_redundant_decls && DECL_SOURCE_LINE (olddecl) != 0 + /* Dont warn about a function declaration + followed by a definition. */ + && !(TREE_CODE (newdecl) == FUNCTION_DECL && DECL_INITIAL (newdecl) != 0 + && DECL_INITIAL (olddecl) == 0)) + { + warning_with_decl (newdecl, "redundant redeclaration of `%s' in same scope"); + warning_with_decl (olddecl, "previous declaration of `%s'"); + } + /* Copy all the DECL_... slots specified in the new decl except for any that we copy here from the old type. @@ -1622,14 +1633,7 @@ pushdecl (x) "previous declaration of `%s'", IDENTIFIER_POINTER (name)); } - if (warn_redundant_decls && line != 0) - { - warning ("redundant redeclaration of `%s' in same scope", - IDENTIFIER_POINTER (name)); - warning_with_file_and_line (file, line, - "previous declaration of `%s'", - IDENTIFIER_POINTER (name)); - } + return t; } @@ -4279,7 +4283,8 @@ grokparms (parms_info, funcdef_flag) last_function_parms = TREE_PURPOSE (parms_info); last_function_parm_tags = TREE_VALUE (parms_info); - if (warn_strict_prototypes && first_parm == 0 && !funcdef_flag) + if (warn_strict_prototypes && first_parm == 0 && !funcdef_flag + && !in_system_header) warning ("function declaration isn't a prototype"); if (first_parm != 0 |