* 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
+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):
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));
}
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))
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. */
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;
instantiations, etc. */
reconsider = true;
ssdf_count++;
+#ifdef USE_MAPPED_LOCATION
+ /* ??? */
+#else
locus.line++;
+#endif
}
for (i = 0; i < deferred_fns_used; ++i)
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;
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);
/* 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);
}
}
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. */
/* 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 ();
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;
{
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++;
}
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);
{
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++;
}
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. */
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;
{
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)
/* 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.
}
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;
/* 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);
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");
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);
/* 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. */