diff options
author | Dale Johannesen <dalej@apple.com> | 2004-12-17 20:05:34 +0000 |
---|---|---|
committer | Dale Johannesen <dalej@gcc.gnu.org> | 2004-12-17 20:05:34 +0000 |
commit | 128691426dcb9e2a3cb57c89bc863d03c1009d82 (patch) | |
tree | cc6ac8b5b4b86542f8bc16178aa7879397343679 /gcc/c-decl.c | |
parent | 5429f07f64ebd4b8963489711e2426cc4ab036fc (diff) | |
download | gcc-128691426dcb9e2a3cb57c89bc863d03c1009d82.zip gcc-128691426dcb9e2a3cb57c89bc863d03c1009d82.tar.gz gcc-128691426dcb9e2a3cb57c89bc863d03c1009d82.tar.bz2 |
c-decl.c (diagnose_mismatched_decls): Accept mismatched function types: void with previous implicit int.
2004-12-17 Dale Johannesen <dalej@apple.com>
* c-decl.c (diagnose_mismatched_decls): Accept mismatched
function types: void with previous implicit int.
From-SVN: r92329
Diffstat (limited to 'gcc/c-decl.c')
-rw-r--r-- | gcc/c-decl.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/gcc/c-decl.c b/gcc/c-decl.c index ea26da4..b728a6b 100644 --- a/gcc/c-decl.c +++ b/gcc/c-decl.c @@ -1191,7 +1191,7 @@ diagnose_mismatched_decls (tree newdecl, tree olddecl, else if (TREE_CODE (newdecl) == FUNCTION_DECL && DECL_INITIAL (newdecl) && TYPE_MAIN_VARIANT (TREE_TYPE (oldtype)) == void_type_node && TYPE_MAIN_VARIANT (TREE_TYPE (newtype)) == integer_type_node - && C_FUNCTION_IMPLICIT_INT (newdecl)) + && C_FUNCTION_IMPLICIT_INT (newdecl) && !DECL_INITIAL (olddecl)) { pedwarn ("%Jconflicting types for %qD", newdecl, newdecl); /* Make sure we keep void as the return type. */ @@ -1199,6 +1199,18 @@ diagnose_mismatched_decls (tree newdecl, tree olddecl, C_FUNCTION_IMPLICIT_INT (newdecl) = 0; pedwarned = true; } + /* Permit void foo (...) to match an earlier call to foo (...) with + no declared type (thus, implicitly int). */ + else if (TREE_CODE (newdecl) == FUNCTION_DECL + && TYPE_MAIN_VARIANT (TREE_TYPE (newtype)) == void_type_node + && TYPE_MAIN_VARIANT (TREE_TYPE (oldtype)) == integer_type_node + && C_DECL_IMPLICIT (olddecl) && !DECL_INITIAL (olddecl)) + { + pedwarn ("%Jconflicting types for %qD", newdecl, newdecl); + /* Make sure we keep void as the return type. */ + TREE_TYPE (olddecl) = *oldtypep = oldtype = newtype; + pedwarned = true; + } else { if (TYPE_QUALS (newtype) != TYPE_QUALS (oldtype)) |