tree-cfg.c (remove_bb): Only warn if line is non-zero.

gcc:
	* tree-cfg.c (remove_bb): Only warn if line is non-zero.
	* c-pch.c (c_common_read_pch): Restore current location after
	reading PCH file.
	* tree.c (expand_location): Update.
	(expr_filename): Changed return type.  Unified the two cases.
	(expr_lineno): Likewise.
	(annotate_with_file_line): Don't use EXPR_LINENO and EXPR_FILENAME
	as lvalues.
	* toplev.c (line_table): Changed type.
	(general_init): Update.
	(realloc_for_line_map): New function.
	(general_init): Allocate line_table using GC.
	* fix-header.c (line_table): Changed type.
	(read_scan_file): Update.
	(read_scan_file): Update.
	* c-ppoutput.c (maybe_print_line): Update.
	(print_line): Update.
	(cb_line_change): Update.
	(cb_define): Update.
	(pp_file_change): Update.
	* c-opts.c (c_common_init_options): Update.
	(finish_options): Update.
	(push_command_line_include): Update.
	* c-lex.c (cb_line_change): Update.
	(cb_def_pragma): Update.
	(cb_define): Update.
	(cb_undef): Update.
	(c_lex_with_flags): Use cpp_get_token_with_location.
	* input.h (line_table): Changed type.
	(location_from_locus): New macro.
	* tree.h (EXPR_FILENAME): No longer an lvalue.
	(EXPR_LINENO): Likewise.
	(expr_locus, set_expr_locus): Declare separately for
	USE_MAPPED_LOCATION.
	(expr_filename, expr_lineno): Changed return type.
	* gimplify.c (tree_to_gimple_tuple): Use SET_EXPR_LOCUS.
	* cfgexpand.c (expand_gimple_cond_expr): Use location_from_locus.
	(expand_gimple_basic_block): Likewise.
	* final.c (final_scan_insn): Use expanded_location.
gcc/cp:
	* decl.c (finish_function): Put return's location on line zero of
	file.
gcc/fortran:
	* scanner.c (get_file): Update.
	(load_file): Update.
	(gfc_next_char_literal): Use gfc_linebuf_linenum.
	* f95-lang.c (gfc_init): Update.
	* gfortran.h (gfc_linebuf_linenum): New macro.
gcc/java:
	* lang.c (java_post_options): Update.
	* jcf-parse.c (set_source_filename): Update.
	(give_name_to_class): Update.
	(jcf_parse): Update.
	(duplicate_class_warning): Update.
	(parse_class_file): Update.
	(java_parse_file): Update.
	* expr.c (expand_byte_code): Update.
gcc/testsuite:
	* lib/g++.exp (g++_target_compile): Use -fno-show-column.
gcc/treelang:
	* tree1.c (treelang_init): Update.
	(treelang_parse_file): Update.
	(treelang_parse_file): Update.
	(treelang_parse_file): Update.
	* lex.l: Update.
	(update_lineno_charno): Likewise.
libcpp:
	* internal.h (struct cpp_reader) <invocation_location>: New
	field.
	(struct cpp_reader) <set_invocation_location>: Likewise.
	* init.c (cpp_set_line_map): New function.
	* line-map.c (linemap_add): Use linemap's allocator.
	* include/line-map.h (GTY): Define.
	(line_map_realloc): New typedef.
	(struct line_map): Mark with GTY.
	(struct line_maps): Likewise.
	(struct line_maps) <maps>: Likewise.
	(struct line_maps) <reallocator>: New field.
	* include/symtab.h (GTY): Conditionally define.
	* include/cpplib.h (cpp_set_line_map): Declare.
	(cpp_get_token_with_location): Declare.
	* macro.c (cpp_get_token): Set invocation_location on the reader.
	(cpp_get_token_with_location): New function.

From-SVN: r128190
This commit is contained in:
Tom Tromey 2007-09-06 16:24:05 +00:00 committed by Tom Tromey
parent 111f1fca4d
commit 5ffeb913b1
36 changed files with 329 additions and 118 deletions

View File

@ -1,3 +1,45 @@
2007-09-06 Tom Tromey <tromey@redhat.com>
* tree-cfg.c (remove_bb): Only warn if line is non-zero.
* c-pch.c (c_common_read_pch): Restore current location after
reading PCH file.
* tree.c (expand_location): Update.
(expr_filename): Changed return type. Unified the two cases.
(expr_lineno): Likewise.
(annotate_with_file_line): Don't use EXPR_LINENO and EXPR_FILENAME
as lvalues.
* toplev.c (line_table): Changed type.
(general_init): Update.
(realloc_for_line_map): New function.
(general_init): Allocate line_table using GC.
* fix-header.c (line_table): Changed type.
(read_scan_file): Update.
(read_scan_file): Update.
* c-ppoutput.c (maybe_print_line): Update.
(print_line): Update.
(cb_line_change): Update.
(cb_define): Update.
(pp_file_change): Update.
* c-opts.c (c_common_init_options): Update.
(finish_options): Update.
(push_command_line_include): Update.
* c-lex.c (cb_line_change): Update.
(cb_def_pragma): Update.
(cb_define): Update.
(cb_undef): Update.
(c_lex_with_flags): Use cpp_get_token_with_location.
* input.h (line_table): Changed type.
(location_from_locus): New macro.
* tree.h (EXPR_FILENAME): No longer an lvalue.
(EXPR_LINENO): Likewise.
(expr_locus, set_expr_locus): Declare separately for
USE_MAPPED_LOCATION.
(expr_filename, expr_lineno): Changed return type.
* gimplify.c (tree_to_gimple_tuple): Use SET_EXPR_LOCUS.
* cfgexpand.c (expand_gimple_cond_expr): Use location_from_locus.
(expand_gimple_basic_block): Likewise.
* final.c (final_scan_insn): Use expanded_location.
2007-09-06 Richard Guenther <rguenther@suse.de> 2007-09-06 Richard Guenther <rguenther@suse.de>
PR tree-optimization/32586 PR tree-optimization/32586

View File

@ -205,7 +205,7 @@ cb_line_change (cpp_reader * ARG_UNUSED (pfile), const cpp_token *token,
#else #else
{ {
source_location loc = token->src_loc; source_location loc = token->src_loc;
const struct line_map *map = linemap_lookup (&line_table, loc); const struct line_map *map = linemap_lookup (line_table, loc);
input_line = SOURCE_LINE (map, loc); input_line = SOURCE_LINE (map, loc);
} }
#endif #endif
@ -283,7 +283,7 @@ cb_def_pragma (cpp_reader *pfile, source_location loc)
const cpp_token *s; const cpp_token *s;
#ifndef USE_MAPPED_LOCATION #ifndef USE_MAPPED_LOCATION
location_t fe_loc; location_t fe_loc;
const struct line_map *map = linemap_lookup (&line_table, loc); const struct line_map *map = linemap_lookup (line_table, loc);
fe_loc.file = map->to_file; fe_loc.file = map->to_file;
fe_loc.line = SOURCE_LINE (map, loc); fe_loc.line = SOURCE_LINE (map, loc);
#else #else
@ -309,7 +309,7 @@ cb_def_pragma (cpp_reader *pfile, source_location loc)
static void static void
cb_define (cpp_reader *pfile, source_location loc, cpp_hashnode *node) cb_define (cpp_reader *pfile, source_location loc, cpp_hashnode *node)
{ {
const struct line_map *map = linemap_lookup (&line_table, loc); const struct line_map *map = linemap_lookup (line_table, loc);
(*debug_hooks->define) (SOURCE_LINE (map, loc), (*debug_hooks->define) (SOURCE_LINE (map, loc),
(const char *) cpp_macro_definition (pfile, node)); (const char *) cpp_macro_definition (pfile, node));
} }
@ -319,7 +319,7 @@ static void
cb_undef (cpp_reader * ARG_UNUSED (pfile), source_location loc, cb_undef (cpp_reader * ARG_UNUSED (pfile), source_location loc,
cpp_hashnode *node) cpp_hashnode *node)
{ {
const struct line_map *map = linemap_lookup (&line_table, loc); const struct line_map *map = linemap_lookup (line_table, loc);
(*debug_hooks->undef) (SOURCE_LINE (map, loc), (*debug_hooks->undef) (SOURCE_LINE (map, loc),
(const char *) NODE_NAME (node)); (const char *) NODE_NAME (node));
} }
@ -338,15 +338,15 @@ c_lex_with_flags (tree *value, location_t *loc, unsigned char *cpp_flags)
timevar_push (TV_CPP); timevar_push (TV_CPP);
retry: retry:
#ifdef USE_MAPPED_LOCATION
tok = cpp_get_token_with_location (parse_in, loc);
#else
tok = cpp_get_token (parse_in); tok = cpp_get_token (parse_in);
*loc = input_location;
#endif
type = tok->type; type = tok->type;
retry_after_at: retry_after_at:
#ifdef USE_MAPPED_LOCATION
*loc = tok->src_loc;
#else
*loc = input_location;
#endif
switch (type) switch (type)
{ {
case CPP_PADDING: case CPP_PADDING:
@ -390,10 +390,19 @@ c_lex_with_flags (tree *value, location_t *loc, unsigned char *cpp_flags)
/* An @ may give the next token special significance in Objective-C. */ /* An @ may give the next token special significance in Objective-C. */
if (c_dialect_objc ()) if (c_dialect_objc ())
{ {
#ifdef USE_MAPPED_LOCATION
location_t atloc = *loc;
location_t newloc;
#else
location_t atloc = input_location; location_t atloc = input_location;
#endif
retry_at: retry_at:
#ifdef USE_MAPPED_LOCATION
tok = cpp_get_token_with_location (parse_in, &newloc);
#else
tok = cpp_get_token (parse_in); tok = cpp_get_token (parse_in);
#endif
type = tok->type; type = tok->type;
switch (type) switch (type)
{ {
@ -417,6 +426,9 @@ c_lex_with_flags (tree *value, location_t *loc, unsigned char *cpp_flags)
default: default:
/* ... or not. */ /* ... or not. */
error ("%Hstray %<@%> in program", &atloc); error ("%Hstray %<@%> in program", &atloc);
#ifdef USE_MAPPED_LOCATION
*loc = newloc;
#endif
goto retry_after_at; goto retry_after_at;
} }
break; break;

View File

@ -218,7 +218,7 @@ c_common_init_options (unsigned int argc, const char **argv)
} }
parse_in = cpp_create_reader (c_dialect_cxx () ? CLK_GNUCXX: CLK_GNUC89, parse_in = cpp_create_reader (c_dialect_cxx () ? CLK_GNUCXX: CLK_GNUC89,
ident_hash, &line_table); ident_hash, line_table);
cpp_opts = cpp_get_options (parse_in); cpp_opts = cpp_get_options (parse_in);
cpp_opts->dollars_in_ident = DOLLARS_IN_IDENTIFIERS; cpp_opts->dollars_in_ident = DOLLARS_IN_IDENTIFIERS;
@ -1485,7 +1485,7 @@ finish_options (void)
size_t i; size_t i;
cb_file_change (parse_in, cb_file_change (parse_in,
linemap_add (&line_table, LC_RENAME, 0, linemap_add (line_table, LC_RENAME, 0,
_("<built-in>"), 0)); _("<built-in>"), 0));
cpp_init_builtins (parse_in, flag_hosted); cpp_init_builtins (parse_in, flag_hosted);
@ -1503,7 +1503,7 @@ finish_options (void)
cpp_opts->warn_dollars = (cpp_opts->pedantic && !cpp_opts->c99); cpp_opts->warn_dollars = (cpp_opts->pedantic && !cpp_opts->c99);
cb_file_change (parse_in, cb_file_change (parse_in,
linemap_add (&line_table, LC_RENAME, 0, linemap_add (line_table, LC_RENAME, 0,
_("<command-line>"), 0)); _("<command-line>"), 0));
for (i = 0; i < deferred_count; i++) for (i = 0; i < deferred_count; i++)
@ -1568,7 +1568,7 @@ push_command_line_include (void)
/* Set this here so the client can change the option if it wishes, /* Set this here so the client can change the option if it wishes,
and after stacking the main file so we don't trace the main file. */ and after stacking the main file so we don't trace the main file. */
line_table.trace_includes = cpp_opts->print_include_names; line_table->trace_includes = cpp_opts->print_include_names;
} }
} }

View File

@ -33,6 +33,7 @@ along with GCC; see the file COPYING3. If not see
#include "langhooks.h" #include "langhooks.h"
#include "hosthooks.h" #include "hosthooks.h"
#include "target.h" #include "target.h"
#include "opts.h"
/* This is a list of flag variables that must match exactly, and their /* This is a list of flag variables that must match exactly, and their
names for the error message. The possible values for *flag_var must names for the error message. The possible values for *flag_var must
@ -365,6 +366,7 @@ c_common_read_pch (cpp_reader *pfile, const char *name,
FILE *f; FILE *f;
struct c_pch_header h; struct c_pch_header h;
struct save_macro_data *smd; struct save_macro_data *smd;
expanded_location saved_loc;
f = fdopen (fd, "rb"); f = fdopen (fd, "rb");
if (f == NULL) if (f == NULL)
@ -406,6 +408,18 @@ c_common_read_pch (cpp_reader *pfile, const char *name,
cpp_errno (pfile, CPP_DL_ERROR, "seeking"); cpp_errno (pfile, CPP_DL_ERROR, "seeking");
} }
/* Save the location and then restore it after reading the PCH. */
#ifdef USE_MAPPED_LOCATION
saved_loc = expand_location (line_table->highest_line);
#else
{
const struct line_map *map = linemap_lookup (line_table,
line_table->highest_line);
saved_loc.file = map->to_file;
saved_loc.line = SOURCE_LINE (map, line_table->highest_line);
}
#endif
cpp_prepare_state (pfile, &smd); cpp_prepare_state (pfile, &smd);
gt_pch_restore (f); gt_pch_restore (f);
@ -415,6 +429,9 @@ c_common_read_pch (cpp_reader *pfile, const char *name,
fclose (f); fclose (f);
cpp_set_line_map (pfile, line_table);
linemap_add (line_table, LC_RENAME, 0, saved_loc.file, saved_loc.line);
/* Give the front end a chance to take action after a PCH file has /* Give the front end a chance to take action after a PCH file has
been loaded. */ been loaded. */
if (lang_post_pch_load) if (lang_post_pch_load)

View File

@ -234,7 +234,7 @@ scan_translation_unit_trad (cpp_reader *pfile)
static void static void
maybe_print_line (source_location src_loc) maybe_print_line (source_location src_loc)
{ {
const struct line_map *map = linemap_lookup (&line_table, src_loc); const struct line_map *map = linemap_lookup (line_table, src_loc);
int src_line = SOURCE_LINE (map, src_loc); int src_line = SOURCE_LINE (map, src_loc);
/* End the previous line of text. */ /* End the previous line of text. */
if (print.printed) if (print.printed)
@ -268,7 +268,7 @@ print_line (source_location src_loc, const char *special_flags)
if (!flag_no_line_commands) if (!flag_no_line_commands)
{ {
const struct line_map *map = linemap_lookup (&line_table, src_loc); const struct line_map *map = linemap_lookup (line_table, src_loc);
size_t to_file_len = strlen (map->to_file); size_t to_file_len = strlen (map->to_file);
unsigned char *to_file_quoted = unsigned char *to_file_quoted =
@ -317,7 +317,7 @@ cb_line_change (cpp_reader *pfile, const cpp_token *token,
ought to care. Some things do care; the fault lies with them. */ ought to care. Some things do care; the fault lies with them. */
if (!CPP_OPTION (pfile, traditional)) if (!CPP_OPTION (pfile, traditional))
{ {
const struct line_map *map = linemap_lookup (&line_table, src_loc); const struct line_map *map = linemap_lookup (line_table, src_loc);
int spaces = SOURCE_COLUMN (map, src_loc) - 2; int spaces = SOURCE_COLUMN (map, src_loc) - 2;
print.printed = 1; print.printed = 1;
@ -349,7 +349,7 @@ cb_define (cpp_reader *pfile, source_location line, cpp_hashnode *node)
fputs ((const char *) NODE_NAME (node), print.outf); fputs ((const char *) NODE_NAME (node), print.outf);
putc ('\n', print.outf); putc ('\n', print.outf);
if (linemap_lookup (&line_table, line)->to_line != 0) if (linemap_lookup (line_table, line)->to_line != 0)
print.src_line++; print.src_line++;
} }
@ -430,7 +430,7 @@ pp_file_change (const struct line_map *map)
/* Bring current file to correct line when entering a new file. */ /* Bring current file to correct line when entering a new file. */
if (map->reason == LC_ENTER) if (map->reason == LC_ENTER)
{ {
const struct line_map *from = INCLUDED_FROM (&line_table, map); const struct line_map *from = INCLUDED_FROM (line_table, map);
maybe_print_line (LAST_SOURCE_LINE_LOCATION (from)); maybe_print_line (LAST_SOURCE_LINE_LOCATION (from));
} }
if (map->reason == LC_ENTER) if (map->reason == LC_ENTER)

View File

@ -1312,7 +1312,7 @@ expand_gimple_cond_expr (basic_block bb, tree stmt)
add_reg_br_prob_note (last, true_edge->probability); add_reg_br_prob_note (last, true_edge->probability);
maybe_dump_rtl_for_tree_stmt (stmt, last); maybe_dump_rtl_for_tree_stmt (stmt, last);
if (true_edge->goto_locus) if (true_edge->goto_locus)
set_curr_insn_source_location (*true_edge->goto_locus); set_curr_insn_source_location (location_from_locus (true_edge->goto_locus));
false_edge->flags |= EDGE_FALLTHRU; false_edge->flags |= EDGE_FALLTHRU;
return NULL; return NULL;
} }
@ -1322,7 +1322,7 @@ expand_gimple_cond_expr (basic_block bb, tree stmt)
add_reg_br_prob_note (last, false_edge->probability); add_reg_br_prob_note (last, false_edge->probability);
maybe_dump_rtl_for_tree_stmt (stmt, last); maybe_dump_rtl_for_tree_stmt (stmt, last);
if (false_edge->goto_locus) if (false_edge->goto_locus)
set_curr_insn_source_location (*false_edge->goto_locus); set_curr_insn_source_location (location_from_locus (false_edge->goto_locus));
true_edge->flags |= EDGE_FALLTHRU; true_edge->flags |= EDGE_FALLTHRU;
return NULL; return NULL;
} }
@ -1353,7 +1353,7 @@ expand_gimple_cond_expr (basic_block bb, tree stmt)
maybe_dump_rtl_for_tree_stmt (stmt, last2); maybe_dump_rtl_for_tree_stmt (stmt, last2);
if (false_edge->goto_locus) if (false_edge->goto_locus)
set_curr_insn_source_location (*false_edge->goto_locus); set_curr_insn_source_location (location_from_locus (false_edge->goto_locus));
return new_bb; return new_bb;
} }
@ -1620,7 +1620,7 @@ expand_gimple_basic_block (basic_block bb)
{ {
emit_jump (label_rtx_for_bb (e->dest)); emit_jump (label_rtx_for_bb (e->dest));
if (e->goto_locus) if (e->goto_locus)
set_curr_insn_source_location (*e->goto_locus); set_curr_insn_source_location (location_from_locus (e->goto_locus));
e->flags &= ~EDGE_FALLTHRU; e->flags &= ~EDGE_FALLTHRU;
} }

View File

@ -1,3 +1,8 @@
2007-09-06 Tom Tromey <tromey@redhat.com>
* decl.c (finish_function): Put return's location on line zero of
file.
2007-09-05 Jason Merrill <jason@redhat.com> 2007-09-05 Jason Merrill <jason@redhat.com>
PR c++/15745 PR c++/15745

View File

@ -11632,7 +11632,10 @@ finish_function (int flags)
return is unreachable, so put the statement on the return is unreachable, so put the statement on the
special line 0. */ special line 0. */
#ifdef USE_MAPPED_LOCATION #ifdef USE_MAPPED_LOCATION
SET_EXPR_LOCATION (stmt, UNKNOWN_LOCATION); {
location_t linezero = linemap_line_start (line_table, 0, 1);
SET_EXPR_LOCATION (stmt, linezero);
}
#else #else
annotate_with_file_line (stmt, input_filename, 0); annotate_with_file_line (stmt, input_filename, 0);
#endif #endif

View File

@ -2092,7 +2092,7 @@ final_scan_insn (rtx insn, FILE *file, int optimize ATTRIBUTE_UNUSED,
if (string[0]) if (string[0])
{ {
location_t loc; expanded_location loc;
if (! app_on) if (! app_on)
{ {
@ -2100,7 +2100,7 @@ final_scan_insn (rtx insn, FILE *file, int optimize ATTRIBUTE_UNUSED,
app_on = 1; app_on = 1;
} }
#ifdef USE_MAPPED_LOCATION #ifdef USE_MAPPED_LOCATION
loc = ASM_INPUT_SOURCE_LOCATION (body); loc = expand_location (ASM_INPUT_SOURCE_LOCATION (body));
#else #else
loc.file = ASM_INPUT_SOURCE_FILE (body); loc.file = ASM_INPUT_SOURCE_FILE (body);
loc.line = ASM_INPUT_SOURCE_LINE (body); loc.line = ASM_INPUT_SOURCE_LINE (body);
@ -2124,6 +2124,7 @@ final_scan_insn (rtx insn, FILE *file, int optimize ATTRIBUTE_UNUSED,
rtx *ops = alloca (noperands * sizeof (rtx)); rtx *ops = alloca (noperands * sizeof (rtx));
const char *string; const char *string;
location_t loc; location_t loc;
expanded_location expanded;
/* There's no telling what that did to the condition codes. */ /* There's no telling what that did to the condition codes. */
CC_STATUS_INIT; CC_STATUS_INIT;
@ -2133,6 +2134,7 @@ final_scan_insn (rtx insn, FILE *file, int optimize ATTRIBUTE_UNUSED,
/* Inhibit dieing on what would otherwise be compiler bugs. */ /* Inhibit dieing on what would otherwise be compiler bugs. */
insn_noperands = noperands; insn_noperands = noperands;
this_is_asm_operands = insn; this_is_asm_operands = insn;
expanded = expand_location (loc);
#ifdef FINAL_PRESCAN_INSN #ifdef FINAL_PRESCAN_INSN
FINAL_PRESCAN_INSN (insn, ops, insn_noperands); FINAL_PRESCAN_INSN (insn, ops, insn_noperands);
@ -2146,12 +2148,12 @@ final_scan_insn (rtx insn, FILE *file, int optimize ATTRIBUTE_UNUSED,
fputs (ASM_APP_ON, file); fputs (ASM_APP_ON, file);
app_on = 1; app_on = 1;
} }
if (loc.file && loc.line) if (expanded.file && expanded.line)
fprintf (asm_out_file, "%s %i \"%s\" 1\n", fprintf (asm_out_file, "%s %i \"%s\" 1\n",
ASM_COMMENT_START, loc.line, loc.file); ASM_COMMENT_START, expanded.line, expanded.file);
output_asm_insn (string, ops); output_asm_insn (string, ops);
#if HAVE_AS_LINE_ZERO #if HAVE_AS_LINE_ZERO
if (loc.file && loc.line) if (expanded.file && expanded.line)
fprintf (asm_out_file, "%s 0 \"\" 2\n", ASM_COMMENT_START); fprintf (asm_out_file, "%s 0 \"\" 2\n", ASM_COMMENT_START);
#endif #endif
} }

View File

@ -1,3 +1,11 @@
2007-09-06 Tom Tromey <tromey@redhat.com>
* scanner.c (get_file): Update.
(load_file): Update.
(gfc_next_char_literal): Use gfc_linebuf_linenum.
* f95-lang.c (gfc_init): Update.
* gfortran.h (gfc_linebuf_linenum): New macro.
2007-09-05 Sandra Loosemore <sandra@codesourcery.com> 2007-09-05 Sandra Loosemore <sandra@codesourcery.com>
* trans-decl.c (build_entry_thunks): Use set_cfun. * trans-decl.c (build_entry_thunks): Use set_cfun.

View File

@ -316,8 +316,8 @@ static bool
gfc_init (void) gfc_init (void)
{ {
#ifdef USE_MAPPED_LOCATION #ifdef USE_MAPPED_LOCATION
linemap_add (&line_table, LC_ENTER, false, gfc_source_file, 1); linemap_add (line_table, LC_ENTER, false, gfc_source_file, 1);
linemap_add (&line_table, LC_RENAME, false, "<built-in>", 0); linemap_add (line_table, LC_RENAME, false, "<built-in>", 0);
#endif #endif
/* First initialize the backend. */ /* First initialize the backend. */

View File

@ -696,6 +696,12 @@ typedef struct gfc_linebuf
#define gfc_linebuf_header_size (offsetof (gfc_linebuf, line)) #define gfc_linebuf_header_size (offsetof (gfc_linebuf, line))
#ifdef USE_MAPPED_LOCATION
#define gfc_linebuf_linenum(LBUF) (LOCATION_LINE ((LBUF)->location))
#else
#define gfc_linebuf_linenum(LBUF) ((LBUF)->linenum)
#endif
typedef struct typedef struct
{ {
char *nextc; char *nextc;

View File

@ -710,7 +710,7 @@ restart:
/* We've got a continuation line. If we are on the very next line after /* We've got a continuation line. If we are on the very next line after
the last continuation, increment the continuation line count and the last continuation, increment the continuation line count and
check whether the limit has been exceeded. */ check whether the limit has been exceeded. */
if (gfc_current_locus.lb->linenum == continue_line + 1) if (gfc_linebuf_linenum (gfc_current_locus.lb) == continue_line + 1)
{ {
if (++continue_count == gfc_option.max_continue_free) if (++continue_count == gfc_option.max_continue_free)
{ {
@ -719,7 +719,7 @@ restart:
"statement at %C", gfc_option.max_continue_free); "statement at %C", gfc_option.max_continue_free);
} }
} }
continue_line = gfc_current_locus.lb->linenum; continue_line = gfc_linebuf_linenum (gfc_current_locus.lb);
/* Now find where it continues. First eat any comment lines. */ /* Now find where it continues. First eat any comment lines. */
openmp_cond_flag = skip_free_comments (); openmp_cond_flag = skip_free_comments ();
@ -831,7 +831,7 @@ restart:
/* We've got a continuation line. If we are on the very next line after /* We've got a continuation line. If we are on the very next line after
the last continuation, increment the continuation line count and the last continuation, increment the continuation line count and
check whether the limit has been exceeded. */ check whether the limit has been exceeded. */
if (gfc_current_locus.lb->linenum == continue_line + 1) if (gfc_linebuf_linenum (gfc_current_locus.lb) == continue_line + 1)
{ {
if (++continue_count == gfc_option.max_continue_fixed) if (++continue_count == gfc_option.max_continue_fixed)
{ {
@ -842,8 +842,8 @@ restart:
} }
} }
if (continue_line < gfc_current_locus.lb->linenum) if (continue_line < gfc_linebuf_linenum (gfc_current_locus.lb))
continue_line = gfc_current_locus.lb->linenum; continue_line = gfc_linebuf_linenum (gfc_current_locus.lb);
} }
/* Ready to read first character of continuation line, which might /* Ready to read first character of continuation line, which might
@ -1170,7 +1170,7 @@ get_file (const char *name, enum lc_reason reason ATTRIBUTE_UNUSED)
f->inclusion_line = current_file->line; f->inclusion_line = current_file->line;
#ifdef USE_MAPPED_LOCATION #ifdef USE_MAPPED_LOCATION
linemap_add (&line_table, reason, false, f->filename, 1); linemap_add (line_table, reason, false, f->filename, 1);
#endif #endif
return f; return f;
@ -1514,7 +1514,7 @@ load_file (const char *filename, bool initial)
#ifdef USE_MAPPED_LOCATION #ifdef USE_MAPPED_LOCATION
b->location b->location
= linemap_line_start (&line_table, current_file->line++, 120); = linemap_line_start (line_table, current_file->line++, 120);
#else #else
b->linenum = current_file->line++; b->linenum = current_file->line++;
#endif #endif
@ -1537,7 +1537,7 @@ load_file (const char *filename, bool initial)
current_file = current_file->up; current_file = current_file->up;
#ifdef USE_MAPPED_LOCATION #ifdef USE_MAPPED_LOCATION
linemap_add (&line_table, LC_LEAVE, 0, NULL, 0); linemap_add (line_table, LC_LEAVE, 0, NULL, 0);
#endif #endif
return SUCCESS; return SUCCESS;
} }

View File

@ -3607,7 +3607,7 @@ tree_to_gimple_tuple (tree *tp)
/* The set to base above overwrites the CODE. */ /* The set to base above overwrites the CODE. */
TREE_SET_CODE ((tree) gs, GIMPLE_MODIFY_STMT); TREE_SET_CODE ((tree) gs, GIMPLE_MODIFY_STMT);
gs->locus = EXPR_LOCUS (*tp); SET_EXPR_LOCUS ((tree) gs, EXPR_LOCUS (*tp));
gs->operands[0] = TREE_OPERAND (*tp, 0); gs->operands[0] = TREE_OPERAND (*tp, 0);
gs->operands[1] = TREE_OPERAND (*tp, 1); gs->operands[1] = TREE_OPERAND (*tp, 1);
gs->block = TREE_BLOCK (*tp); gs->block = TREE_BLOCK (*tp);

View File

@ -23,7 +23,7 @@ along with GCC; see the file COPYING3. If not see
#define GCC_INPUT_H #define GCC_INPUT_H
#include "line-map.h" #include "line-map.h"
extern struct line_maps line_table; extern GTY(()) struct line_maps *line_table;
/* The location for declarations in "<built-in>" */ /* The location for declarations in "<built-in>" */
#define BUILTINS_LOCATION ((source_location) 2) #define BUILTINS_LOCATION ((source_location) 2)
@ -50,6 +50,8 @@ extern expanded_location expand_location (source_location);
typedef source_location location_t; /* deprecated typedef */ typedef source_location location_t; /* deprecated typedef */
typedef source_location source_locus; /* to be removed */ typedef source_location source_locus; /* to be removed */
#define location_from_locus(LOCUS) (LOCUS)
#else /* ! USE_MAPPED_LOCATION */ #else /* ! USE_MAPPED_LOCATION */
struct location_s GTY(()) struct location_s GTY(())
@ -69,6 +71,8 @@ typedef location_t *source_locus;
extern location_t unknown_location; extern location_t unknown_location;
#define UNKNOWN_LOCATION unknown_location #define UNKNOWN_LOCATION unknown_location
#define location_from_locus(LOCUS) (* (LOCUS))
#endif /* ! USE_MAPPED_LOCATION */ #endif /* ! USE_MAPPED_LOCATION */
struct file_stack struct file_stack

View File

@ -1,3 +1,14 @@
2007-09-06 Tom Tromey <tromey@redhat.com>
* lang.c (java_post_options): Update.
* jcf-parse.c (set_source_filename): Update.
(give_name_to_class): Update.
(jcf_parse): Update.
(duplicate_class_warning): Update.
(parse_class_file): Update.
(java_parse_file): Update.
* expr.c (expand_byte_code): Update.
2007-09-05 Sandra Loosemore <sandra@codesourcery.com> 2007-09-05 Sandra Loosemore <sandra@codesourcery.com>
* decl.c (finish_method): Use set_cfun. * decl.c (finish_method): Use set_cfun.

View File

@ -3194,7 +3194,7 @@ expand_byte_code (JCF *jcf, tree method)
{ {
int line = GET_u2 (linenumber_pointer - 2); int line = GET_u2 (linenumber_pointer - 2);
#ifdef USE_MAPPED_LOCATION #ifdef USE_MAPPED_LOCATION
input_location = linemap_line_start (&line_table, line, 1); input_location = linemap_line_start (line_table, line, 1);
#else #else
input_location.line = line; input_location.line = line;
#endif #endif

View File

@ -365,7 +365,7 @@ set_source_filename (JCF *jcf, int index)
sfname = find_sourcefile (sfname); sfname = find_sourcefile (sfname);
#ifdef USE_MAPPED_LOCATION #ifdef USE_MAPPED_LOCATION
line_table.maps[line_table.used-1].to_file = sfname; line_table->maps[line_table->used-1].to_file = sfname;
#else #else
input_filename = sfname; input_filename = sfname;
DECL_SOURCE_LOCATION (TYPE_NAME (current_class)) = input_location; DECL_SOURCE_LOCATION (TYPE_NAME (current_class)) = input_location;
@ -1209,8 +1209,8 @@ give_name_to_class (JCF *jcf, int i)
{ {
tree source_name = identifier_subst (class_name, "", '.', '/', ".java"); tree source_name = identifier_subst (class_name, "", '.', '/', ".java");
const char *sfname = IDENTIFIER_POINTER (source_name); const char *sfname = IDENTIFIER_POINTER (source_name);
linemap_add (&line_table, LC_ENTER, false, sfname, 0); linemap_add (line_table, LC_ENTER, false, sfname, 0);
input_location = linemap_line_start (&line_table, 0, 1); input_location = linemap_line_start (line_table, 0, 1);
file_start_location = input_location; file_start_location = input_location;
DECL_SOURCE_LOCATION (TYPE_NAME (this_class)) = input_location; DECL_SOURCE_LOCATION (TYPE_NAME (this_class)) = input_location;
if (main_input_filename == NULL && jcf == main_jcf) if (main_input_filename == NULL && jcf == main_jcf)
@ -1497,7 +1497,7 @@ jcf_parse (JCF* jcf)
annotation_write_byte (JV_DONE_ATTR); annotation_write_byte (JV_DONE_ATTR);
#ifdef USE_MAPPED_LOCATION #ifdef USE_MAPPED_LOCATION
linemap_add (&line_table, LC_LEAVE, false, NULL, 0); linemap_add (line_table, LC_LEAVE, false, NULL, 0);
#endif #endif
/* The fields of class_type_node are already in correct order. */ /* The fields of class_type_node are already in correct order. */
@ -1532,8 +1532,8 @@ duplicate_class_warning (const char *filename)
{ {
location_t warn_loc; location_t warn_loc;
#ifdef USE_MAPPED_LOCATION #ifdef USE_MAPPED_LOCATION
linemap_add (&line_table, LC_RENAME, 0, filename, 0); linemap_add (line_table, LC_RENAME, 0, filename, 0);
warn_loc = linemap_line_start (&line_table, 0, 1); warn_loc = linemap_line_start (line_table, 0, 1);
#else #else
warn_loc.file = filename; warn_loc.file = filename;
warn_loc.line = 0; warn_loc.line = 0;
@ -1650,7 +1650,7 @@ parse_class_file (void)
} }
#ifdef USE_MAPPED_LOCATION #ifdef USE_MAPPED_LOCATION
if (min_line != 0) if (min_line != 0)
input_location = linemap_line_start (&line_table, min_line, 1); input_location = linemap_line_start (line_table, min_line, 1);
#else #else
if (min_line != 0) if (min_line != 0)
input_line = min_line; input_line = min_line;
@ -1926,8 +1926,8 @@ java_parse_file (int set_yydebug ATTRIBUTE_UNUSED)
main_jcf->read_state = finput; main_jcf->read_state = finput;
main_jcf->filbuf = jcf_filbuf_from_stdio; main_jcf->filbuf = jcf_filbuf_from_stdio;
#ifdef USE_MAPPED_LOCATION #ifdef USE_MAPPED_LOCATION
linemap_add (&line_table, LC_ENTER, false, filename, 0); linemap_add (line_table, LC_ENTER, false, filename, 0);
input_location = linemap_line_start (&line_table, 0, 1); input_location = linemap_line_start (line_table, 0, 1);
#endif #endif
if (open_in_zip (main_jcf, filename, NULL, 0) < 0) if (open_in_zip (main_jcf, filename, NULL, 0) < 0)
fatal_error ("bad zip/jar file %s", filename); fatal_error ("bad zip/jar file %s", filename);
@ -1935,7 +1935,7 @@ java_parse_file (int set_yydebug ATTRIBUTE_UNUSED)
/* Register all the classes defined there. */ /* Register all the classes defined there. */
process_zip_dir (main_jcf->read_state); process_zip_dir (main_jcf->read_state);
#ifdef USE_MAPPED_LOCATION #ifdef USE_MAPPED_LOCATION
linemap_add (&line_table, LC_LEAVE, false, NULL, 0); linemap_add (line_table, LC_LEAVE, false, NULL, 0);
#endif #endif
parse_zip_file_entries (); parse_zip_file_entries ();
} }
@ -1950,7 +1950,7 @@ java_parse_file (int set_yydebug ATTRIBUTE_UNUSED)
java_parser_context_restore_global (); java_parser_context_restore_global ();
java_pop_parser_context (1); java_pop_parser_context (1);
#ifdef USE_MAPPED_LOCATION #ifdef USE_MAPPED_LOCATION
linemap_add (&line_table, LC_LEAVE, false, NULL, 0); linemap_add (line_table, LC_LEAVE, false, NULL, 0);
#endif #endif
#endif #endif
} }

View File

@ -653,8 +653,8 @@ java_post_options (const char **pfilename)
} }
} }
#ifdef USE_MAPPED_LOCATION #ifdef USE_MAPPED_LOCATION
linemap_add (&line_table, LC_ENTER, false, filename, 0); linemap_add (line_table, LC_ENTER, false, filename, 0);
linemap_add (&line_table, LC_RENAME, false, "<built-in>", 0); linemap_add (line_table, LC_RENAME, false, "<built-in>", 0);
#endif #endif
/* Initialize the compiler back end. */ /* Initialize the compiler back end. */

View File

@ -1,3 +1,7 @@
2007-09-06 Tom Tromey <tromey@redhat.com>
* lib/g++.exp (g++_target_compile): Use -fno-show-column.
2007-09-06 Richard Guenther <rguenther@suse.de> 2007-09-06 Richard Guenther <rguenther@suse.de>
PR tree-optimization/32586 PR tree-optimization/32586

View File

@ -273,6 +273,7 @@ proc g++_target_compile { source dest type options } {
} }
lappend options "additional_flags=[libio_include_flags]" lappend options "additional_flags=[libio_include_flags]"
lappend options "additional_flags=-fno-show-column"
lappend options "compiler=$GXX_UNDER_TEST" lappend options "compiler=$GXX_UNDER_TEST"
set options [concat $gpp_compile_options $options] set options [concat $gpp_compile_options $options]

View File

@ -146,7 +146,7 @@ location_t unknown_location = { NULL, 0 };
location_t input_location; location_t input_location;
struct line_maps line_table; struct line_maps *line_table;
/* Stack of currently pending input files. */ /* Stack of currently pending input files. */
@ -1601,6 +1601,14 @@ default_tree_printer (pretty_printer * pp, text_info *text, const char *spec,
return true; return true;
} }
/* A helper function; used as the reallocator function for cpp's line
table. */
static void *
realloc_for_line_map (void *ptr, size_t len)
{
return ggc_realloc (ptr, len);
}
/* Initialization of the front end environment, before command line /* Initialization of the front end environment, before command line
options are parsed. Signal handlers, internationalization etc. options are parsed. Signal handlers, internationalization etc.
ARGV0 is main's argv[0]. */ ARGV0 is main's argv[0]. */
@ -1657,7 +1665,9 @@ general_init (const char *argv0)
table. */ table. */
init_ggc (); init_ggc ();
init_stringpool (); init_stringpool ();
linemap_init (&line_table); line_table = GGC_NEW (struct line_maps);
linemap_init (line_table);
line_table->reallocator = realloc_for_line_map;
init_ttree (); init_ttree ();
/* Initialize register usage now so switches may override. */ /* Initialize register usage now so switches may override. */

View File

@ -2057,7 +2057,7 @@ remove_bb (basic_block bb)
loop above, so the last statement we process is the first statement loop above, so the last statement we process is the first statement
in the block. */ in the block. */
#ifdef USE_MAPPED_LOCATION #ifdef USE_MAPPED_LOCATION
if (loc > BUILTINS_LOCATION) if (loc > BUILTINS_LOCATION && LOCATION_LINE (loc) > 0)
warning (OPT_Wunreachable_code, "%Hwill never be executed", &loc); warning (OPT_Wunreachable_code, "%Hwill never be executed", &loc);
#else #else
if (loc) if (loc)

View File

@ -3403,7 +3403,7 @@ expand_location (source_location loc)
} }
else else
{ {
const struct line_map *map = linemap_lookup (&line_table, loc); const struct line_map *map = linemap_lookup (line_table, loc);
xloc.file = map->to_file; xloc.file = map->to_file;
xloc.line = SOURCE_LINE (map, loc); xloc.line = SOURCE_LINE (map, loc);
xloc.column = SOURCE_COLUMN (map, loc); xloc.column = SOURCE_COLUMN (map, loc);
@ -3419,6 +3419,8 @@ expand_location (source_location loc)
void void
annotate_with_file_line (tree node, const char *file, int line) annotate_with_file_line (tree node, const char *file, int line)
{ {
location_t *new_loc;
/* Roughly one percent of the calls to this function are to annotate /* Roughly one percent of the calls to this function are to annotate
a node with the same information already attached to that node! a node with the same information already attached to that node!
Just return instead of wasting memory. */ Just return instead of wasting memory. */
@ -3443,10 +3445,11 @@ annotate_with_file_line (tree node, const char *file, int line)
return; return;
} }
SET_EXPR_LOCUS (node, ggc_alloc (sizeof (location_t))); new_loc = GGC_NEW (location_t);
EXPR_LINENO (node) = line; new_loc->file = file;
EXPR_FILENAME (node) = file; new_loc->line = line;
last_annotated_node = EXPR_LOCUS (node); SET_EXPR_LOCUS (node, new_loc);
last_annotated_node = new_loc;
} }
void void
@ -3509,13 +3512,13 @@ expr_locus (const_tree node)
{ {
#ifdef USE_MAPPED_LOCATION #ifdef USE_MAPPED_LOCATION
if (GIMPLE_STMT_P (node)) if (GIMPLE_STMT_P (node))
return &GIMPLE_STMT_LOCUS (node); return CONST_CAST (source_location *, &GIMPLE_STMT_LOCUS (node));
return EXPR_P (node) ? &node->exp.locus : (location_t *) NULL; return (EXPR_P (node)
? CONST_CAST (source_location *, &node->exp.locus)
: (source_location *) NULL);
#else #else
if (GIMPLE_STMT_P (node)) if (GIMPLE_STMT_P (node))
return GIMPLE_STMT_LOCUS (node); return GIMPLE_STMT_LOCUS (node);
/* ?? The cast below was originally "(location_t *)" in the macro,
but that makes no sense. ?? */
return EXPR_P (node) ? node->exp.locus : (source_locus) NULL; return EXPR_P (node) ? node->exp.locus : (source_locus) NULL;
#endif #endif
} }
@ -3552,33 +3555,24 @@ set_expr_locus (tree node,
#endif #endif
} }
const char ** /* Return the file name of the location of NODE. */
const char *
expr_filename (const_tree node) expr_filename (const_tree node)
{ {
#ifdef USE_MAPPED_LOCATION
if (GIMPLE_STMT_P (node)) if (GIMPLE_STMT_P (node))
return &LOCATION_FILE (GIMPLE_STMT_LOCUS (node)); return LOCATION_FILE (location_from_locus (GIMPLE_STMT_LOCUS (node)));
return &LOCATION_FILE (EXPR_CHECK (node)->exp.locus); return LOCATION_FILE (location_from_locus (EXPR_CHECK (node)->exp.locus));
#else
if (GIMPLE_STMT_P (node))
return &GIMPLE_STMT_LOCUS (node)->file;
return &(EXPR_CHECK (node)->exp.locus->file);
#endif
} }
int * /* Return the line number of the location of NODE. */
int
expr_lineno (const_tree node) expr_lineno (const_tree node)
{ {
#ifdef USE_MAPPED_LOCATION
if (GIMPLE_STMT_P (node)) if (GIMPLE_STMT_P (node))
return &LOCATION_LINE (GIMPLE_STMT_LOCUS (node)); return LOCATION_LINE (location_from_locus (GIMPLE_STMT_LOCUS (node)));
return &LOCATION_LINE (EXPR_CHECK (node)->exp.locus); return LOCATION_LINE (location_from_locus (EXPR_CHECK (node)->exp.locus));
#else
if (GIMPLE_STMT_P (node))
return &GIMPLE_STMT_LOCUS (node)->line;
return &EXPR_CHECK (node)->exp.locus->line;
#endif
} }
/* Return a declaration like DDECL except that its DECL_ATTRIBUTES /* Return a declaration like DDECL except that its DECL_ATTRIBUTES
is ATTRIBUTE. */ is ATTRIBUTE. */

View File

@ -1598,8 +1598,8 @@ struct tree_constructor GTY(())
#define EXPR_HAS_LOCATION(NODE) expr_has_location ((NODE)) #define EXPR_HAS_LOCATION(NODE) expr_has_location ((NODE))
#define EXPR_LOCUS(NODE) expr_locus ((NODE)) #define EXPR_LOCUS(NODE) expr_locus ((NODE))
#define SET_EXPR_LOCUS(NODE, FROM) set_expr_locus ((NODE), (FROM)) #define SET_EXPR_LOCUS(NODE, FROM) set_expr_locus ((NODE), (FROM))
#define EXPR_FILENAME(NODE) *(expr_filename ((NODE))) #define EXPR_FILENAME(NODE) (expr_filename ((NODE)))
#define EXPR_LINENO(NODE) *(expr_lineno ((NODE))) #define EXPR_LINENO(NODE) (expr_lineno ((NODE)))
/* True if a tree is an expression or statement that can have a /* True if a tree is an expression or statement that can have a
location. */ location. */
@ -4840,22 +4840,17 @@ extern tree find_compatible_field (tree, tree);
extern location_t expr_location (const_tree); extern location_t expr_location (const_tree);
extern void set_expr_location (tree, location_t); extern void set_expr_location (tree, location_t);
extern bool expr_has_location (const_tree); extern bool expr_has_location (const_tree);
extern
#ifdef USE_MAPPED_LOCATION #ifdef USE_MAPPED_LOCATION
source_location * extern source_locus *expr_locus (const_tree);
extern void set_expr_locus (tree, source_location *);
#else #else
source_locus extern source_locus expr_locus (const_tree);
extern void set_expr_locus (tree, source_locus loc);
#endif #endif
expr_locus (const_tree); extern const char *expr_filename (const_tree);
extern void set_expr_locus (tree, extern int expr_lineno (const_tree);
#ifdef USE_MAPPED_LOCATION
source_location *loc
#else
source_locus loc
#endif
);
extern const char **expr_filename (const_tree);
extern int *expr_lineno (const_tree);
extern tree *tree_block (tree); extern tree *tree_block (tree);
extern tree *generic_tree_operand (tree, int); extern tree *generic_tree_operand (tree, int);
extern tree *generic_tree_type (tree); extern tree *generic_tree_type (tree);

View File

@ -1,3 +1,12 @@
2007-09-06 Tom Tromey <tromey@redhat.com>
* tree1.c (treelang_init): Update.
(treelang_parse_file): Update.
(treelang_parse_file): Update.
(treelang_parse_file): Update.
* lex.l: Update.
(update_lineno_charno): Likewise.
2007-09-05 Sandra Loosemore <sandra@codesourcery.com> 2007-09-05 Sandra Loosemore <sandra@codesourcery.com>
* treetree.c (tree_code_create_function_wrapup): Use set_cfun. * treetree.c (tree_code_create_function_wrapup): Use set_cfun.

View File

@ -76,7 +76,7 @@ static void dump_lex_value (int lexret);
{ {
/* ??? Should really allocate only what we need. */ /* ??? Should really allocate only what we need. */
yylval = my_malloc (sizeof (struct prod_token_parm_item)); yylval = my_malloc (sizeof (struct prod_token_parm_item));
LINEMAP_POSITION_FOR_COLUMN (input_location, &line_table, LINEMAP_POSITION_FOR_COLUMN (input_location, line_table,
next_tree_charno); next_tree_charno);
((struct prod_token_parm_item *)yylval)->tp.tok.location = input_location; ((struct prod_token_parm_item *)yylval)->tp.tok.location = input_location;
((struct prod_token_parm_item *)yylval)->tp.tok.charno = next_tree_charno; ((struct prod_token_parm_item *)yylval)->tp.tok.charno = next_tree_charno;
@ -233,7 +233,7 @@ update_lineno_charno (void)
/* Update the values we send to caller in case we sometimes don't /* Update the values we send to caller in case we sometimes don't
tell them about all the 'tokens' eg comments etc. */ tell them about all the 'tokens' eg comments etc. */
int yyl; int yyl;
LINEMAP_POSITION_FOR_COLUMN (input_location, &line_table, LINEMAP_POSITION_FOR_COLUMN (input_location, line_table,
next_tree_charno); next_tree_charno);
((struct prod_token_parm_item *)yylval)->tp.tok.location = input_location; ((struct prod_token_parm_item *)yylval)->tp.tok.location = input_location;
((struct prod_token_parm_item *)yylval)->tp.tok.charno = next_tree_charno; ((struct prod_token_parm_item *)yylval)->tp.tok.charno = next_tree_charno;
@ -243,7 +243,7 @@ update_lineno_charno (void)
if ( yytext[yyl] == '\n' ) if ( yytext[yyl] == '\n' )
{ {
#ifdef USE_MAPPED_LOCATION #ifdef USE_MAPPED_LOCATION
source_location s = linemap_line_start (&line_table, ++lineno, source_location s = linemap_line_start (line_table, ++lineno,
80); 80);
input_location = s; input_location = s;
#else #else

View File

@ -142,7 +142,7 @@ treelang_init (void)
#ifndef USE_MAPPED_LOCATION #ifndef USE_MAPPED_LOCATION
input_filename = main_input_filename; input_filename = main_input_filename;
#else #else
linemap_add (&line_table, LC_ENTER, false, main_input_filename, 1); linemap_add (line_table, LC_ENTER, false, main_input_filename, 1);
#endif #endif
/* This error will not happen from GCC as it will always create a /* This error will not happen from GCC as it will always create a
@ -166,8 +166,8 @@ treelang_init (void)
} }
#ifdef USE_MAPPED_LOCATION #ifdef USE_MAPPED_LOCATION
linemap_add (&line_table, LC_RENAME, false, "<built-in>", 1); linemap_add (line_table, LC_RENAME, false, "<built-in>", 1);
linemap_line_start (&line_table, 0, 1); linemap_line_start (line_table, 0, 1);
#endif #endif
/* Init decls, etc. */ /* Init decls, etc. */
@ -191,8 +191,8 @@ treelang_parse_file (int debug_flag ATTRIBUTE_UNUSED)
{ {
#ifdef USE_MAPPED_LOCATION #ifdef USE_MAPPED_LOCATION
source_location s; source_location s;
linemap_add (&line_table, LC_RENAME, false, main_input_filename, 1); linemap_add (line_table, LC_RENAME, false, main_input_filename, 1);
s = linemap_line_start (&line_table, 1, 80); s = linemap_line_start (line_table, 1, 80);
input_location = s; input_location = s;
#else #else
input_line = 1; input_line = 1;
@ -202,7 +202,7 @@ treelang_parse_file (int debug_flag ATTRIBUTE_UNUSED)
yyparse (); yyparse ();
cgraph_finalize_compilation_unit (); cgraph_finalize_compilation_unit ();
#ifdef USE_MAPPED_LOCATION #ifdef USE_MAPPED_LOCATION
linemap_add (&line_table, LC_LEAVE, false, NULL, 0); linemap_add (line_table, LC_LEAVE, false, NULL, 0);
#endif #endif
cgraph_optimize (); cgraph_optimize ();
} }

View File

@ -1,3 +1,22 @@
2007-09-06 Tom Tromey <tromey@redhat.com>
* internal.h (struct cpp_reader) <invocation_location>: New
field.
(struct cpp_reader) <set_invocation_location>: Likewise.
* init.c (cpp_set_line_map): New function.
* line-map.c (linemap_add): Use linemap's allocator.
* include/line-map.h (GTY): Define.
(line_map_realloc): New typedef.
(struct line_map): Mark with GTY.
(struct line_maps): Likewise.
(struct line_maps) <maps>: Likewise.
(struct line_maps) <reallocator>: New field.
* include/symtab.h (GTY): Conditionally define.
* include/cpplib.h (cpp_set_line_map): Declare.
(cpp_get_token_with_location): Declare.
* macro.c (cpp_get_token): Set invocation_location on the reader.
(cpp_get_token_with_location): New function.
2007-08-30 Chao-ying Fu <fu@mips.com> 2007-08-30 Chao-ying Fu <fu@mips.com>
* expr.c (interpret_float_suffix): Support hr, r, lr, llr, uhr, ur, * expr.c (interpret_float_suffix): Support hr, r, lr, llr, uhr, ur,

View File

@ -1,6 +1,6 @@
/* Definitions for CPP library. /* Definitions for CPP library.
Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
2004, 2005 2004, 2005, 2007
Free Software Foundation, Inc. Free Software Foundation, Inc.
Written by Per Bothner, 1994-95. Written by Per Bothner, 1994-95.
@ -623,6 +623,10 @@ struct cpp_hashnode GTY(())
extern cpp_reader *cpp_create_reader (enum c_lang, struct ht *, extern cpp_reader *cpp_create_reader (enum c_lang, struct ht *,
struct line_maps *); struct line_maps *);
/* Reset the cpp_reader's line_map. This is only used after reading a
PCH file. */
extern void cpp_set_line_map (cpp_reader *, struct line_maps *);
/* Call this to change the selected language standard (e.g. because of /* Call this to change the selected language standard (e.g. because of
command line options). */ command line options). */
extern void cpp_set_lang (cpp_reader *, enum c_lang); extern void cpp_set_lang (cpp_reader *, enum c_lang);
@ -687,6 +691,8 @@ extern void cpp_register_deferred_pragma (cpp_reader *, const char *,
extern int cpp_avoid_paste (cpp_reader *, const cpp_token *, extern int cpp_avoid_paste (cpp_reader *, const cpp_token *,
const cpp_token *); const cpp_token *);
extern const cpp_token *cpp_get_token (cpp_reader *); extern const cpp_token *cpp_get_token (cpp_reader *);
extern const cpp_token *cpp_get_token_with_location (cpp_reader *,
source_location *);
extern const unsigned char *cpp_macro_definition (cpp_reader *, extern const unsigned char *cpp_macro_definition (cpp_reader *,
const cpp_hashnode *); const cpp_hashnode *);
extern void _cpp_backup_tokens (cpp_reader *, unsigned int); extern void _cpp_backup_tokens (cpp_reader *, unsigned int);

View File

@ -1,5 +1,5 @@
/* Map logical line numbers to (source file, line number) pairs. /* Map logical line numbers to (source file, line number) pairs.
Copyright (C) 2001, 2003, 2004 Copyright (C) 2001, 2003, 2004, 2007
Free Software Foundation, Inc. Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify it This program is free software; you can redistribute it and/or modify it
@ -23,6 +23,10 @@ Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#ifndef LIBCPP_LINE_MAP_H #ifndef LIBCPP_LINE_MAP_H
#define LIBCPP_LINE_MAP_H #define LIBCPP_LINE_MAP_H
#ifndef GTY
#define GTY(x) /* nothing */
#endif
/* Reason for adding a line change with add_line_map (). LC_ENTER is /* Reason for adding a line change with add_line_map (). LC_ENTER is
when including a new file, e.g. a #include directive in C. when including a new file, e.g. a #include directive in C.
LC_LEAVE is when reaching a file's end. LC_RENAME is when a file LC_LEAVE is when reaching a file's end. LC_RENAME is when a file
@ -35,6 +39,9 @@ enum lc_reason {LC_ENTER = 0, LC_LEAVE, LC_RENAME};
and effectively typedef source_location location_t. */ and effectively typedef source_location location_t. */
typedef unsigned int source_location; typedef unsigned int source_location;
/* Memory allocation function typedef. Works like xrealloc. */
typedef void *(*line_map_realloc) (void *, size_t);
/* Physical source file TO_FILE at line TO_LINE at column 0 is represented /* Physical source file TO_FILE at line TO_LINE at column 0 is represented
by the logical START_LOCATION. TO_LINE+L at column C is represented by by the logical START_LOCATION. TO_LINE+L at column C is represented by
START_LOCATION+(L*(1<<column_bits))+C, as long as C<(1<<column_bits), START_LOCATION+(L*(1<<column_bits))+C, as long as C<(1<<column_bits),
@ -47,7 +54,7 @@ typedef unsigned int source_location;
creation of this line map, SYSP is one for a system header, two for creation of this line map, SYSP is one for a system header, two for
a C system header file that therefore needs to be extern "C" a C system header file that therefore needs to be extern "C"
protected in C++, and zero otherwise. */ protected in C++, and zero otherwise. */
struct line_map struct line_map GTY(())
{ {
const char *to_file; const char *to_file;
unsigned int to_line; unsigned int to_line;
@ -61,9 +68,9 @@ struct line_map
}; };
/* A set of chronological line_map structures. */ /* A set of chronological line_map structures. */
struct line_maps struct line_maps GTY(())
{ {
struct line_map *maps; struct line_map * GTY ((length ("%h.used"))) maps;
unsigned int allocated; unsigned int allocated;
unsigned int used; unsigned int used;
@ -89,6 +96,10 @@ struct line_maps
/* The maximum column number we can quickly allocate. Higher numbers /* The maximum column number we can quickly allocate. Higher numbers
may require allocating a new line_map. */ may require allocating a new line_map. */
unsigned int max_column_hint; unsigned int max_column_hint;
/* If non-null, the allocator to use when resizing 'maps'. If null,
xrealloc is used. */
line_map_realloc reallocator;
}; };
/* Initialize a line map set. */ /* Initialize a line map set. */

View File

@ -1,5 +1,5 @@
/* Hash tables. /* Hash tables.
Copyright (C) 2000, 2001, 2003, 2004 Free Software Foundation, Inc. Copyright (C) 2000, 2001, 2003, 2004, 2007 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify it 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 under the terms of the GNU General Public License as published by the
@ -19,7 +19,9 @@ Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
#define LIBCPP_SYMTAB_H #define LIBCPP_SYMTAB_H
#include "obstack.h" #include "obstack.h"
#ifndef GTY
#define GTY(x) /* nothing */ #define GTY(x) /* nothing */
#endif
/* This is what each hash table entry points to. It may be embedded /* This is what each hash table entry points to. It may be embedded
deeply within another object. */ deeply within another object. */

View File

@ -1,6 +1,6 @@
/* CPP Library. /* CPP Library.
Copyright (C) 1986, 1987, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998, Copyright (C) 1986, 1987, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
1999, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007 Free Software Foundation, Inc.
Contributed by Per Bothner, 1994-95. Contributed by Per Bothner, 1994-95.
Based on CCCP program by Paul Rubin, June 1986 Based on CCCP program by Paul Rubin, June 1986
Adapted to ANSI C, Richard Stallman, Jan 1987 Adapted to ANSI C, Richard Stallman, Jan 1987
@ -227,6 +227,14 @@ cpp_create_reader (enum c_lang lang, hash_table *table,
return pfile; return pfile;
} }
/* Set the line_table entry in PFILE. This is called after reading a
PCH file, as the old line_table will be incorrect. */
void
cpp_set_line_map (cpp_reader *pfile, struct line_maps *line_table)
{
pfile->line_table = line_table;
}
/* Free resources used by PFILE. Accessing PFILE after this function /* Free resources used by PFILE. Accessing PFILE after this function
returns leads to undefined behavior. Returns the error count. */ returns leads to undefined behavior. Returns the error count. */
void void

View File

@ -339,6 +339,14 @@ struct cpp_reader
/* Token generated while handling a directive, if any. */ /* Token generated while handling a directive, if any. */
cpp_token directive_result; cpp_token directive_result;
/* When expanding a macro at top-level, this is the location of the
macro invocation. */
source_location invocation_location;
/* True if this call to cpp_get_token should consider setting
invocation_location. */
bool set_invocation_location;
/* Search paths for include files. */ /* Search paths for include files. */
struct cpp_dir *quote_include; /* "" */ struct cpp_dir *quote_include; /* "" */
struct cpp_dir *bracket_include; /* <> */ struct cpp_dir *bracket_include; /* <> */

View File

@ -1,5 +1,5 @@
/* Map logical line numbers to (source file, line number) pairs. /* Map logical line numbers to (source file, line number) pairs.
Copyright (C) 2001, 2003, 2004 Copyright (C) 2001, 2003, 2004, 2007
Free Software Foundation, Inc. Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify it This program is free software; you can redistribute it and/or modify it
@ -96,8 +96,15 @@ linemap_add (struct line_maps *set, enum lc_reason reason,
if (set->used == set->allocated) if (set->used == set->allocated)
{ {
line_map_realloc reallocator
= set->reallocator ? set->reallocator : xrealloc;
set->allocated = 2 * set->allocated + 256; set->allocated = 2 * set->allocated + 256;
set->maps = XRESIZEVEC (struct line_map, set->maps, set->allocated); set->maps
= (struct line_map *) (*reallocator) (set->maps,
set->allocated
* sizeof (struct line_map));
memset (&set->maps[set->used], 0, ((set->allocated - set->used)
* sizeof (struct line_map)));
} }
map = &set->maps[set->used]; map = &set->maps[set->used];

View File

@ -1,7 +1,7 @@
/* Part of CPP library. (Macro and #define handling.) /* Part of CPP library. (Macro and #define handling.)
Copyright (C) 1986, 1987, 1989, 1992, 1993, 1994, 1995, 1996, 1998, Copyright (C) 1986, 1987, 1989, 1992, 1993, 1994, 1995, 1996, 1998,
1999, 2000, 2001, 2002, 2003, 2004, 2005, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
2006 Free Software Foundation, Inc. 2006, 2007 Free Software Foundation, Inc.
Written by Per Bothner, 1994. Written by Per Bothner, 1994.
Based on CCCP program by Paul Rubin, June 1986 Based on CCCP program by Paul Rubin, June 1986
Adapted to ANSI C, Richard Stallman, Jan 1987 Adapted to ANSI C, Richard Stallman, Jan 1987
@ -1094,6 +1094,8 @@ const cpp_token *
cpp_get_token (cpp_reader *pfile) cpp_get_token (cpp_reader *pfile)
{ {
const cpp_token *result; const cpp_token *result;
bool can_set = pfile->set_invocation_location;
pfile->set_invocation_location = false;
for (;;) for (;;)
{ {
@ -1139,6 +1141,10 @@ cpp_get_token (cpp_reader *pfile)
if (!(node->flags & NODE_DISABLED)) if (!(node->flags & NODE_DISABLED))
{ {
/* If not in a macro context, and we're going to start an
expansion, record the location. */
if (can_set && !context->macro)
pfile->invocation_location = result->src_loc;
if (!pfile->state.prevent_expansion if (!pfile->state.prevent_expansion
&& enter_macro_context (pfile, node)) && enter_macro_context (pfile, node))
{ {
@ -1164,6 +1170,27 @@ cpp_get_token (cpp_reader *pfile)
return result; return result;
} }
/* Like cpp_get_token, but also returns a location separate from the
one provided by the returned token. LOC is an out parameter; *LOC
is set to the location "as expected by the user". This matters
when a token results from macro expansion -- the token's location
will indicate where the macro is defined, but *LOC will be the
location of the start of the expansion. */
const cpp_token *
cpp_get_token_with_location (cpp_reader *pfile, source_location *loc)
{
const cpp_token *result;
pfile->set_invocation_location = true;
result = cpp_get_token (pfile);
if (pfile->context->macro)
*loc = pfile->invocation_location;
else
*loc = result->src_loc;
return result;
}
/* Returns true if we're expanding an object-like macro that was /* Returns true if we're expanding an object-like macro that was
defined in a system header. Just checks the macro at the top of defined in a system header. Just checks the macro at the top of
the stack. Used for diagnostic suppression. */ the stack. Used for diagnostic suppression. */