Conditionally compile support for --enable-mapped_location.

* decl.c (pop_label):  Handle (imperfectly) USE_MAPPED_LOCATION case.
	* decl2.c:  If USE_MAPPED_LOCATION, don't do some line number
	adjustments - which I don't understand.
	* error.c (dump_decl):  Rename "<interrnal>" to "<built-in>".
	* error.c:  Use LOCATION_FILE and EXPR_LOCATION macros.
	(print_instantiation_partial_context):  Use expand_location.
	* decl.c (duplicate_decl):  Use new DECL_IS_BUILTIN macro.
	* name-lookup.c:  Likewise.
	* lex.c (cxx_init):  Likewise.  Also use BUILTINS_LOCATION.
	* name-lookup.c:  Use input_line macro.
	* parser.c (cp_lexer_get_preprocessor_token):  Use UNKNOWN_LOCATION.
	(cp_parser_statement):  Rename locaal variable statement_locus to
	statement_location and use SET_EXPR_LOCATION macro.
	* pt.c:  Handle USE_MAPPED_LOCATION case.  Use new macros.
	* tree.c (cp_walk_subtrees):  Likewise.

From-SVN: r83923
This commit is contained in:
Per Bothner 2004-06-30 11:23:35 -07:00 committed by Per Bothner
parent 9506ac2be5
commit 93409b8c45
9 changed files with 74 additions and 31 deletions

View File

@ -1,3 +1,22 @@
2004-06-30 Per Bothner <per@bothner.com>
Conditionally compile support for --enable-mapped_location.
* decl.c (pop_label): Handle (imperfectly) USE_MAPPED_LOCATION case.
* decl2.c: If USE_MAPPED_LOCATION, don't do some line number
adjustments - which I don't understand.
* error.c (dump_decl): Rename "<interrnal>" to "<built-in>".
* error.c: Use LOCATION_FILE and EXPR_LOCATION macros.
(print_instantiation_partial_context): Use expand_location.
* decl.c (duplicate_decl): Use new DECL_IS_BUILTIN macro.
* name-lookup.c: Likewise.
* lex.c (cxx_init): Likewise. Also use BUILTINS_LOCATION.
* name-lookup.c: Use input_line macro.
* parser.c (cp_lexer_get_preprocessor_token): Use UNKNOWN_LOCATION.
(cp_parser_statement): Rename locaal variable statement_locus to
statement_location and use SET_EXPR_LOCATION macro.
* pt.c: Handle USE_MAPPED_LOCATION case. Use new macros.
* tree.c (cp_walk_subtrees): Likewise.
2004-06-29 Per Bothner <per@bothner.com>
* tree.c (build_min_nt, build_min, build_min_non_dep):

View File

@ -363,8 +363,12 @@ pop_label (tree label, tree old_value)
location_t location;
cp_error_at ("label `%D' used but not defined", label);
#ifdef USE_MAPPED_LOCATION
location = input_location; /* FIXME want (input_filename, (line)0) */
#else
location.file = input_filename;
location.line = 0;
#endif
/* Avoid crashing later. */
define_label (location, DECL_NAME (label));
}
@ -1635,7 +1639,7 @@ duplicate_decls (tree newdecl, tree olddecl)
TYPE_RAISES_EXCEPTIONS (oldtype));
if ((pedantic || ! DECL_IN_SYSTEM_HEADER (olddecl))
&& DECL_SOURCE_LINE (olddecl) != 0
&& ! DECL_IS_BUILTIN (olddecl)
&& flag_exceptions
&& !comp_except_specs (TYPE_RAISES_EXCEPTIONS (TREE_TYPE (newdecl)),
TYPE_RAISES_EXCEPTIONS (TREE_TYPE (olddecl)), 1))

View File

@ -2419,7 +2419,11 @@ generate_ctor_or_dtor_function (bool constructor_p, int priority,
size_t i;
input_location = *locus;
#ifdef USE_MAPPED_LOCATION
/* ??? */
#else
locus->line++;
#endif
/* We use `I' to indicate initialization and `D' to indicate
destruction. */
@ -2556,9 +2560,13 @@ finish_file (void)
if (pch_file)
c_common_write_pch ();
#ifdef USE_MAPPED_LOCATION
/* FIXME - huh? */
#else
/* Otherwise, GDB can get confused, because in only knows
about source for LINENO-1 lines. */
input_line -= 1;
#endif
interface_unknown = 1;
interface_only = 0;
@ -2714,7 +2722,11 @@ finish_file (void)
instantiations, etc. */
reconsider = true;
ssdf_count++;
#ifdef USE_MAPPED_LOCATION
/* ??? */
#else
locus.line++;
#endif
}
for (i = 0; i < deferred_fns_used; ++i)

View File

@ -835,7 +835,7 @@ dump_decl (tree t, int flags)
if (DECL_GLOBAL_CTOR_P (t) || DECL_GLOBAL_DTOR_P (t))
dump_global_iord (t);
else if (! DECL_LANG_SPECIFIC (t))
pp_identifier (cxx_pp, "<internal>");
pp_identifier (cxx_pp, "<built-in>");
else
dump_function_decl (t, flags);
break;
@ -2145,9 +2145,8 @@ cp_print_error_function (diagnostic_context *context,
if (diagnostic_last_function_changed (context))
{
const char *old_prefix = context->printer->prefix;
char *new_prefix = diagnostic->location.file
? file_name_as_prefix (diagnostic->location.file)
: NULL;
const char *file = LOCATION_FILE (diagnostic->location);
char *new_prefix = file ? file_name_as_prefix (file) : NULL;
pp_base_set_prefix (context->printer, new_prefix);
@ -2208,11 +2207,12 @@ print_instantiation_full_context (diagnostic_context *context)
/* Avoid redundancy with the the "In function" line. */;
else
pp_verbatim (context->printer,
"%s: In instantiation of `%s':\n", location.file,
"%s: In instantiation of `%s':\n",
LOCATION_FILE (location),
decl_as_string (TINST_DECL (p),
TFF_DECL_SPECIFIERS | TFF_RETURN_TYPE));
location = *EXPR_LOCUS (p);
location = EXPR_LOCATION (p);
p = TREE_CHAIN (p);
}
}
@ -2225,16 +2225,20 @@ static void
print_instantiation_partial_context (diagnostic_context *context,
tree t, location_t loc)
{
for (; t; t = TREE_CHAIN (t))
expanded_location xloc;
for (; ; t = TREE_CHAIN (t))
{
xloc = expand_location (loc);
if (t == NULL_TREE)
break;
pp_verbatim (context->printer, "%s:%d: instantiated from `%s'\n",
loc.file, loc.line,
xloc.file, xloc.line,
decl_as_string (TINST_DECL (t),
TFF_DECL_SPECIFIERS | TFF_RETURN_TYPE));
loc = *EXPR_LOCUS (t);
loc = EXPR_LOCATION (t);
}
pp_verbatim (context->printer, "%s:%d: instantiated from here\n",
loc.file, loc.line);
xloc.file, xloc.line);
}
/* Called from cp_thing to print the template context for an error. */

View File

@ -336,7 +336,11 @@ cxx_init (void)
/* We cannot just assign to input_filename because it has already
been initialized and will be used later as an N_BINCL for stabs+
debugging. */
push_srcloc ("<internal>", 0);
#ifdef USE_MAPPED_LOCATION
push_srcloc (BUILTINS_LOCATION);
#else
push_srcloc ("<built-in>", 0);
#endif
init_reswords ();
init_tree ();

View File

@ -781,7 +781,7 @@ pushdecl (tree x)
if (TREE_CODE (x) == TYPE_DECL)
{
tree type = TREE_TYPE (x);
if (DECL_SOURCE_LINE (x) == 0)
if (DECL_IS_BUILTIN (x))
{
if (TYPE_NAME (type) == 0)
TYPE_NAME (type) = x;
@ -1328,7 +1328,7 @@ begin_scope (scope_kind kind, tree entity)
{
scope->binding_depth = binding_depth;
indent (binding_depth);
cxx_scope_debug (scope, input_location.line, "push");
cxx_scope_debug (scope, input_line, "push");
is_class_level = 0;
binding_depth++;
}
@ -1354,7 +1354,7 @@ leave_scope (void)
if (ENABLE_SCOPE_CHECKING)
{
indent (--binding_depth);
cxx_scope_debug (scope, input_location.line, "leave");
cxx_scope_debug (scope, input_line, "leave");
if (is_class_level != (scope == class_binding_level))
{
indent (binding_depth);
@ -1407,7 +1407,7 @@ resume_scope (struct cp_binding_level* b)
{
b->binding_depth = binding_depth;
indent (binding_depth);
cxx_scope_debug (b, input_location.line, "resume");
cxx_scope_debug (b, input_line, "resume");
is_class_level = 0;
binding_depth++;
}
@ -1600,7 +1600,7 @@ print_binding_level (struct cp_binding_level* lvl)
continue;
if (no_print_builtins
&& (TREE_CODE (t) == TYPE_DECL)
&& (!strcmp (DECL_SOURCE_FILE (t),"<built-in>")))
&& DECL_IS_BUILTIN (t))
continue;
/* Function decls tend to have longer names. */

View File

@ -597,8 +597,7 @@ cp_lexer_get_preprocessor_token (cp_lexer *lexer ATTRIBUTE_UNUSED ,
if (lexer != NULL && !lexer->main_lexer_p)
{
token->type = CPP_EOF;
token->location.line = 0;
token->location.file = NULL;
token->location = UNKNOWN_LOCATION;
token->value = NULL_TREE;
token->keyword = RID_MAX;
@ -5890,14 +5889,14 @@ cp_parser_statement (cp_parser* parser, tree in_statement_expr)
{
tree statement;
cp_token *token;
location_t statement_locus;
location_t statement_location;
/* There is no statement yet. */
statement = NULL_TREE;
/* Peek at the next token. */
token = cp_lexer_peek_token (parser->lexer);
/* Remember the location of the first token in the statement. */
statement_locus = token->location;
statement_location = token->location;
/* If this is a keyword, then that will often determine what kind of
statement we have. */
if (token->type == CPP_KEYWORD)
@ -5973,10 +5972,7 @@ cp_parser_statement (cp_parser* parser, tree in_statement_expr)
/* Set the line number for the statement. */
if (statement && STATEMENT_CODE_P (TREE_CODE (statement)))
{
SET_EXPR_LOCUS (statement, NULL);
annotate_with_locus (statement, statement_locus);
}
SET_EXPR_LOCATION (statement, statement_location);
}
/* Parse a labeled-statement.

View File

@ -4871,7 +4871,7 @@ push_tinst_level (tree d)
}
new = make_node (TINST_LEVEL);
annotate_with_locus (new, input_location);
SET_EXPR_LOCATION (new, input_location);
TINST_DECL (new) = d;
TREE_CHAIN (new) = current_tinst_level;
current_tinst_level = new;
@ -4896,7 +4896,7 @@ pop_tinst_level (void)
/* Restore the filename and line number stashed away when we started
this instantiation. */
input_location = *EXPR_LOCUS (old);
input_location = EXPR_LOCATION (old);
extract_interface_info ();
current_tinst_level = TREE_CHAIN (old);
@ -6930,8 +6930,12 @@ tsubst (tree t, tree args, tsubst_flags_t complain, tree in_decl)
message to avoid spewing a ton of messages during a
single bad template instantiation. */
if (complain & tf_error
#ifdef USE_MAPPED_LOCATION
&& last_loc != input_location)
#else
&& (last_loc.line != input_line
|| last_loc.file != input_filename))
#endif
{
if (TREE_CODE (type) == VOID_TYPE)
error ("forming reference to void");
@ -7713,8 +7717,8 @@ tsubst_expr (tree t, tree args, tsubst_flags_t complain, tree in_decl)
if (t == NULL_TREE || t == error_mark_node)
return t;
if (EXPR_LOCUS (t))
input_location = *EXPR_LOCUS (t);
if (EXPR_HAS_LOCATION (t))
input_location = EXPR_LOCATION (t);
if (STATEMENT_CODE_P (TREE_CODE (t)))
current_stmt_tree ()->stmts_are_full_exprs_p = STMT_IS_FULL_EXPR_P (t);

View File

@ -1973,8 +1973,8 @@ cp_walk_subtrees (tree *tp, int *walk_subtrees_p, walk_tree_fn func,
/* Set input_location here so we get the right instantiation context
if we call instantiate_decl from inlinable_function_p. */
save_locus = input_location;
if (EXPR_LOCUS (*tp))
input_location = *EXPR_LOCUS (*tp);
if (EXPR_HAS_LOCATION (*tp))
input_location = EXPR_LOCATION (*tp);
/* Not one of the easy cases. We must explicitly go through the
children. */