aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZack Weinberg <zack@wolery.cumb.org>2000-07-31 18:10:31 +0000
committerZack Weinberg <zack@gcc.gnu.org>2000-07-31 18:10:31 +0000
commit111458f1bf05cbfe487bdab956917a59c5fdc60d (patch)
tree71356bf58f3c89b7f453bb3fe8fa75cffb958203
parentcdbca1727ce8d428964efcb2f20ee82142a2c762 (diff)
downloadgcc-111458f1bf05cbfe487bdab956917a59c5fdc60d.zip
gcc-111458f1bf05cbfe487bdab956917a59c5fdc60d.tar.gz
gcc-111458f1bf05cbfe487bdab956917a59c5fdc60d.tar.bz2
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
-rw-r--r--gcc/ChangeLog13
-rw-r--r--gcc/c-decl.c24
-rw-r--r--gcc/c-lang.c9
-rw-r--r--gcc/c-tree.h4
-rw-r--r--gcc/c-typeck.c7
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/gcc.dg/c99-impl-decl-1.c2
7 files changed, 49 insertions, 14 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 44caceb..846f61e 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -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.
diff --git a/gcc/c-decl.c b/gcc/c-decl.c
index 34a8f42..a9eb619 100644
--- a/gcc/c-decl.c
+++ b/gcc/c-decl.c
@@ -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.
diff --git a/gcc/c-lang.c b/gcc/c-lang.c
index 620ed78..a34f306 100644
--- a/gcc/c-lang.c
+++ b/gcc/c-lang.c
@@ -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. */
diff --git a/gcc/c-tree.h b/gcc/c-tree.h
index fcf6112..0bb4efb 100644
--- a/gcc/c-tree.h
+++ b/gcc/c-tree.h
@@ -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 \
diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c
index 17cdedd..e6fc249 100644
--- a/gcc/c-typeck.c
+++ b/gcc/c-typeck.c
@@ -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;
}
}
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index cc7ed1b..c1090c8 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -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.
diff --git a/gcc/testsuite/gcc.dg/c99-impl-decl-1.c b/gcc/testsuite/gcc.dg/c99-impl-decl-1.c
index 5843e64..6602bc7 100644
--- a/gcc/testsuite/gcc.dg/c99-impl-decl-1.c
+++ b/gcc/testsuite/gcc.dg/c99-impl-decl-1.c
@@ -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