diff options
author | Joseph Myers <joseph@codesourcery.com> | 2009-03-29 23:56:07 +0100 |
---|---|---|
committer | Joseph Myers <jsm28@gcc.gnu.org> | 2009-03-29 23:56:07 +0100 |
commit | 148e4216a47b822512444dbd3ca5e2670aef431c (patch) | |
tree | e75993fadfb11c86fc56a516f41f7aafb3fee001 /gcc/c-opts.c | |
parent | ba20e30910df3945603374d426730d6da5350572 (diff) | |
download | gcc-148e4216a47b822512444dbd3ca5e2670aef431c.zip gcc-148e4216a47b822512444dbd3ca5e2670aef431c.tar.gz gcc-148e4216a47b822512444dbd3ca5e2670aef431c.tar.bz2 |
re PR preprocessor/34695 (Preprocessor warning->error conversion from -Werror is silent)
PR preprocessor/34695
gcc:
* Makefile.in (c-opts.o): Depend on c-tree.h.
* c-common.c: Move down include of diagnostic.h.
(done_lexing, c_cpp_error): New.
* c-common.h (done_lexing): Declare.
* c-decl.c (c_write_global_declarations): Don't check cpp_errors
(parse_in).
* c-opts.c: Include c-tree.h.
(c_common_init_options): Set preprocessor error callback.
(c_common_handle_option): Do not set preprocessor
inhibit_warnings, warnings_are_errors, warn_system_headers,
pedantic_errors or inhibit_warnings flags.
(c_common_post_options): Do not check cpp_errors (parse_in).
(c_common_finish): Do not output dependencies if there were
errors. Do not check return value of cpp_finish.
* c-ppoutput.c (pp_file_change): Set input_location.
* c-tree.h (c_cpp_error): Declare.
* diagnostic.c (diagnostic_set_info_translated): Also initialize
override_column.
(diagnostic_build_prefix): Check override_column.
* diagnostic.h (diagnostic_info): Add override_column field.
(diagnostic_override_column): Define.
gcc/cp:
* cp-tree.h (cp_cpp_error): Remove.
* error.c (cp_cpp_error): Remove.
* parser.c (cp_lexer_new_main): Set done_lexing instead of
client_diagnostic and error callback.
gcc/fortran:
* cpp.c (cb_cpp_error): New.
(gfc_cpp_post_options): Don't set cpp_option->inhibit_warnings.
Don't check cpp_errors (cpp_in).
(gfc_cpp_init_0): Set cb->error.
gcc/testsuite:
* gcc.dg/builtin-redefine.c, gcc.dg/cpp/redef2.c,
gcc.dg/cpp/redef3.c, gcc.dg/cpp/trad/redef2.c: Use dg-message
instead of dg-warning for "previous definition" messages.
* gcc.dg/cpp/Wvariadic-1.c, gcc.dg/cpp/Wvariadic-3.c: Expect
"warnings being treated as errors" message.
* gcc.dg/fltconst-1.c: Use -fshow-column.
libcpp:
* makedepend.c: Remove.
* Makefile.in (makedepend_OBJS, makedepend$(EXEEXT)): Remove.
(all, clean, TAGS_SOURCES, include): Remove makedepend handling.
* directives.c (cpp_errors): Remove.
* errors.c (print_location, _cpp_begin_message, v_message):
Remove.
(cpp_error, cpp_error_with_line): Always use error callback.
(cpp_error, cpp_error_with_line, cpp_errno): Return bool.
* include/cpplib.h (cpp_options): Remove pedantic_errors,
inhibit_warnings, warn_system_headers, inhibit_errors,
warnings_are_errors, client_diagnostic.
(cpp_callbacks): Add extra arguments to error callback; make it
return bool.
(cpp_finish): Return void.
(cpp_destroy): Remove inaccurate comment about return value.
(cpp_errors, CPP_DL_EXTRACT, CPP_DL_WARNING_P): Remove.
(CPP_DL_NOTE): Define.
* include/line-map.h (linemap_print_containing_files): Remove.
* init.c (cpp_finish): Do not check for or return number of
errors.
* internal.h (cpp_reader): Remove errors field.
* line-map.c (linemap_print_containing_files): Remove.
* macro.c (_cpp_create_definition): Use CPP_DL_NOTE for message
about previous definition. Only emit it if previous diagnostic
was emitted.
From-SVN: r145263
Diffstat (limited to 'gcc/c-opts.c')
-rw-r--r-- | gcc/c-opts.c | 25 |
1 files changed, 7 insertions, 18 deletions
diff --git a/gcc/c-opts.c b/gcc/c-opts.c index 28bdc31..334577a 100644 --- a/gcc/c-opts.c +++ b/gcc/c-opts.c @@ -40,6 +40,7 @@ along with GCC; see the file COPYING3. If not see #include "mkdeps.h" #include "target.h" #include "tm_p.h" +#include "c-tree.h" /* For c_cpp_error. */ #ifndef DOLLARS_IN_IDENTIFIERS # define DOLLARS_IN_IDENTIFIERS true @@ -201,6 +202,7 @@ c_common_init_options (unsigned int argc, const char **argv) { static const unsigned int lang_flags[] = {CL_C, CL_ObjC, CL_CXX, CL_ObjCXX}; unsigned int i, result; + struct cpp_callbacks *cb; /* This is conditionalized only because that is the way the front ends used to do it. Maybe this should be unconditional? */ @@ -216,6 +218,8 @@ c_common_init_options (unsigned int argc, const char **argv) parse_in = cpp_create_reader (c_dialect_cxx () ? CLK_GNUCXX: CLK_GNUC89, ident_hash, line_table); + cb = cpp_get_callbacks (parse_in); + cb->error = c_cpp_error; cpp_opts = cpp_get_options (parse_in); cpp_opts->dollars_in_ident = DOLLARS_IN_IDENTIFIERS; @@ -333,7 +337,6 @@ c_common_handle_option (size_t scode, const char *arg, int value) or environment var dependency generation is used. */ cpp_opts->deps.style = (code == OPT_M ? DEPS_SYSTEM: DEPS_USER); flag_no_output = 1; - cpp_opts->inhibit_warnings = 1; break; case OPT_MD: @@ -444,7 +447,6 @@ c_common_handle_option (size_t scode, const char *arg, int value) break; case OPT_Werror: - cpp_opts->warnings_are_errors = value; global_dc->warning_as_error_requested = value; break; @@ -503,10 +505,6 @@ c_common_handle_option (size_t scode, const char *arg, int value) warn_strict_null_sentinel = value; break; - case OPT_Wsystem_headers: - cpp_opts->warn_system_headers = value; - break; - case OPT_Wtraditional: cpp_opts->warn_traditional = value; break; @@ -895,8 +893,6 @@ c_common_handle_option (size_t scode, const char *arg, int value) c_common_post_options, so that a subsequent -Wno-endif-labels is not overridden. */ case OPT_pedantic_errors: - cpp_opts->pedantic_errors = 1; - /* Fall through. */ case OPT_pedantic: cpp_opts->pedantic = 1; cpp_opts->warn_endif_labels = 1; @@ -971,10 +967,6 @@ c_common_handle_option (size_t scode, const char *arg, int value) flag_undef = 1; break; - case OPT_w: - cpp_opts->inhibit_warnings = 1; - break; - case OPT_v: verbose = true; break; @@ -1159,10 +1151,6 @@ c_common_post_options (const char **pfilename) input_location = UNKNOWN_LOCATION; - /* If an error has occurred in cpplib, note it so we fail - immediately. */ - errorcount += cpp_errors (parse_in); - *pfilename = this_input_filename = cpp_read_main_file (parse_in, in_fnames[0]); /* Don't do any compilation or preprocessing if there is no input file. */ @@ -1274,7 +1262,8 @@ c_common_finish (void) { FILE *deps_stream = NULL; - if (cpp_opts->deps.style != DEPS_NONE) + /* Don't write the deps file if there are errors. */ + if (cpp_opts->deps.style != DEPS_NONE && errorcount == 0) { /* If -M or -MM was seen without -MF, default output to the output stream. */ @@ -1290,7 +1279,7 @@ c_common_finish (void) /* For performance, avoid tearing down cpplib's internal structures with cpp_destroy (). */ - errorcount += cpp_finish (parse_in, deps_stream); + cpp_finish (parse_in, deps_stream); if (deps_stream && deps_stream != out_stream && (ferror (deps_stream) || fclose (deps_stream))) |