mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-03-18 16:31:12 +08:00
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
This commit is contained in:
parent
5429f07f64
commit
128691426d
@ -1,3 +1,8 @@
|
||||
2004-12-17 Dale Johannesen <dalej@apple.com>
|
||||
|
||||
* c-decl.c (diagnose_mismatched_decls): Accept mismatched
|
||||
function types: void with previous implicit int.
|
||||
|
||||
2004-12-17 Andreas Krebbel <krebbel1@de.ibm.com>
|
||||
|
||||
* config/s390/s390.c (s390_gimplify_va_arg): Set alias set to
|
||||
|
14
gcc/c-decl.c
14
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))
|
||||
|
@ -1,3 +1,7 @@
|
||||
2004-12-17 Dale Johannesen <dalej@apple.com>
|
||||
|
||||
* gcc.dg/20041213-1.c: New.
|
||||
|
||||
2004-12-17 Ziemowit Laski <zlaski@apple.com>
|
||||
|
||||
* objc.dg/stabs-1.m: Allow assembly label to begin
|
||||
|
32
gcc/testsuite/gcc.dg/20041213-1.c
Normal file
32
gcc/testsuite/gcc.dg/20041213-1.c
Normal file
@ -0,0 +1,32 @@
|
||||
/* { dg-do compile } */
|
||||
/* test redeclarations with void and implicit int */
|
||||
extern foo1(); /* { dg-error "error: previous declaration" } */
|
||||
extern void foo1(); /* { dg-error "error: conflicting types" } */
|
||||
|
||||
extern void foo2(); /* { dg-error "error: previous declaration" } */
|
||||
extern foo2(); /* { dg-error "error: conflicting types" } */
|
||||
|
||||
void foo3() {} /* { dg-error "error: previous definition" } */
|
||||
extern foo3(); /* { dg-error "error: conflicting types" } */
|
||||
|
||||
extern foo4(); /* { dg-error "error: previous declaration" } */
|
||||
void foo4() {} /* { dg-error "error: conflicting types" } */
|
||||
|
||||
extern void foo5(); /* { dg-warning "previous declaration" } */
|
||||
foo5() {} /* { dg-warning "conflicting types" } */
|
||||
|
||||
foo6() {} /* { dg-error "error: previous definition" } */
|
||||
extern void foo6(); /* { dg-error "error: conflicting types" } */
|
||||
|
||||
foo7() {} /* { dg-error "error: previous definition" } */
|
||||
void foo7() {} /* { dg-error "error: conflicting types" } */
|
||||
|
||||
void foo8() {} /* { dg-error "error: previous definition" } */
|
||||
foo8() {} /* { dg-error "error: conflicting types" } */
|
||||
|
||||
int use9() { foo9(); } /* { dg-warning "previous implicit declaration" } */
|
||||
extern void foo9(); /* { dg-warning "conflicting types" } */
|
||||
|
||||
int use10() { foo10(); } /* { dg-warning "previous implicit declaration" } */
|
||||
void foo10() {} /* { dg-warning "conflicting types" } */
|
||||
|
Loading…
x
Reference in New Issue
Block a user