* 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
+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.
/* 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
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));
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.
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. */
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));
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 \
/* 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;
}
}
+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.
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