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>
PR tree-optimization/32586

View File

@ -205,7 +205,7 @@ cb_line_change (cpp_reader * ARG_UNUSED (pfile), const cpp_token *token,
#else
{
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);
}
#endif
@ -283,7 +283,7 @@ cb_def_pragma (cpp_reader *pfile, source_location loc)
const cpp_token *s;
#ifndef USE_MAPPED_LOCATION
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.line = SOURCE_LINE (map, loc);
#else
@ -309,7 +309,7 @@ cb_def_pragma (cpp_reader *pfile, source_location loc)
static void
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),
(const char *) cpp_macro_definition (pfile, node));
}
@ -319,7 +319,7 @@ static void
cb_undef (cpp_reader * ARG_UNUSED (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->undef) (SOURCE_LINE (map, loc),
(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);
retry:
#ifdef USE_MAPPED_LOCATION
tok = cpp_get_token_with_location (parse_in, loc);
#else
tok = cpp_get_token (parse_in);
*loc = input_location;
#endif
type = tok->type;
retry_after_at:
#ifdef USE_MAPPED_LOCATION
*loc = tok->src_loc;
#else
*loc = input_location;
#endif
switch (type)
{
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. */
if (c_dialect_objc ())
{
#ifdef USE_MAPPED_LOCATION
location_t atloc = *loc;
location_t newloc;
#else
location_t atloc = input_location;
#endif
retry_at:
#ifdef USE_MAPPED_LOCATION
tok = cpp_get_token_with_location (parse_in, &newloc);
#else
tok = cpp_get_token (parse_in);
#endif
type = tok->type;
switch (type)
{
@ -417,6 +426,9 @@ c_lex_with_flags (tree *value, location_t *loc, unsigned char *cpp_flags)
default:
/* ... or not. */
error ("%Hstray %<@%> in program", &atloc);
#ifdef USE_MAPPED_LOCATION
*loc = newloc;
#endif
goto retry_after_at;
}
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,
ident_hash, &line_table);
ident_hash, line_table);
cpp_opts = cpp_get_options (parse_in);
cpp_opts->dollars_in_ident = DOLLARS_IN_IDENTIFIERS;
@ -1485,7 +1485,7 @@ finish_options (void)
size_t i;
cb_file_change (parse_in,
linemap_add (&line_table, LC_RENAME, 0,
linemap_add (line_table, LC_RENAME, 0,
_("<built-in>"), 0));
cpp_init_builtins (parse_in, flag_hosted);
@ -1503,7 +1503,7 @@ finish_options (void)
cpp_opts->warn_dollars = (cpp_opts->pedantic && !cpp_opts->c99);
cb_file_change (parse_in,
linemap_add (&line_table, LC_RENAME, 0,
linemap_add (line_table, LC_RENAME, 0,
_("<command-line>"), 0));
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,
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 "hosthooks.h"
#include "target.h"
#include "opts.h"
/* 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
@ -365,6 +366,7 @@ c_common_read_pch (cpp_reader *pfile, const char *name,
FILE *f;
struct c_pch_header h;
struct save_macro_data *smd;
expanded_location saved_loc;
f = fdopen (fd, "rb");
if (f == NULL)
@ -406,6 +408,18 @@ c_common_read_pch (cpp_reader *pfile, const char *name,
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);
gt_pch_restore (f);
@ -415,6 +429,9 @@ c_common_read_pch (cpp_reader *pfile, const char *name,
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
been loaded. */
if (lang_post_pch_load)

View File

@ -234,7 +234,7 @@ scan_translation_unit_trad (cpp_reader *pfile)
static void
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);
/* End the previous line of text. */
if (print.printed)
@ -268,7 +268,7 @@ print_line (source_location src_loc, const char *special_flags)
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);
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. */
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;
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);
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++;
}
@ -430,7 +430,7 @@ pp_file_change (const struct line_map *map)
/* Bring current file to correct line when entering a new file. */
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));
}
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);
maybe_dump_rtl_for_tree_stmt (stmt, last);
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;
return NULL;
}
@ -1322,7 +1322,7 @@ expand_gimple_cond_expr (basic_block bb, tree stmt)
add_reg_br_prob_note (last, false_edge->probability);
maybe_dump_rtl_for_tree_stmt (stmt, last);
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;
return NULL;
}
@ -1353,7 +1353,7 @@ expand_gimple_cond_expr (basic_block bb, tree stmt)
maybe_dump_rtl_for_tree_stmt (stmt, last2);
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;
}
@ -1620,7 +1620,7 @@ expand_gimple_basic_block (basic_block bb)
{
emit_jump (label_rtx_for_bb (e->dest));
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;
}

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>
PR c++/15745

View File

@ -11632,7 +11632,10 @@ finish_function (int flags)
return is unreachable, so put the statement on the
special line 0. */
#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
annotate_with_file_line (stmt, input_filename, 0);
#endif

View File

@ -2092,7 +2092,7 @@ final_scan_insn (rtx insn, FILE *file, int optimize ATTRIBUTE_UNUSED,
if (string[0])
{
location_t loc;
expanded_location loc;
if (! app_on)
{
@ -2100,7 +2100,7 @@ final_scan_insn (rtx insn, FILE *file, int optimize ATTRIBUTE_UNUSED,
app_on = 1;
}
#ifdef USE_MAPPED_LOCATION
loc = ASM_INPUT_SOURCE_LOCATION (body);
loc = expand_location (ASM_INPUT_SOURCE_LOCATION (body));
#else
loc.file = ASM_INPUT_SOURCE_FILE (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));
const char *string;
location_t loc;
expanded_location expanded;
/* There's no telling what that did to the condition codes. */
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. */
insn_noperands = noperands;
this_is_asm_operands = insn;
expanded = expand_location (loc);
#ifdef FINAL_PRESCAN_INSN
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);
app_on = 1;
}
if (loc.file && loc.line)
if (expanded.file && expanded.line)
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);
#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);
#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>
* trans-decl.c (build_entry_thunks): Use set_cfun.

View File

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

View File

@ -696,6 +696,12 @@ typedef struct gfc_linebuf
#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
{
char *nextc;

View File

@ -710,7 +710,7 @@ restart:
/* We've got a continuation line. If we are on the very next line after
the last continuation, increment the continuation line count and
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)
{
@ -719,7 +719,7 @@ restart:
"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. */
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
the last continuation, increment the continuation line count and
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)
{
@ -842,8 +842,8 @@ restart:
}
}
if (continue_line < gfc_current_locus.lb->linenum)
continue_line = gfc_current_locus.lb->linenum;
if (continue_line < gfc_linebuf_linenum (gfc_current_locus.lb))
continue_line = gfc_linebuf_linenum (gfc_current_locus.lb);
}
/* 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;
#ifdef USE_MAPPED_LOCATION
linemap_add (&line_table, reason, false, f->filename, 1);
linemap_add (line_table, reason, false, f->filename, 1);
#endif
return f;
@ -1514,7 +1514,7 @@ load_file (const char *filename, bool initial)
#ifdef USE_MAPPED_LOCATION
b->location
= linemap_line_start (&line_table, current_file->line++, 120);
= linemap_line_start (line_table, current_file->line++, 120);
#else
b->linenum = current_file->line++;
#endif
@ -1537,7 +1537,7 @@ load_file (const char *filename, bool initial)
current_file = current_file->up;
#ifdef USE_MAPPED_LOCATION
linemap_add (&line_table, LC_LEAVE, 0, NULL, 0);
linemap_add (line_table, LC_LEAVE, 0, NULL, 0);
#endif
return SUCCESS;
}

View File

@ -3607,7 +3607,7 @@ tree_to_gimple_tuple (tree *tp)
/* The set to base above overwrites the CODE. */
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[1] = TREE_OPERAND (*tp, 1);
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
#include "line-map.h"
extern struct line_maps line_table;
extern GTY(()) struct line_maps *line_table;
/* The location for declarations in "<built-in>" */
#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 source_locus; /* to be removed */
#define location_from_locus(LOCUS) (LOCUS)
#else /* ! USE_MAPPED_LOCATION */
struct location_s GTY(())
@ -69,6 +71,8 @@ typedef location_t *source_locus;
extern location_t unknown_location;
#define UNKNOWN_LOCATION unknown_location
#define location_from_locus(LOCUS) (* (LOCUS))
#endif /* ! USE_MAPPED_LOCATION */
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>
* 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);
#ifdef USE_MAPPED_LOCATION
input_location = linemap_line_start (&line_table, line, 1);
input_location = linemap_line_start (line_table, line, 1);
#else
input_location.line = line;
#endif

View File

@ -365,7 +365,7 @@ set_source_filename (JCF *jcf, int index)
sfname = find_sourcefile (sfname);
#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
input_filename = sfname;
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");
const char *sfname = IDENTIFIER_POINTER (source_name);
linemap_add (&line_table, LC_ENTER, false, sfname, 0);
input_location = linemap_line_start (&line_table, 0, 1);
linemap_add (line_table, LC_ENTER, false, sfname, 0);
input_location = linemap_line_start (line_table, 0, 1);
file_start_location = input_location;
DECL_SOURCE_LOCATION (TYPE_NAME (this_class)) = input_location;
if (main_input_filename == NULL && jcf == main_jcf)
@ -1497,7 +1497,7 @@ jcf_parse (JCF* jcf)
annotation_write_byte (JV_DONE_ATTR);
#ifdef USE_MAPPED_LOCATION
linemap_add (&line_table, LC_LEAVE, false, NULL, 0);
linemap_add (line_table, LC_LEAVE, false, NULL, 0);
#endif
/* 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;
#ifdef USE_MAPPED_LOCATION
linemap_add (&line_table, LC_RENAME, 0, filename, 0);
warn_loc = linemap_line_start (&line_table, 0, 1);
linemap_add (line_table, LC_RENAME, 0, filename, 0);
warn_loc = linemap_line_start (line_table, 0, 1);
#else
warn_loc.file = filename;
warn_loc.line = 0;
@ -1650,7 +1650,7 @@ parse_class_file (void)
}
#ifdef USE_MAPPED_LOCATION
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
if (min_line != 0)
input_line = min_line;
@ -1926,8 +1926,8 @@ java_parse_file (int set_yydebug ATTRIBUTE_UNUSED)
main_jcf->read_state = finput;
main_jcf->filbuf = jcf_filbuf_from_stdio;
#ifdef USE_MAPPED_LOCATION
linemap_add (&line_table, LC_ENTER, false, filename, 0);
input_location = linemap_line_start (&line_table, 0, 1);
linemap_add (line_table, LC_ENTER, false, filename, 0);
input_location = linemap_line_start (line_table, 0, 1);
#endif
if (open_in_zip (main_jcf, filename, NULL, 0) < 0)
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. */
process_zip_dir (main_jcf->read_state);
#ifdef USE_MAPPED_LOCATION
linemap_add (&line_table, LC_LEAVE, false, NULL, 0);
linemap_add (line_table, LC_LEAVE, false, NULL, 0);
#endif
parse_zip_file_entries ();
}
@ -1950,7 +1950,7 @@ java_parse_file (int set_yydebug ATTRIBUTE_UNUSED)
java_parser_context_restore_global ();
java_pop_parser_context (1);
#ifdef USE_MAPPED_LOCATION
linemap_add (&line_table, LC_LEAVE, false, NULL, 0);
linemap_add (line_table, LC_LEAVE, false, NULL, 0);
#endif
#endif
}

View File

@ -653,8 +653,8 @@ java_post_options (const char **pfilename)
}
}
#ifdef USE_MAPPED_LOCATION
linemap_add (&line_table, LC_ENTER, false, filename, 0);
linemap_add (&line_table, LC_RENAME, false, "<built-in>", 0);
linemap_add (line_table, LC_ENTER, false, filename, 0);
linemap_add (line_table, LC_RENAME, false, "<built-in>", 0);
#endif
/* 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>
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=-fno-show-column"
lappend options "compiler=$GXX_UNDER_TEST"
set options [concat $gpp_compile_options $options]

View File

@ -146,7 +146,7 @@ location_t unknown_location = { NULL, 0 };
location_t input_location;
struct line_maps line_table;
struct line_maps *line_table;
/* Stack of currently pending input files. */
@ -1601,6 +1601,14 @@ default_tree_printer (pretty_printer * pp, text_info *text, const char *spec,
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
options are parsed. Signal handlers, internationalization etc.
ARGV0 is main's argv[0]. */
@ -1657,7 +1665,9 @@ general_init (const char *argv0)
table. */
init_ggc ();
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 ();
/* 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
in the block. */
#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);
#else
if (loc)

View File

@ -3403,7 +3403,7 @@ expand_location (source_location loc)
}
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.line = SOURCE_LINE (map, loc);
xloc.column = SOURCE_COLUMN (map, loc);
@ -3419,6 +3419,8 @@ expand_location (source_location loc)
void
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
a node with the same information already attached to that node!
Just return instead of wasting memory. */
@ -3443,10 +3445,11 @@ annotate_with_file_line (tree node, const char *file, int line)
return;
}
SET_EXPR_LOCUS (node, ggc_alloc (sizeof (location_t)));
EXPR_LINENO (node) = line;
EXPR_FILENAME (node) = file;
last_annotated_node = EXPR_LOCUS (node);
new_loc = GGC_NEW (location_t);
new_loc->file = file;
new_loc->line = line;
SET_EXPR_LOCUS (node, new_loc);
last_annotated_node = new_loc;
}
void
@ -3509,13 +3512,13 @@ expr_locus (const_tree node)
{
#ifdef USE_MAPPED_LOCATION
if (GIMPLE_STMT_P (node))
return &GIMPLE_STMT_LOCUS (node);
return EXPR_P (node) ? &node->exp.locus : (location_t *) NULL;
return CONST_CAST (source_location *, &GIMPLE_STMT_LOCUS (node));
return (EXPR_P (node)
? CONST_CAST (source_location *, &node->exp.locus)
: (source_location *) NULL);
#else
if (GIMPLE_STMT_P (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;
#endif
}
@ -3552,33 +3555,24 @@ set_expr_locus (tree node,
#endif
}
const char **
/* Return the file name of the location of NODE. */
const char *
expr_filename (const_tree node)
{
#ifdef USE_MAPPED_LOCATION
if (GIMPLE_STMT_P (node))
return &LOCATION_FILE (GIMPLE_STMT_LOCUS (node));
return &LOCATION_FILE (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
return LOCATION_FILE (location_from_locus (GIMPLE_STMT_LOCUS (node)));
return LOCATION_FILE (location_from_locus (EXPR_CHECK (node)->exp.locus));
}
int *
/* Return the line number of the location of NODE. */
int
expr_lineno (const_tree node)
{
#ifdef USE_MAPPED_LOCATION
if (GIMPLE_STMT_P (node))
return &LOCATION_LINE (GIMPLE_STMT_LOCUS (node));
return &LOCATION_LINE (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 LOCATION_LINE (location_from_locus (GIMPLE_STMT_LOCUS (node)));
return LOCATION_LINE (location_from_locus (EXPR_CHECK (node)->exp.locus));
}
/* Return a declaration like DDECL except that its DECL_ATTRIBUTES
is ATTRIBUTE. */

View File

@ -1598,8 +1598,8 @@ struct tree_constructor GTY(())
#define EXPR_HAS_LOCATION(NODE) expr_has_location ((NODE))
#define EXPR_LOCUS(NODE) expr_locus ((NODE))
#define SET_EXPR_LOCUS(NODE, FROM) set_expr_locus ((NODE), (FROM))
#define EXPR_FILENAME(NODE) *(expr_filename ((NODE)))
#define EXPR_LINENO(NODE) *(expr_lineno ((NODE)))
#define EXPR_FILENAME(NODE) (expr_filename ((NODE)))
#define EXPR_LINENO(NODE) (expr_lineno ((NODE)))
/* True if a tree is an expression or statement that can have a
location. */
@ -4840,22 +4840,17 @@ extern tree find_compatible_field (tree, tree);
extern location_t expr_location (const_tree);
extern void set_expr_location (tree, location_t);
extern bool expr_has_location (const_tree);
extern
#ifdef USE_MAPPED_LOCATION
source_location *
extern source_locus *expr_locus (const_tree);
extern void set_expr_locus (tree, source_location *);
#else
source_locus
extern source_locus expr_locus (const_tree);
extern void set_expr_locus (tree, source_locus loc);
#endif
expr_locus (const_tree);
extern void set_expr_locus (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 const char *expr_filename (const_tree);
extern int expr_lineno (const_tree);
extern tree *tree_block (tree);
extern tree *generic_tree_operand (tree, int);
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>
* 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. */
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);
((struct prod_token_parm_item *)yylval)->tp.tok.location = input_location;
((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
tell them about all the 'tokens' eg comments etc. */
int yyl;
LINEMAP_POSITION_FOR_COLUMN (input_location, &line_table,
LINEMAP_POSITION_FOR_COLUMN (input_location, line_table,
next_tree_charno);
((struct prod_token_parm_item *)yylval)->tp.tok.location = input_location;
((struct prod_token_parm_item *)yylval)->tp.tok.charno = next_tree_charno;
@ -243,7 +243,7 @@ update_lineno_charno (void)
if ( yytext[yyl] == '\n' )
{
#ifdef USE_MAPPED_LOCATION
source_location s = linemap_line_start (&line_table, ++lineno,
source_location s = linemap_line_start (line_table, ++lineno,
80);
input_location = s;
#else

View File

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

View File

@ -1,6 +1,6 @@
/* Definitions for CPP library.
Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
2004, 2005
2004, 2005, 2007
Free Software Foundation, Inc.
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 *,
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
command line options). */
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 *,
const cpp_token *);
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 *,
const cpp_hashnode *);
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.
Copyright (C) 2001, 2003, 2004
Copyright (C) 2001, 2003, 2004, 2007
Free Software Foundation, Inc.
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
#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
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
@ -35,6 +39,9 @@ enum lc_reason {LC_ENTER = 0, LC_LEAVE, LC_RENAME};
and effectively typedef source_location location_t. */
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
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),
@ -47,7 +54,7 @@ typedef unsigned int source_location;
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"
protected in C++, and zero otherwise. */
struct line_map
struct line_map GTY(())
{
const char *to_file;
unsigned int to_line;
@ -61,9 +68,9 @@ struct line_map
};
/* 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 used;
@ -89,6 +96,10 @@ struct line_maps
/* The maximum column number we can quickly allocate. Higher numbers
may require allocating a new line_map. */
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. */

View File

@ -1,5 +1,5 @@
/* 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
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
#include "obstack.h"
#ifndef GTY
#define GTY(x) /* nothing */
#endif
/* This is what each hash table entry points to. It may be embedded
deeply within another object. */

View File

@ -1,6 +1,6 @@
/* CPP Library.
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.
Based on CCCP program by Paul Rubin, June 1986
Adapted to ANSI C, Richard Stallman, Jan 1987
@ -227,6 +227,14 @@ cpp_create_reader (enum c_lang lang, hash_table *table,
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
returns leads to undefined behavior. Returns the error count. */
void

View File

@ -339,6 +339,14 @@ struct cpp_reader
/* Token generated while handling a directive, if any. */
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. */
struct cpp_dir *quote_include; /* "" */
struct cpp_dir *bracket_include; /* <> */

View File

@ -1,5 +1,5 @@
/* 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.
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)
{
line_map_realloc reallocator
= set->reallocator ? set->reallocator : xrealloc;
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];

View File

@ -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 Free Software Foundation, Inc.
2006, 2007 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
@ -1094,6 +1094,8 @@ const cpp_token *
cpp_get_token (cpp_reader *pfile)
{
const cpp_token *result;
bool can_set = pfile->set_invocation_location;
pfile->set_invocation_location = false;
for (;;)
{
@ -1139,6 +1141,10 @@ cpp_get_token (cpp_reader *pfile)
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
&& enter_macro_context (pfile, node))
{
@ -1164,6 +1170,27 @@ cpp_get_token (cpp_reader *pfile)
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
defined in a system header. Just checks the macro at the top of
the stack. Used for diagnostic suppression. */