c-decl.c (implicitly_declare): Diagnose incompatible implicit declarations.
* c-decl.c (implicitly_declare): Diagnose incompatible implicit declarations. testsuite: * gcc.dg/redecl-5.c: New test. * gcc.dg/format/attr-6.c: Expect warning for implicit declaration of scanf. From-SVN: r85509
This commit is contained in:
parent
2e84789689
commit
9cbe78fbeb
@ -1,3 +1,8 @@
|
||||
2004-08-03 Joseph S. Myers <jsm@polyomino.org.uk>
|
||||
|
||||
* c-decl.c (implicitly_declare): Diagnose incompatible implicit
|
||||
declarations.
|
||||
|
||||
2004-08-03 Mike Stump <mrs@apple.com>
|
||||
|
||||
* config/darwin-c.c: Don't search in "/Local/Library/Frameworks"
|
||||
|
17
gcc/c-decl.c
17
gcc/c-decl.c
@ -2082,6 +2082,23 @@ implicitly_declare (tree functionid)
|
||||
implicit_decl_warning (functionid, decl);
|
||||
C_DECL_IMPLICIT (decl) = 1;
|
||||
}
|
||||
if (DECL_BUILT_IN (decl))
|
||||
{
|
||||
if (!comptypes (default_function_type, TREE_TYPE (decl)))
|
||||
{
|
||||
warning ("incompatible implicit declaration of built-in"
|
||||
" function %qD", decl);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!comptypes (default_function_type, TREE_TYPE (decl)))
|
||||
{
|
||||
error ("incompatible implicit declaration of function %qD",
|
||||
decl);
|
||||
locate_old_decl (decl, error);
|
||||
}
|
||||
}
|
||||
bind (functionid, decl, current_scope,
|
||||
/*invisible=*/false, /*nested=*/true);
|
||||
return decl;
|
||||
|
@ -1,3 +1,9 @@
|
||||
2004-08-03 Joseph S. Myers <jsm@polyomino.org.uk>
|
||||
|
||||
* gcc.dg/redecl-5.c: New test.
|
||||
* gcc.dg/format/attr-6.c: Expect warning for implicit declaration
|
||||
of scanf.
|
||||
|
||||
2004-08-03 Roger Sayle <roger@eyesopen.com>
|
||||
|
||||
PR middle-end/16790
|
||||
|
@ -18,4 +18,5 @@ void
|
||||
foo (const char *s, int *p)
|
||||
{
|
||||
scanf("%ld", p); /* { dg-warning "format" "implicit scanf" } */
|
||||
/* { dg-warning "implicit" "implicit decl warning" { target *-*-* } 20 } */
|
||||
}
|
||||
|
19
gcc/testsuite/gcc.dg/redecl-5.c
Normal file
19
gcc/testsuite/gcc.dg/redecl-5.c
Normal file
@ -0,0 +1,19 @@
|
||||
/* Test for multiple declarations and composite types. Diagnosis of
|
||||
incompatible implicit declaration. */
|
||||
/* Origin: Joseph Myers <jsm@polyomino.org.uk> */
|
||||
/* { dg-do compile } */
|
||||
/* { dg-options "-std=c89" } */
|
||||
|
||||
void
|
||||
f (void)
|
||||
{
|
||||
long z(); /* { dg-error "previous implicit declaration" } */
|
||||
}
|
||||
|
||||
void
|
||||
g (void)
|
||||
{
|
||||
z(); /* { dg-error "incompatible" } */
|
||||
labs(1); /* { dg-warning "incompatible" } */
|
||||
printf("x"); /* { dg-warning "incompatible" } */
|
||||
}
|
Loading…
Reference in New Issue
Block a user