c-decl.c (mesg_implicit_function_declaration): Init to -1.

* c-decl.c (mesg_implicit_function_declaration): Init to -1.
	(implicit_decl_warning): New function.
	(implicitly_declare): Use it.
	* c-typeck.c (build_external_ref): Use implicit_decl_warning
	to complain about implicit decls of builtins.

	* c-lang.c (lang_init): Set mesg_implicit_function_declaration
	based on pedantic && flag_isoc99, if not already set.
	* c-tree.h: Declare mesg_implicit_function_declaration.
	Prototype implicit_decl_warning.

	* gcc.dg/c99-impl-decl-1.c: No longer XFAIL.

From-SVN: r35385
This commit is contained in:
Zack Weinberg 2000-07-31 18:10:31 +00:00 committed by Zack Weinberg
parent cdbca1727c
commit 111458f1bf
7 changed files with 49 additions and 14 deletions

View File

@ -1,3 +1,16 @@
2000-07-31 Zack Weinberg <zack@wolery.cumb.org>
* c-decl.c (mesg_implicit_function_declaration): Init to -1.
(implicit_decl_warning): New function.
(implicitly_declare): Use it.
* c-typeck.c (build_external_ref): Use implicit_decl_warning
to complain about implicit decls of builtins.
* c-lang.c (lang_init): Set mesg_implicit_function_declaration
based on pedantic && flag_isoc99, if not already set.
* c-tree.h: Declare mesg_implicit_function_declaration.
Prototype implicit_decl_warning.
2000-07-30 Jeffrey D. Oldham <oldham@codesourcery.com>
* Makefile.in (ssa.o): Updated header files in dependences.

View File

@ -358,7 +358,7 @@ int warn_long_long = 1;
/* Nonzero means message about use of implicit function declarations;
1 means warning; 2 means error. */
int mesg_implicit_function_declaration;
int mesg_implicit_function_declaration = -1;
/* Nonzero means give string constants the type `const char *'
to get extra warnings from them. These warnings will be too numerous
@ -2525,15 +2525,8 @@ implicitly_declare (functionid)
rest_of_decl_compilation (decl, NULL_PTR, 0, 0);
if (mesg_implicit_function_declaration && implicit_warning)
{
if (mesg_implicit_function_declaration == 2)
error ("implicit declaration of function `%s'",
IDENTIFIER_POINTER (functionid));
else
warning ("implicit declaration of function `%s'",
IDENTIFIER_POINTER (functionid));
}
if (implicit_warning)
implicit_decl_warning (functionid);
else if (warn_traditional && traditional_warning)
warning ("function `%s' was previously declared within a block",
IDENTIFIER_POINTER (functionid));
@ -2546,6 +2539,17 @@ implicitly_declare (functionid)
return decl;
}
void
implicit_decl_warning (id)
tree id;
{
char *name = IDENTIFIER_POINTER (id);
if (mesg_implicit_function_declaration == 2)
error ("implicit declaration of function `%s'", name);
else if (mesg_implicit_function_declaration == 1)
warning ("implicit declaration of function `%s'", name);
}
/* Return zero if the declaration NEWDECL is valid
when the declaration OLDDECL (assumed to be for the same name)
has already been seen.

View File

@ -69,6 +69,15 @@ lang_init ()
if (flag_bounds_check < 0)
flag_bounds_check = flag_bounded_pointers;
/* If still unspecified, make it match pedantic && -std=c99. */
if (mesg_implicit_function_declaration < 0)
{
if (pedantic && flag_isoc99)
mesg_implicit_function_declaration = flag_pedantic_errors ? 2 : 1;
else
mesg_implicit_function_declaration = 0;
}
/* the beginning of the file is a new line; check for # */
/* With luck, we discover the real source file's name from that
and put it in input_filename. */

View File

@ -188,6 +188,7 @@ extern tree grokfield PARAMS ((const char *, int, tree
extern tree groktypename PARAMS ((tree));
extern tree groktypename_in_parm_context PARAMS ((tree));
extern tree implicitly_declare PARAMS ((tree));
extern void implicit_decl_warning PARAMS ((tree));
extern int in_parm_level_p PARAMS ((void));
extern void init_decl_processing PARAMS ((void));
extern void insert_block PARAMS ((tree));
@ -388,6 +389,9 @@ extern int warn_long_long;
extern int system_header_p;
/* Warn about implicit declarations. 1 = warning, 2 = error. */
extern int mesg_implicit_function_declaration;
/* Nonzero enables objc features. */
#define doing_objc_thang \

View File

@ -1417,9 +1417,10 @@ build_external_ref (id, fun)
/* Implicit declaration of built-in function. Don't
change the built-in declaration, but don't let this
go by silently, either. */
pedwarn ("implicit declaration of function `%s'",
IDENTIFIER_POINTER (DECL_NAME (decl)));
C_DECL_ANTICIPATED (decl) = 0; /* only issue this warning once */
implicit_decl_warning (id);
/* only issue this warning once */
C_DECL_ANTICIPATED (decl) = 0;
ref = decl;
}
}

View File

@ -1,3 +1,7 @@
2000-07-31 Zack Weinberg <zack@wolery.cumb.org>
* gcc.dg/c99-impl-decl-1.c: No longer XFAIL.
2000-07-31 Joseph S. Myers <jsm28@cam.ac.uk>
* gcc.dg/noncompile/voidparam-1.c: New test.

View File

@ -7,7 +7,7 @@ void
foo (void)
{
bar (); /* { dg-bogus "warning" "warning in place of error" } */
/* { dg-error "implicit" "C99 implicit declaration error" { xfail *-*-* } 9 } */
/* { dg-error "implicit" "C99 implicit declaration error" { target *-*-* } 9 } */
}
/* C90 subclause 7.1.7 says we can implicitly declare strcmp; C99 removes