Commit 111458f1 by Zack Weinberg Committed by Zack Weinberg

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
parent cdbca172
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> 2000-07-30 Jeffrey D. Oldham <oldham@codesourcery.com>
* Makefile.in (ssa.o): Updated header files in dependences. * Makefile.in (ssa.o): Updated header files in dependences.
......
...@@ -358,7 +358,7 @@ int warn_long_long = 1; ...@@ -358,7 +358,7 @@ int warn_long_long = 1;
/* Nonzero means message about use of implicit function declarations; /* Nonzero means message about use of implicit function declarations;
1 means warning; 2 means error. */ 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 *' /* Nonzero means give string constants the type `const char *'
to get extra warnings from them. These warnings will be too numerous to get extra warnings from them. These warnings will be too numerous
...@@ -2525,15 +2525,8 @@ implicitly_declare (functionid) ...@@ -2525,15 +2525,8 @@ implicitly_declare (functionid)
rest_of_decl_compilation (decl, NULL_PTR, 0, 0); rest_of_decl_compilation (decl, NULL_PTR, 0, 0);
if (mesg_implicit_function_declaration && implicit_warning) if (implicit_warning)
{ implicit_decl_warning (functionid);
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));
}
else if (warn_traditional && traditional_warning) else if (warn_traditional && traditional_warning)
warning ("function `%s' was previously declared within a block", warning ("function `%s' was previously declared within a block",
IDENTIFIER_POINTER (functionid)); IDENTIFIER_POINTER (functionid));
...@@ -2546,6 +2539,17 @@ implicitly_declare (functionid) ...@@ -2546,6 +2539,17 @@ implicitly_declare (functionid)
return decl; 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 /* Return zero if the declaration NEWDECL is valid
when the declaration OLDDECL (assumed to be for the same name) when the declaration OLDDECL (assumed to be for the same name)
has already been seen. has already been seen.
......
...@@ -69,6 +69,15 @@ lang_init () ...@@ -69,6 +69,15 @@ lang_init ()
if (flag_bounds_check < 0) if (flag_bounds_check < 0)
flag_bounds_check = flag_bounded_pointers; 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 # */ /* the beginning of the file is a new line; check for # */
/* With luck, we discover the real source file's name from that /* With luck, we discover the real source file's name from that
and put it in input_filename. */ and put it in input_filename. */
......
...@@ -188,6 +188,7 @@ extern tree grokfield PARAMS ((const char *, int, tree ...@@ -188,6 +188,7 @@ extern tree grokfield PARAMS ((const char *, int, tree
extern tree groktypename PARAMS ((tree)); extern tree groktypename PARAMS ((tree));
extern tree groktypename_in_parm_context PARAMS ((tree)); extern tree groktypename_in_parm_context PARAMS ((tree));
extern tree implicitly_declare PARAMS ((tree)); extern tree implicitly_declare PARAMS ((tree));
extern void implicit_decl_warning PARAMS ((tree));
extern int in_parm_level_p PARAMS ((void)); extern int in_parm_level_p PARAMS ((void));
extern void init_decl_processing PARAMS ((void)); extern void init_decl_processing PARAMS ((void));
extern void insert_block PARAMS ((tree)); extern void insert_block PARAMS ((tree));
...@@ -388,6 +389,9 @@ extern int warn_long_long; ...@@ -388,6 +389,9 @@ extern int warn_long_long;
extern int system_header_p; extern int system_header_p;
/* Warn about implicit declarations. 1 = warning, 2 = error. */
extern int mesg_implicit_function_declaration;
/* Nonzero enables objc features. */ /* Nonzero enables objc features. */
#define doing_objc_thang \ #define doing_objc_thang \
......
...@@ -1417,9 +1417,10 @@ build_external_ref (id, fun) ...@@ -1417,9 +1417,10 @@ build_external_ref (id, fun)
/* Implicit declaration of built-in function. Don't /* Implicit declaration of built-in function. Don't
change the built-in declaration, but don't let this change the built-in declaration, but don't let this
go by silently, either. */ go by silently, either. */
pedwarn ("implicit declaration of function `%s'", implicit_decl_warning (id);
IDENTIFIER_POINTER (DECL_NAME (decl)));
C_DECL_ANTICIPATED (decl) = 0; /* only issue this warning once */ /* only issue this warning once */
C_DECL_ANTICIPATED (decl) = 0;
ref = decl; ref = decl;
} }
} }
......
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> 2000-07-31 Joseph S. Myers <jsm28@cam.ac.uk>
* gcc.dg/noncompile/voidparam-1.c: New test. * gcc.dg/noncompile/voidparam-1.c: New test.
......
...@@ -7,7 +7,7 @@ void ...@@ -7,7 +7,7 @@ void
foo (void) foo (void)
{ {
bar (); /* { dg-bogus "warning" "warning in place of error" } */ 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 /* C90 subclause 7.1.7 says we can implicitly declare strcmp; C99 removes
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment