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 /libcpp | |
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 'libcpp')
-rw-r--r-- | libcpp/ChangeLog | 29 | ||||
-rw-r--r-- | libcpp/Makefile.in | 17 | ||||
-rw-r--r-- | libcpp/directives.c | 9 | ||||
-rw-r--r-- | libcpp/errors.c | 170 | ||||
-rw-r--r-- | libcpp/include/cpplib.h | 53 | ||||
-rw-r--r-- | libcpp/include/line-map.h | 8 | ||||
-rw-r--r-- | libcpp/init.c | 13 | ||||
-rw-r--r-- | libcpp/internal.h | 7 | ||||
-rw-r--r-- | libcpp/line-map.c | 41 | ||||
-rw-r--r-- | libcpp/macro.c | 12 | ||||
-rw-r--r-- | libcpp/makedepend.c | 206 |
11 files changed, 98 insertions, 467 deletions
diff --git a/libcpp/ChangeLog b/libcpp/ChangeLog index 61d5b97..a9841c7 100644 --- a/libcpp/ChangeLog +++ b/libcpp/ChangeLog @@ -1,3 +1,32 @@ +2009-03-29 Joseph Myers <joseph@codesourcery.com> + + PR preprocessor/34695 + * 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. + 2009-03-28 Joseph Myers <joseph@codesourcery.com> * Makefile.in (po/$(PACKAGE).pot): Use $(mkinstalldirs) not diff --git a/libcpp/Makefile.in b/libcpp/Makefile.in index 5815f73..8d99d72 100644 --- a/libcpp/Makefile.in +++ b/libcpp/Makefile.in @@ -1,7 +1,7 @@ # @configure_input@ # Makefile for libcpp. Run 'configure' to generate Makefile from Makefile.in -# Copyright (C) 2004, 2008 Free Software Foundation, Inc. +# Copyright (C) 2004, 2008, 2009 Free Software Foundation, Inc. #This file is part of libcpp. @@ -73,13 +73,12 @@ ALL_CFLAGS = $(CFLAGS) $(WARN_CFLAGS) $(INCLUDES) $(CPPFLAGS) libcpp_a_OBJS = charset.o directives.o directives-only.o errors.o \ expr.o files.o identifiers.o init.o lex.o line-map.o macro.o \ mkdeps.o pch.o symtab.o traditional.o -makedepend_OBJS = makedepend.o libcpp_a_SOURCES = charset.c directives.c directives-only.c errors.c \ expr.c files.c identifiers.c init.c lex.c line-map.c macro.c \ mkdeps.c pch.c symtab.c traditional.c -all: libcpp.a makedepend$(EXEEXT) $(USED_CATALOGS) +all: libcpp.a $(USED_CATALOGS) .SUFFIXES: .SUFFIXES: .c .gmo .o .obj .po .pox @@ -89,12 +88,6 @@ libcpp.a: $(libcpp_a_OBJS) $(AR) $(ARFLAGS) libcpp.a $(libcpp_a_OBJS) $(RANLIB) libcpp.a -makedepend$(EXEEXT): $(makedepend_OBJS) libcpp.a ../libiberty/libiberty.a - @rm -f makedepend$(EXEEXT) - $(CC) $(CFLAGS) $(LDFLAGS) -o makedepend$(EXEEXT) \ - $(makedepend_OBJS) libcpp.a ../libiberty/libiberty.a \ - $(LIBINTL) $(LIBICONV) - # Rules to rebuild the configuration Makefile: $(srcdir)/Makefile.in config.status @@ -166,7 +159,7 @@ mostlyclean: -rm -f *.o clean: mostlyclean - -rm -rf makedepend$(EXEEXT) libcpp.a $(srcdir)/autom4te.cache + -rm -rf libcpp.a $(srcdir)/autom4te.cache distclean: clean -rm -f config.h stamp-h1 config.status config.cache config.log \ @@ -248,7 +241,7 @@ po/$(PACKAGE).pot: $(libcpp_a_SOURCES) sed 's:$(srcdir)/::g' <po/$(PACKAGE).pot.tmp >po/$(PACKAGE).pot rm po/$(PACKAGE).pot.tmp -TAGS_SOURCES = $(libcpp_a_SOURCES) makedepend.c internal.h ucnid.h \ +TAGS_SOURCES = $(libcpp_a_SOURCES) internal.h ucnid.h \ include/line-map.h include/symtab.h include/cpp-id-data.h \ include/cpplib.h include/mkdeps.h system.h @@ -260,7 +253,7 @@ TAGS: $(TAGS_SOURCES) .NOEXPORT: # Dependencies --include $(patsubst %.o, $(DEPDIR)/%.Po, $(libcpp_a_OBJS) $(makedepend_OBJS)) +-include $(patsubst %.o, $(DEPDIR)/%.Po, $(libcpp_a_OBJS)) # Dependencies on generated headers have to be explicit. init.o: localedir.h diff --git a/libcpp/directives.c b/libcpp/directives.c index 9e0744b..f9e0fc2 100644 --- a/libcpp/directives.c +++ b/libcpp/directives.c @@ -1,7 +1,7 @@ /* CPP Library. (Directive handling.) Copyright (C) 1986, 1987, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, - 2007, 2008 Free Software Foundation, Inc. + 2007, 2008, 2009 Free Software Foundation, Inc. Contributed by Per Bothner, 1994-95. Based on CCCP program by Paul Rubin, June 1986 Adapted to ANSI C, Richard Stallman, Jan 1987 @@ -2299,13 +2299,6 @@ handle_assertion (cpp_reader *pfile, const char *str, int type) run_directive (pfile, type, str, count); } -/* The number of errors for a given reader. */ -unsigned int -cpp_errors (cpp_reader *pfile) -{ - return pfile->errors; -} - /* The options structure. */ cpp_options * cpp_get_options (cpp_reader *pfile) diff --git a/libcpp/errors.c b/libcpp/errors.c index e3d5629..c053f39 100644 --- a/libcpp/errors.c +++ b/libcpp/errors.c @@ -1,6 +1,6 @@ /* Default error handlers for CPP Library. Copyright (C) 1986, 1987, 1989, 1992, 1993, 1994, 1995, 1998, 1999, 2000, - 2001, 2002, 2004, 2008 Free Software Foundation, Inc. + 2001, 2002, 2004, 2008, 2009 Free Software Foundation, Inc. Written by Per Bothner, 1994. Based on CCCP program by Paul Rubin, June 1986 Adapted to ANSI C, Richard Stallman, Jan 1987 @@ -28,171 +28,69 @@ Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "cpplib.h" #include "internal.h" -static void print_location (cpp_reader *, source_location, unsigned int); - -/* Print the logical file location (LINE, COL) in preparation for a - diagnostic. Outputs the #include chain if it has changed. A line - of zero suppresses the include stack, and outputs the program name - instead. */ -static void -print_location (cpp_reader *pfile, source_location line, unsigned int col) -{ - if (line == 0) - fprintf (stderr, "%s: ", progname); - else - { - const struct line_map *map; - linenum_type lin; - - map = linemap_lookup (pfile->line_table, line); - linemap_print_containing_files (pfile->line_table, map); - - lin = SOURCE_LINE (map, line); - if (col == 0) - { - col = SOURCE_COLUMN (map, line); - if (col == 0) - col = 1; - } - - if (lin == 0) - fprintf (stderr, "%s:", map->to_file); - else if (CPP_OPTION (pfile, show_column) == 0) - fprintf (stderr, "%s:%u:", map->to_file, lin); - else - fprintf (stderr, "%s:%u:%u:", map->to_file, lin, col); - - fputc (' ', stderr); - } -} - -/* Set up for a diagnostic: print the file and line, bump the error - counter, etc. SRC_LOC is the logical line number; zero means to print - at the location of the previously lexed token, which tends to be - the correct place by default. The column number can be specified either - using COLUMN or (if COLUMN==0) extracting SOURCE_COLUMN from SRC_LOC. - (This may seem redundant, but is useful when pre-scanning (cleaning) a line, - when we haven't yet verified whether the current line_map has a - big enough max_column_hint.) - - Returns 0 if the error has been suppressed. */ -static int -_cpp_begin_message (cpp_reader *pfile, int code, - source_location src_loc, unsigned int column) -{ - int level = CPP_DL_EXTRACT (code); - - switch (level) - { - case CPP_DL_WARNING: - case CPP_DL_PEDWARN: - if (cpp_in_system_header (pfile) - && ! CPP_OPTION (pfile, warn_system_headers)) - return 0; - /* Fall through. */ - - case CPP_DL_WARNING_SYSHDR: - if (CPP_OPTION (pfile, warnings_are_errors) - || (level == CPP_DL_PEDWARN && CPP_OPTION (pfile, pedantic_errors))) - { - if (CPP_OPTION (pfile, inhibit_errors)) - return 0; - level = CPP_DL_ERROR; - pfile->errors++; - } - else if (CPP_OPTION (pfile, inhibit_warnings)) - return 0; - break; - - case CPP_DL_ERROR: - if (CPP_OPTION (pfile, inhibit_errors)) - return 0; - /* ICEs cannot be inhibited. */ - case CPP_DL_ICE: - pfile->errors++; - break; - } - - print_location (pfile, src_loc, column); - if (CPP_DL_WARNING_P (level)) - fputs (_("warning: "), stderr); - else if (level == CPP_DL_ICE) - fputs (_("internal error: "), stderr); - else - fputs (_("error: "), stderr); - - return 1; -} - -/* Don't remove the blank before do, as otherwise the exgettext - script will mistake this as a function definition */ -#define v_message(msgid, ap) \ - do { vfprintf (stderr, _(msgid), ap); putc ('\n', stderr); } while (0) - -/* Exported interface. */ - /* Print an error at the location of the previously lexed token. */ -void +bool cpp_error (cpp_reader * pfile, int level, const char *msgid, ...) { source_location src_loc; va_list ap; - + bool ret; + va_start (ap, msgid); - if (CPP_OPTION (pfile, client_diagnostic)) - pfile->cb.error (pfile, level, _(msgid), &ap); - else + if (CPP_OPTION (pfile, traditional)) { - if (CPP_OPTION (pfile, traditional)) - { - if (pfile->state.in_directive) - src_loc = pfile->directive_line; - else - src_loc = pfile->line_table->highest_line; - } - /* We don't want to refer to a token before the beginning of the - current run -- that is invalid. */ - else if (pfile->cur_token == pfile->cur_run->base) - { - if (pfile->cur_run->prev != NULL) - src_loc = pfile->cur_run->prev->limit->src_loc; - else - src_loc = 0; - } + if (pfile->state.in_directive) + src_loc = pfile->directive_line; else - { - src_loc = pfile->cur_token[-1].src_loc; - } - - if (_cpp_begin_message (pfile, level, src_loc, 0)) - v_message (msgid, ap); + src_loc = pfile->line_table->highest_line; + } + /* We don't want to refer to a token before the beginning of the + current run -- that is invalid. */ + else if (pfile->cur_token == pfile->cur_run->base) + { + if (pfile->cur_run->prev != NULL) + src_loc = pfile->cur_run->prev->limit->src_loc; + else + src_loc = 0; } + else + { + src_loc = pfile->cur_token[-1].src_loc; + } + + if (!pfile->cb.error) + abort (); + ret = pfile->cb.error (pfile, level, src_loc, 0, _(msgid), &ap); va_end (ap); + return ret; } /* Print an error at a specific location. */ -void +bool cpp_error_with_line (cpp_reader *pfile, int level, source_location src_loc, unsigned int column, const char *msgid, ...) { va_list ap; + bool ret; va_start (ap, msgid); - if (_cpp_begin_message (pfile, level, src_loc, column)) - v_message (msgid, ap); + if (!pfile->cb.error) + abort (); + ret = pfile->cb.error (pfile, level, src_loc, column, _(msgid), &ap); va_end (ap); + return ret; } -void +bool cpp_errno (cpp_reader *pfile, int level, const char *msgid) { if (msgid[0] == '\0') msgid = _("stdout"); - cpp_error (pfile, level, "%s: %s", msgid, xstrerror (errno)); + return cpp_error (pfile, level, "%s: %s", msgid, xstrerror (errno)); } diff --git a/libcpp/include/cpplib.h b/libcpp/include/cpplib.h index e2c505c..ffde40e 100644 --- a/libcpp/include/cpplib.h +++ b/libcpp/include/cpplib.h @@ -302,22 +302,9 @@ struct cpp_options /* Nonzero means print names of header files (-H). */ unsigned char print_include_names; - /* Nonzero means cpp_pedwarn causes a hard error. */ - unsigned char pedantic_errors; - - /* Nonzero means don't print warning messages. */ - unsigned char inhibit_warnings; - /* Nonzero means complain about deprecated features. */ unsigned char warn_deprecated; - /* Nonzero means don't suppress warnings from system headers. */ - unsigned char warn_system_headers; - - /* Nonzero means don't print error messages. Has no option to - select it, but can be set by a user of cpplib (e.g. fix-header). */ - unsigned char inhibit_errors; - /* Nonzero means warn if slash-star appears in a comment. */ unsigned char warn_comments; @@ -353,9 +340,6 @@ struct cpp_options explicitly undefined. */ unsigned char warn_builtin_macro_redefined; - /* Nonzero means turn warnings into errors. */ - unsigned char warnings_are_errors; - /* Nonzero means we should look for header.gcc files that remap file names. */ unsigned char remap; @@ -450,9 +434,6 @@ struct cpp_options /* Nonzero means __STDC__ should have the value 0 in system headers. */ unsigned char stdc_0_in_system_headers; - /* True means error callback should be used for diagnostics. */ - bool client_diagnostic; - /* True disables tokenization outside of preprocessing directives. */ bool directives_only; }; @@ -492,10 +473,11 @@ struct cpp_callbacks be expanded. */ cpp_hashnode * (*macro_to_expand) (cpp_reader *, const cpp_token *); - /* Called to emit a diagnostic if client_diagnostic option is true. - This callback receives the translated message. */ - void (*error) (cpp_reader *, int, const char *, va_list *) - ATTRIBUTE_FPTR_PRINTF(3,0); + /* Called to emit a diagnostic. This callback receives the + translated message. */ + bool (*error) (cpp_reader *, int, source_location, unsigned int, + const char *, va_list *) + ATTRIBUTE_FPTR_PRINTF(5,0); /* Callbacks for when a macro is expanded, or tested (whether defined or not at the time) in #ifdef, #ifndef or "defined". */ @@ -697,19 +679,13 @@ extern void cpp_init_iconv (cpp_reader *); /* Call this to finish preprocessing. If you requested dependency generation, pass an open stream to write the information to, - otherwise NULL. It is your responsibility to close the stream. - - Returns cpp_errors (pfile). */ -extern int cpp_finish (cpp_reader *, FILE *deps_stream); + otherwise NULL. It is your responsibility to close the stream. */ +extern void cpp_finish (cpp_reader *, FILE *deps_stream); /* Call this to release the handle at the end of preprocessing. Any - use of the handle after this function returns is invalid. Returns - cpp_errors (pfile). */ + use of the handle after this function returns is invalid. */ extern void cpp_destroy (cpp_reader *); -/* Error count. */ -extern unsigned int cpp_errors (cpp_reader *); - extern unsigned int cpp_token_len (const cpp_token *); extern unsigned char *cpp_token_as_text (cpp_reader *, const cpp_token *); extern unsigned char *cpp_spell_token (cpp_reader *, const cpp_token *, @@ -835,24 +811,21 @@ cpp_num cpp_num_sign_extend (cpp_num, size_t); /* An internal consistency check failed. Prints "internal error: ", otherwise the same as CPP_DL_ERROR. */ #define CPP_DL_ICE 0x04 -/* Extracts a diagnostic level from an int. */ -#define CPP_DL_EXTRACT(l) (l & 0xf) -/* Nonzero if a diagnostic level is one of the warnings. */ -#define CPP_DL_WARNING_P(l) (CPP_DL_EXTRACT (l) >= CPP_DL_WARNING \ - && CPP_DL_EXTRACT (l) <= CPP_DL_PEDWARN) +/* An informative note following a warning. */ +#define CPP_DL_NOTE 0x05 /* Output a diagnostic of some kind. */ -extern void cpp_error (cpp_reader *, int, const char *msgid, ...) +extern bool cpp_error (cpp_reader *, int, const char *msgid, ...) ATTRIBUTE_PRINTF_3; /* Output a diagnostic with "MSGID: " preceding the error string of errno. No location is printed. */ -extern void cpp_errno (cpp_reader *, int, const char *msgid); +extern bool cpp_errno (cpp_reader *, int, const char *msgid); /* Same as cpp_error, except additionally specifies a position as a (translation unit) physical line and physical column. If the line is zero, then no location is printed. */ -extern void cpp_error_with_line (cpp_reader *, int, source_location, unsigned, +extern bool cpp_error_with_line (cpp_reader *, int, source_location, unsigned, const char *msgid, ...) ATTRIBUTE_PRINTF_5; /* In lex.c */ diff --git a/libcpp/include/line-map.h b/libcpp/include/line-map.h index 81e888b..a8ce298 100644 --- a/libcpp/include/line-map.h +++ b/libcpp/include/line-map.h @@ -1,5 +1,5 @@ /* Map logical line numbers to (source file, line number) pairs. - Copyright (C) 2001, 2003, 2004, 2007 + Copyright (C) 2001, 2003, 2004, 2007, 2008, 2009 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it @@ -144,12 +144,6 @@ extern const struct line_map *linemap_add extern const struct line_map *linemap_lookup (struct line_maps *, source_location); -/* Print the file names and line numbers of the #include commands - which led to the map MAP, if any, to stderr. Nothing is output if - the most recently listed stack is the same as the current one. */ -extern void linemap_print_containing_files (struct line_maps *, - const struct line_map *); - /* Converts a map and a source_location to source line. */ #define SOURCE_LINE(MAP, LOC) \ ((((LOC) - (MAP)->start_location) >> (MAP)->column_bits) + (MAP)->to_line) diff --git a/libcpp/init.c b/libcpp/init.c index cc7a09e..ffba852 100644 --- a/libcpp/init.c +++ b/libcpp/init.c @@ -1,6 +1,7 @@ /* CPP Library. Copyright (C) 1986, 1987, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998, - 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007 Free Software Foundation, Inc. + 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, + 2009 Free Software Foundation, Inc. Contributed by Per Bothner, 1994-95. Based on CCCP program by Paul Rubin, June 1986 Adapted to ANSI C, Richard Stallman, Jan 1987 @@ -615,12 +616,11 @@ read_original_directory (cpp_reader *pfile) } /* This is called at the end of preprocessing. It pops the last - buffer and writes dependency output, and returns the number of - errors. + buffer and writes dependency output. Maybe it should also reset state, such that you could call cpp_start_read with a new filename to restart processing. */ -int +void cpp_finish (cpp_reader *pfile, FILE *deps_stream) { /* Warn about unused macros before popping the final buffer. */ @@ -635,9 +635,8 @@ cpp_finish (cpp_reader *pfile, FILE *deps_stream) while (pfile->buffer) _cpp_pop_buffer (pfile); - /* Don't write the deps file if there are errors. */ if (CPP_OPTION (pfile, deps.style) != DEPS_NONE - && deps_stream && pfile->errors == 0) + && deps_stream) { deps_write (pfile->deps, deps_stream, 72); @@ -648,8 +647,6 @@ cpp_finish (cpp_reader *pfile, FILE *deps_stream) /* Report on headers that could use multiple include guards. */ if (CPP_OPTION (pfile, print_include_names)) _cpp_report_missing_guards (pfile); - - return pfile->errors; } static void diff --git a/libcpp/internal.h b/libcpp/internal.h index af075b4..d4eeda4 100644 --- a/libcpp/internal.h +++ b/libcpp/internal.h @@ -1,6 +1,6 @@ /* Part of CPP library. - Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008 - Free Software Foundation, Inc. + Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, + 2008, 2009 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the @@ -388,9 +388,6 @@ struct cpp_reader /* Nonzero prevents the lexer from re-using the token runs. */ unsigned int keep_tokens; - /* Error counter for exit code. */ - unsigned int errors; - /* Buffer to hold macro definition string. */ unsigned char *macro_buffer; unsigned int macro_buffer_len; diff --git a/libcpp/line-map.c b/libcpp/line-map.c index 964a7cd..2802c67 100644 --- a/libcpp/line-map.c +++ b/libcpp/line-map.c @@ -1,5 +1,5 @@ /* Map logical line numbers to (source file, line number) pairs. - Copyright (C) 2001, 2003, 2004, 2007, 2008 + Copyright (C) 2001, 2003, 2004, 2007, 2008, 2009 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it @@ -302,45 +302,6 @@ linemap_lookup (struct line_maps *set, source_location line) return &set->maps[mn]; } -/* Print the file names and line numbers of the #include commands - which led to the map MAP, if any, to stderr. Nothing is output if - the most recently listed stack is the same as the current one. */ - -void -linemap_print_containing_files (struct line_maps *set, - const struct line_map *map) -{ - if (MAIN_FILE_P (map) || set->last_listed == map->included_from) - return; - - set->last_listed = map->included_from; - map = INCLUDED_FROM (set, map); - - fprintf (stderr, _("In file included from %s:%u"), - map->to_file, LAST_SOURCE_LINE (map)); - - while (! MAIN_FILE_P (map)) - { - map = INCLUDED_FROM (set, map); - /* Translators note: this message is used in conjunction - with "In file included from %s:%ld" and some other - tricks. We want something like this: - - | In file included from sys/select.h:123, - | from sys/types.h:234, - | from userfile.c:31: - | bits/select.h:45: <error message here> - - with all the "from"s lined up. - The trailing comma is at the beginning of this message, - and the trailing colon is not translated. */ - fprintf (stderr, _(",\n from %s:%u"), - map->to_file, LAST_SOURCE_LINE (map)); - } - - fputs (":\n", stderr); -} - /* Print an include trace, for e.g. the -H option of the preprocessor. */ static void diff --git a/libcpp/macro.c b/libcpp/macro.c index 8122648..3a20c36 100644 --- a/libcpp/macro.c +++ b/libcpp/macro.c @@ -1,7 +1,7 @@ /* Part of CPP library. (Macro and #define handling.) Copyright (C) 1986, 1987, 1989, 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, - 2006, 2007, 2008 Free Software Foundation, Inc. + 2006, 2007, 2008, 2009 Free Software Foundation, Inc. Written by Per Bothner, 1994. Based on CCCP program by Paul Rubin, June 1986 Adapted to ANSI C, Richard Stallman, Jan 1987 @@ -1807,11 +1807,13 @@ _cpp_create_definition (cpp_reader *pfile, cpp_hashnode *node) if (warn_of_redefinition (pfile, node, macro)) { - cpp_error_with_line (pfile, CPP_DL_PEDWARN, pfile->directive_line, 0, - "\"%s\" redefined", NODE_NAME (node)); + bool warned; + warned = cpp_error_with_line (pfile, CPP_DL_PEDWARN, + pfile->directive_line, 0, + "\"%s\" redefined", NODE_NAME (node)); - if (node->type == NT_MACRO && !(node->flags & NODE_BUILTIN)) - cpp_error_with_line (pfile, CPP_DL_PEDWARN, + if (warned && node->type == NT_MACRO && !(node->flags & NODE_BUILTIN)) + cpp_error_with_line (pfile, CPP_DL_NOTE, node->value.macro->line, 0, "this is the location of the previous definition"); } diff --git a/libcpp/makedepend.c b/libcpp/makedepend.c deleted file mode 100644 index c67f64e..0000000 --- a/libcpp/makedepend.c +++ /dev/null @@ -1,206 +0,0 @@ -/* Dependency generator utility. - Copyright (C) 2004 Free Software Foundation, Inc. - Contributed by Zack Weinberg, May 2004 - -This program is free software; you can redistribute it and/or modify it -under the terms of the GNU General Public License as published by the -Free Software Foundation; either version 2, or (at your option) any -later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - - In other words, you are welcome to use, share and improve this program. - You are forbidden to forbid anyone else to use, share and improve - what you give them. Help stamp out software-hoarding! */ - -#include "config.h" -#include "system.h" -#include "line-map.h" -#include "cpplib.h" -#include "getopt.h" -#include "mkdeps.h" - -const char *progname; -const char *vpath; - -static const char *output_file; -static bool had_errors; - -/* Option lists, to give to cpplib before each input file. */ -struct cmd_line_macro -{ - struct cmd_line_macro *next; - bool is_undef; - const char *macro; -}; - -static struct cmd_line_macro *cmd_line_macros; -static cpp_dir *cmd_line_searchpath; - -static void -add_clm (const char *macro, bool is_undef) -{ - struct cmd_line_macro *clm = XNEW (struct cmd_line_macro); - clm->next = cmd_line_macros; - clm->is_undef = is_undef; - clm->macro = macro; - cmd_line_macros = clm; -} - -static void -add_dir (char *name, bool sysp) -{ - cpp_dir *dir = XNEW (cpp_dir); - dir->next = cmd_line_searchpath; - dir->name = name; - dir->sysp = sysp; - dir->construct = 0; - dir->user_supplied_p = 1; - cmd_line_searchpath = dir; -} - -/* Command line processing. */ - -static void ATTRIBUTE_NORETURN -usage (int errcode) -{ - fprintf (stderr, -"usage: %s [-vh] [-V vpath] [-Dname[=def]...] [-Uname] [-Idir...] [-o file] sources...\n", - progname); - exit (errcode); -} - -static int -parse_options (int argc, char **argv) -{ - static const struct option longopts[] = { - { "--help", no_argument, 0, 'h' }, - { 0, 0, 0, 0 } - }; - - for (;;) - switch (getopt_long (argc, argv, "hD:U:I:J:o:V:", longopts, 0)) - { - case 'h': usage (0); - case 'D': add_clm (optarg, false); break; - case 'U': add_clm (optarg, true); break; - case 'I': add_dir (optarg, false); break; - case 'J': add_dir (optarg, true); break; - case 'o': - if (output_file) - { - fprintf (stderr, "%s: too many output files\n", progname); - usage (2); - } - output_file = optarg; - break; - case 'V': - if (vpath) - { - fprintf (stderr, "%s: too many vpaths\n", progname); - usage (2); - } - vpath = optarg; - break; - case '?': - usage (2); /* getopt has issued the error message. */ - - case -1: /* end of options */ - if (optind == argc) - { - fprintf (stderr, "%s: no input files\n", progname); - usage (2); - } - return optind; - - default: - abort (); - } -} - -/* Set up cpplib from command line options. */ -static cpp_reader * -reader_init (struct line_maps *line_table) -{ - cpp_reader *reader; - cpp_options *options; - - linemap_init (line_table); - reader = cpp_create_reader (CLK_GNUC89, 0, line_table); - - /* Ignore warnings and errors (we don't have access to system - headers). Request dependency output. */ - options = cpp_get_options (reader); - options->inhibit_warnings = 1; - options->inhibit_errors = 1; - options->deps.style = DEPS_USER; - - /* Further initialization. */ - cpp_post_options (reader); - cpp_init_iconv (reader); - cpp_set_include_chains (reader, cmd_line_searchpath, cmd_line_searchpath, - false); - if (vpath) - { - struct deps *deps = cpp_get_deps (reader); - deps_add_vpath (deps, vpath); - } - - return reader; -} - -/* Process one input source file. */ -static void -process_file (const char *file) -{ - struct line_maps line_table; - cpp_reader *reader = reader_init (&line_table); - - if (!cpp_read_main_file (reader, file)) - had_errors = true; - else - { - struct cmd_line_macro *clm; - - cpp_init_builtins (reader, true); - for (clm = cmd_line_macros; clm; clm = clm->next) - (clm->is_undef ? cpp_undef : cpp_define) (reader, clm->macro); - - cpp_scan_nooutput (reader); - if (cpp_finish (reader, stdout)) - had_errors = true; - } - cpp_destroy (reader); - linemap_free (&line_table); -} - -/* Master control. */ - -int -main(int argc, char **argv) -{ - int first_input, i; - - progname = argv[0]; - xmalloc_set_program_name (progname); - - first_input = parse_options (argc, argv); - if (output_file) - if (!freopen (output_file, "w", stdout)) - { - perror (output_file); - return 1; - } - - for (i = first_input; i < argc; i++) - process_file (argv[i]); - - return had_errors; -} |