diff options
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 17 | ||||
-rw-r--r-- | gcc/c-lex.c | 5 | ||||
-rw-r--r-- | gcc/cp/ChangeLog | 8 | ||||
-rw-r--r-- | gcc/cp/lex.c | 8 | ||||
-rw-r--r-- | gcc/cp/parser.c | 6 | ||||
-rw-r--r-- | gcc/diagnostic.c | 34 | ||||
-rw-r--r-- | gcc/diagnostic.h | 15 | ||||
-rw-r--r-- | gcc/input.h | 19 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/warn/pragma-system_header2.C | 4 | ||||
-rw-r--r-- | gcc/toplev.c | 74 |
11 files changed, 70 insertions, 125 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 6ba25c1..a3a5540 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,20 @@ +2008-02-29 Tom Tromey <tromey@redhat.com> + + * toplev.c (input_file_stack, input_file_stack_tick, fs_p, + input_file_stack_history, input_file_stack_restored): Remove. + (push_srcloc, pop_srcloc, restore_input_file_stack): Likewise. + * input.h (struct file_stack): Remove. + (push_srcloc, pop_srcloc, restore_input_file_stack): Likewise. + (input_file_stack, input_file_stack_tick, INPUT_FILE_STACK_BITS): + Likewise. + * diagnostic.h (struct diagnostic_context) <last_module>: Change + type. + (diagnostic_last_module_changed): Add 'map' argument. + (diagnostic_set_last_function): Likewise. + * diagnostic.c (undiagnostic_report_current_module): Iterate using + line map, not input_file_stack. + * c-lex.c (fe_file_change): Don't use push_srcloc or pop_srcloc. + 2008-02-29 Paul Brook <paul@codesourcery.com> * config/arm/arm.md (arm_addsi3): Add r/k/n alternative. diff --git a/gcc/c-lex.c b/gcc/c-lex.c index 7bc283b..617cd7e 100644 --- a/gcc/c-lex.c +++ b/gcc/c-lex.c @@ -207,8 +207,7 @@ fe_file_change (const struct line_map *new_map) { int included_at = LAST_SOURCE_LINE_LOCATION (new_map - 1); - input_location = included_at; - push_srcloc (new_map->start_location); + input_location = new_map->start_location; (*debug_hooks->start_source_file) (included_at, new_map->to_file); #ifndef NO_IMPLICIT_EXTERN_C if (c_header_level) @@ -231,7 +230,7 @@ fe_file_change (const struct line_map *new_map) --pending_lang_change; } #endif - pop_srcloc (); + input_location = new_map->start_location; (*debug_hooks->end_source_file) (new_map->to_line); } diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 562c2a5..4c0d919 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,11 @@ +2008-02-29 Tom Tromey <tromey@redhat.com> + + * parser.c (struct cp_token) <input_file_stack_index>: Remove. + (cp_lexer_get_preprocessor_token): Update. + (cp_lexer_set_source_position_from_token): Don't call + restore_input_file_stack. + * lex.c (cxx_init): Don't use push_srcloc or pop_srcloc. + 2008-02-28 Richard Guenther <rguenther@suse.de> Revert: diff --git a/gcc/cp/lex.c b/gcc/cp/lex.c index 2558a78..0b2a372 100644 --- a/gcc/cp/lex.c +++ b/gcc/cp/lex.c @@ -372,6 +372,7 @@ bool statement_code_p[MAX_TREE_CODES]; bool cxx_init (void) { + location_t saved_loc; unsigned int i; static const enum tree_code stmt_codes[] = { CTOR_INITIALIZER, TRY_BLOCK, HANDLER, @@ -385,7 +386,8 @@ cxx_init (void) for (i = 0; i < ARRAY_SIZE (stmt_codes); i++) statement_code_p[stmt_codes[i]] = true; - push_srcloc (BUILTINS_LOCATION); + saved_loc = input_location; + input_location = BUILTINS_LOCATION; init_reswords (); init_tree (); @@ -413,7 +415,7 @@ cxx_init (void) if (c_common_init () == false) { - pop_srcloc(); + input_location = saved_loc; return false; } @@ -421,7 +423,7 @@ cxx_init (void) init_repo (); - pop_srcloc(); + input_location = saved_loc; return true; } diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 77542bf..458ab7b 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -79,8 +79,6 @@ typedef struct cp_token GTY (()) KEYWORD is RID_MAX) iff this name was looked up and found to be ambiguous. An error has already been reported. */ BOOL_BITFIELD ambiguous_p : 1; - /* The input file stack index at which this token was found. */ - unsigned input_file_stack_index : INPUT_FILE_STACK_BITS; /* The value associated with this token, if any. */ union cp_token_value { /* Used for CPP_NESTED_NAME_SPECIFIER and CPP_TEMPLATE_ID. */ @@ -99,7 +97,7 @@ DEF_VEC_ALLOC_P (cp_token_position,heap); static cp_token eof_token = { - CPP_EOF, RID_MAX, 0, PRAGMA_NONE, 0, 0, false, 0, { NULL }, + CPP_EOF, RID_MAX, 0, PRAGMA_NONE, 0, false, 0, { NULL }, 0 }; @@ -408,7 +406,6 @@ cp_lexer_get_preprocessor_token (cp_lexer *lexer, cp_token *token) token->type = c_lex_with_flags (&token->u.value, &token->location, &token->flags, lexer == NULL ? 0 : C_LEX_RAW_STRINGS); - token->input_file_stack_index = input_file_stack_tick; token->keyword = RID_MAX; token->pragma_kind = PRAGMA_NONE; token->in_system_header = in_system_header; @@ -490,7 +487,6 @@ cp_lexer_set_source_position_from_token (cp_token *token) { input_location = token->location; in_system_header = token->in_system_header; - restore_input_file_stack (token->input_file_stack_index); } } diff --git a/gcc/diagnostic.c b/gcc/diagnostic.c index 05f1533..bc4e051 100644 --- a/gcc/diagnostic.c +++ b/gcc/diagnostic.c @@ -269,7 +269,7 @@ diagnostic_report_current_function (diagnostic_context *context, void diagnostic_report_current_module (diagnostic_context *context) { - struct file_stack *p; + const struct line_map *map; if (pp_needs_newline (context->printer)) { @@ -277,23 +277,29 @@ diagnostic_report_current_module (diagnostic_context *context) pp_needs_newline (context->printer) = false; } - p = input_file_stack; - if (p && diagnostic_last_module_changed (context)) + if (input_location <= BUILTINS_LOCATION) + return; + + map = linemap_lookup (line_table, input_location); + if (map && diagnostic_last_module_changed (context, map)) { - expanded_location xloc = expand_location (p->location); - pp_verbatim (context->printer, - "In file included from %s:%d", - xloc.file, xloc.line); - while ((p = p->next) != NULL) + diagnostic_set_last_module (context, map); + if (! MAIN_FILE_P (map)) { - xloc = expand_location (p->location); + map = INCLUDED_FROM (line_table, map); pp_verbatim (context->printer, - ",\n from %s:%d", - xloc.file, xloc.line); + "In file included from %s:%d", + map->to_file, LAST_SOURCE_LINE (map)); + while (! MAIN_FILE_P (map)) + { + map = INCLUDED_FROM (line_table, map); + pp_verbatim (context->printer, + ",\n from %s:%d", + map->to_file, LAST_SOURCE_LINE (map)); + } + pp_verbatim (context->printer, ":"); + pp_newline (context->printer); } - pp_verbatim (context->printer, ":"); - diagnostic_set_last_module (context); - pp_newline (context->printer); } } diff --git a/gcc/diagnostic.h b/gcc/diagnostic.h index 02e43bd..992c0c4 100644 --- a/gcc/diagnostic.h +++ b/gcc/diagnostic.h @@ -1,5 +1,5 @@ /* Various declarations for language-independent diagnostics subroutines. - Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 + Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. Contributed by Gabriel Dos Reis <gdr@codesourcery.com> @@ -110,8 +110,9 @@ struct diagnostic_context function name. */ tree last_function; - /* Used to detect when input_file_stack has changed since last described. */ - int last_module; + /* Used to detect when the input file stack has changed since last + described. */ + const struct line_map *last_module; int lock; }; @@ -152,13 +153,13 @@ struct diagnostic_context /* True if the last module or file in which a diagnostic was reported is different from the current one. */ -#define diagnostic_last_module_changed(DC) \ - ((DC)->last_module != input_file_stack_tick) +#define diagnostic_last_module_changed(DC, MAP) \ + ((DC)->last_module != MAP) /* Remember the current module or file as being the last one in which we report a diagnostic. */ -#define diagnostic_set_last_module(DC) \ - (DC)->last_module = input_file_stack_tick +#define diagnostic_set_last_module(DC, MAP) \ + (DC)->last_module = MAP /* Raise SIGABRT on any diagnostic of severity DK_ERROR or higher. */ #define diagnostic_abort_on_error(DC) \ diff --git a/gcc/input.h b/gcc/input.h index 4a3040c..5d43259 100644 --- a/gcc/input.h +++ b/gcc/input.h @@ -49,19 +49,10 @@ extern expanded_location expand_location (source_location); This could be removed but it hardly seems worth the effort. */ typedef source_location location_t; -struct file_stack -{ - struct file_stack *next; - location_t location; -}; - /* Top-level source file. */ extern const char *main_input_filename; extern location_t input_location; -extern void push_srcloc (location_t); -extern void pop_srcloc (void); -extern void restore_input_file_stack (int); #define LOCATION_FILE(LOC) ((expand_location (LOC)).file) #define LOCATION_LINE(LOC) ((expand_location (LOC)).line) @@ -69,14 +60,4 @@ extern void restore_input_file_stack (int); #define input_line LOCATION_LINE (input_location) #define input_filename LOCATION_FILE (input_location) -/* Stack of currently pending input files. - The line member is not accurate for the innermost file on the stack. */ -extern struct file_stack *input_file_stack; - -/* Incremented on each change to input_file_stack. */ -extern int input_file_stack_tick; - -/* The number of bits available for input_file_stack_tick. */ -#define INPUT_FILE_STACK_BITS 31 - #endif diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 93f2c45..951afe1 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2008-02-29 Tom Tromey <tromey@redhat.com> + + * g++.dg/warn/pragma-system_header2.C: Ignore "included from" + line. + 2008-02-29 Sebastian Pop <sebastian.pop@amd.com> * testsuite/gcc.dg/tree-ssa/ltrans-8.c: Increase the size of strides diff --git a/gcc/testsuite/g++.dg/warn/pragma-system_header2.C b/gcc/testsuite/g++.dg/warn/pragma-system_header2.C index be29474..a39bea7 100644 --- a/gcc/testsuite/g++.dg/warn/pragma-system_header2.C +++ b/gcc/testsuite/g++.dg/warn/pragma-system_header2.C @@ -3,6 +3,7 @@ #include "pragma-system_header2.h" + void f() { g<int>(); @@ -11,3 +12,6 @@ void f() // { dg-warning "conversion" "" { target *-*-* } 2 } // { dg-warning "conversion" "" { target *-*-* } 5 } + +// I couldn't find another way to make this work. +// { dg-prune-output "In file included from" } diff --git a/gcc/toplev.c b/gcc/toplev.c index cf0ec2a..5b1600c 100644 --- a/gcc/toplev.c +++ b/gcc/toplev.c @@ -144,23 +144,6 @@ location_t input_location; struct line_maps *line_table; -/* Stack of currently pending input files. */ - -struct file_stack *input_file_stack; - -/* Incremented on each change to input_file_stack. */ -int input_file_stack_tick; - -/* Record of input_file_stack at each tick. */ -typedef struct file_stack *fs_p; -DEF_VEC_P(fs_p); -DEF_VEC_ALLOC_P(fs_p,heap); -static VEC(fs_p,heap) *input_file_stack_history; - -/* Whether input_file_stack has been restored to a previous state (in - which case there should be no more pushing). */ -static bool input_file_stack_restored; - /* Name to use as base of names for dump output files. */ const char *dump_base_name; @@ -953,63 +936,6 @@ warn_deprecated_use (tree node) } } -/* Save the current INPUT_LOCATION on the top entry in the - INPUT_FILE_STACK. Push a new entry for FILE and LINE, and set the - INPUT_LOCATION accordingly. */ - -void -push_srcloc (location_t fline) -{ - struct file_stack *fs; - - gcc_assert (!input_file_stack_restored); - if (input_file_stack_tick == (int) ((1U << INPUT_FILE_STACK_BITS) - 1)) - sorry ("GCC supports only %d input file changes", input_file_stack_tick); - - fs = XNEW (struct file_stack); - fs->location = input_location; - fs->next = input_file_stack; - input_location = fline; - input_file_stack = fs; - input_file_stack_tick++; - VEC_safe_push (fs_p, heap, input_file_stack_history, input_file_stack); -} - -/* Pop the top entry off the stack of presently open source files. - Restore the INPUT_LOCATION from the new topmost entry on the - stack. */ - -void -pop_srcloc (void) -{ - struct file_stack *fs; - - gcc_assert (!input_file_stack_restored); - if (input_file_stack_tick == (int) ((1U << INPUT_FILE_STACK_BITS) - 1)) - sorry ("GCC supports only %d input file changes", input_file_stack_tick); - - fs = input_file_stack; - input_location = fs->location; - input_file_stack = fs->next; - input_file_stack_tick++; - VEC_safe_push (fs_p, heap, input_file_stack_history, input_file_stack); -} - -/* Restore the input file stack to its state as of TICK, for the sake - of diagnostics after processing the whole input. Once this has - been called, push_srcloc and pop_srcloc may no longer be - called. */ -void -restore_input_file_stack (int tick) -{ - if (tick == 0) - input_file_stack = NULL; - else - input_file_stack = VEC_index (fs_p, input_file_stack_history, tick - 1); - input_file_stack_tick = tick; - input_file_stack_restored = true; -} - /* Compile an entire translation unit. Write a file of assembly output and various debugging dumps. */ |