* 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.
gcc/cp
* 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.
gcc/testsuite
* g++.dg/warn/pragma-system_header2.C: Ignore "included from"
line.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@132775
138bc75d-0d04-0410-961f-
82ee72b054a4
+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.
{
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)
--pending_lang_change;
}
#endif
- pop_srcloc ();
+ input_location = new_map->start_location;
(*debug_hooks->end_source_file) (new_map->to_line);
}
+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:
bool
cxx_init (void)
{
+ location_t saved_loc;
unsigned int i;
static const enum tree_code stmt_codes[] = {
CTOR_INITIALIZER, TRY_BLOCK, HANDLER,
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 ();
if (c_common_init () == false)
{
- pop_srcloc();
+ input_location = saved_loc;
return false;
}
init_repo ();
- pop_srcloc();
+ input_location = saved_loc;
return true;
}
\f
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. */
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
};
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;
{
input_location = token->location;
in_system_header = token->in_system_header;
- restore_input_file_stack (token->input_file_stack_index);
}
}
void
diagnostic_report_current_module (diagnostic_context *context)
{
- struct file_stack *p;
+ const struct line_map *map;
if (pp_needs_newline (context->printer))
{
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);
}
}
/* 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>
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;
};
/* 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) \
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)
#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
+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
#include "pragma-system_header2.h"
+
void f()
{
g<int>();
// { 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" }
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;
}
}
-/* 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. */