Commit 3c20847b by Per Bothner Committed by Per Bothner

Conditionally compile support for --enable-mapped_location.

	* basic-block.h (struct edge_def):  Use new source_locus typedef.
	* c-common.c (fname_decl):  Update save/clear/store of input_location.
	(c_do_switch_warnings):  Update for USE_MAPPED_LOCATION case.
	* c-decl.c:  Likewise.
	* c-dump.c (dump_stmt):  Likewise.
	* c-gimplify.c (c-gimplify.c):  Generalize using SET_EXPR_LOCATION.
	* c-lex.c (cb_line_change):  If USE_MAPPED_LOCATION use token's	src_loc
	to set input_location direction, rather than using linemap_lookup.
	(fe_file_change, cb_def_pragma):  Again use source_location directly.
	* c-opts.c (saved_lineno):  Remove static variable.
	(c_common_post_options, c_common_init):  Don't bothner to save,
	clear and restore input_Location - now handled by lang_dependent_init.
	* function.c (init_function_start):  Use new DECL_IS_BUILTIN macro.
	* xcoffout.c (xcoff_assign_fundamental_type_number):  Likewise.

From-SVN: r83919
parent c1667470
...@@ -26,6 +26,21 @@ ...@@ -26,6 +26,21 @@
(lang_dependent_init): Save, set input_location to <built-in>. (lang_dependent_init): Save, set input_location to <built-in>.
(warn_deprecated_use): Use expand_location. (warn_deprecated_use): Use expand_location.
* basic-block.h (struct edge_def): Use new source_locus typedef.
* c-common.c (fname_decl): Update save/clear/store of input_location.
(c_do_switch_warnings): Update for USE_MAPPED_LOCATION case.
* c-decl.c: Likewise.
* c-dump.c (dump_stmt): Likewise.
* c-gimplify.c (c-gimplify.c): Generalize using SET_EXPR_LOCATION.
* c-lex.c (cb_line_change): If USE_MAPPED_LOCATION use token's src_loc
to set input_location direction, rather than using linemap_lookup.
(fe_file_change, cb_def_pragma): Again use source_location directly.
* c-opts.c (saved_lineno): Remove static variable.
(c_common_post_options, c_common_init): Don't bothner to save,
clear and restore input_Location - now handled by lang_dependent_init.
* function.c (init_function_start): Use new DECL_IS_BUILTIN macro.
* xcoffout.c (xcoff_assign_fundamental_type_number): Likewise.
2004-06-30 Richard Sandiford <rsandifo@redhat.com> 2004-06-30 Richard Sandiford <rsandifo@redhat.com>
Eric Christopher <echristo@redhat.com> Eric Christopher <echristo@redhat.com>
......
...@@ -143,7 +143,7 @@ struct edge_def GTY((chain_next ("%h.pred_next"))) ...@@ -143,7 +143,7 @@ struct edge_def GTY((chain_next ("%h.pred_next")))
PTR GTY ((skip (""))) aux; PTR GTY ((skip (""))) aux;
/* Location of any goto implicit in the edge, during tree-ssa. */ /* Location of any goto implicit in the edge, during tree-ssa. */
location_t *goto_locus; source_locus goto_locus;
int flags; /* see EDGE_* below */ int flags; /* see EDGE_* below */
int probability; /* biased by REG_BR_PROB_BASE */ int probability; /* biased by REG_BR_PROB_BASE */
......
...@@ -801,8 +801,12 @@ fname_decl (unsigned int rid, tree id) ...@@ -801,8 +801,12 @@ fname_decl (unsigned int rid, tree id)
To avoid this problem set the lineno to 0 here; that prevents To avoid this problem set the lineno to 0 here; that prevents
it from appearing in the RTL. */ it from appearing in the RTL. */
tree stmts; tree stmts;
location_t saved_locus = input_location; location_t saved_location = input_location;
#ifdef USE_MAPPED_LOCATION
input_location = UNKNOWN_LOCATION;
#else
input_line = 0; input_line = 0;
#endif
stmts = push_stmt_list (); stmts = push_stmt_list ();
decl = (*make_fname_decl) (id, fname_vars[ix].pretty); decl = (*make_fname_decl) (id, fname_vars[ix].pretty);
...@@ -811,7 +815,7 @@ fname_decl (unsigned int rid, tree id) ...@@ -811,7 +815,7 @@ fname_decl (unsigned int rid, tree id)
saved_function_name_decls saved_function_name_decls
= tree_cons (decl, stmts, saved_function_name_decls); = tree_cons (decl, stmts, saved_function_name_decls);
*fname_vars[ix].decl = decl; *fname_vars[ix].decl = decl;
input_location = saved_locus; input_location = saved_location;
} }
if (!ix && !current_function_decl) if (!ix && !current_function_decl)
pedwarn ("%J'%D' is not defined outside of function scope", decl, decl); pedwarn ("%J'%D' is not defined outside of function scope", decl, decl);
...@@ -3599,20 +3603,22 @@ void ...@@ -3599,20 +3603,22 @@ void
c_do_switch_warnings (splay_tree cases, tree switch_stmt) c_do_switch_warnings (splay_tree cases, tree switch_stmt)
{ {
splay_tree_node default_node; splay_tree_node default_node;
location_t *switch_locus; location_t switch_location;
tree type; tree type;
if (!warn_switch && !warn_switch_enum && !warn_switch_default) if (!warn_switch && !warn_switch_enum && !warn_switch_default)
return; return;
switch_locus = EXPR_LOCUS (switch_stmt); if (EXPR_HAS_LOCATION (switch_stmt))
if (!switch_locus) switch_location = EXPR_LOCATION (switch_stmt);
switch_locus = &input_location; else
switch_location = input_location;
type = SWITCH_TYPE (switch_stmt); type = SWITCH_TYPE (switch_stmt);
default_node = splay_tree_lookup (cases, (splay_tree_key) NULL); default_node = splay_tree_lookup (cases, (splay_tree_key) NULL);
if (warn_switch_default && !default_node) if (warn_switch_default && !default_node)
warning ("%Hswitch missing default case", switch_locus); warning ("%Hswitch missing default case", &switch_location);
/* If the switch expression was an enumerated type, check that /* If the switch expression was an enumerated type, check that
exactly all enumeration literals are covered by the cases. exactly all enumeration literals are covered by the cases.
...@@ -3647,7 +3653,7 @@ c_do_switch_warnings (splay_tree cases, tree switch_stmt) ...@@ -3647,7 +3653,7 @@ c_do_switch_warnings (splay_tree cases, tree switch_stmt)
/* Warn if there are enumerators that don't correspond to /* Warn if there are enumerators that don't correspond to
case expressions. */ case expressions. */
warning ("%Henumeration value `%E' not handled in switch", warning ("%Henumeration value `%E' not handled in switch",
switch_locus, TREE_PURPOSE (chain)); &switch_location, TREE_PURPOSE (chain));
} }
} }
......
...@@ -1114,7 +1114,7 @@ diagnose_mismatched_decls (tree newdecl, tree olddecl, ...@@ -1114,7 +1114,7 @@ diagnose_mismatched_decls (tree newdecl, tree olddecl,
} }
} }
else if (TREE_CODE (olddecl) == FUNCTION_DECL else if (TREE_CODE (olddecl) == FUNCTION_DECL
&& DECL_SOURCE_LINE (olddecl) == 0) && DECL_IS_BUILTIN (olddecl))
{ {
/* A conflicting function declaration for a predeclared /* A conflicting function declaration for a predeclared
function that isn't actually built in. Objective C uses function that isn't actually built in. Objective C uses
...@@ -1223,7 +1223,7 @@ diagnose_mismatched_decls (tree newdecl, tree olddecl, ...@@ -1223,7 +1223,7 @@ diagnose_mismatched_decls (tree newdecl, tree olddecl,
default. Objective C uses these. See also above. default. Objective C uses these. See also above.
FIXME: Make Objective C use normal builtins. */ FIXME: Make Objective C use normal builtins. */
if (TREE_CODE (olddecl) == FUNCTION_DECL if (TREE_CODE (olddecl) == FUNCTION_DECL
&& DECL_SOURCE_LINE (olddecl) == 0) && DECL_IS_BUILTIN (olddecl))
return false; return false;
else else
{ {
...@@ -1671,7 +1671,7 @@ warn_if_shadowing (tree new) ...@@ -1671,7 +1671,7 @@ warn_if_shadowing (tree new)
/* Shadow warnings wanted? */ /* Shadow warnings wanted? */
if (!warn_shadow if (!warn_shadow
/* No shadow warnings for internally generated vars. */ /* No shadow warnings for internally generated vars. */
|| DECL_SOURCE_LINE (new) == 0 || DECL_IS_BUILTIN (new)
/* No shadow warnings for vars made for inlining. */ /* No shadow warnings for vars made for inlining. */
|| DECL_FROM_INLINE (new) || DECL_FROM_INLINE (new)
/* Don't warn about the parm names in function declarator /* Don't warn about the parm names in function declarator
...@@ -1755,7 +1755,7 @@ warn_if_shadowing (tree new) ...@@ -1755,7 +1755,7 @@ warn_if_shadowing (tree new)
static void static void
clone_underlying_type (tree x) clone_underlying_type (tree x)
{ {
if (DECL_SOURCE_LINE (x) == 0) if (DECL_IS_BUILTIN (x))
{ {
if (TYPE_NAME (TREE_TYPE (x)) == 0) if (TYPE_NAME (TREE_TYPE (x)) == 0)
TYPE_NAME (TREE_TYPE (x)) = x; TYPE_NAME (TREE_TYPE (x)) = x;
...@@ -1963,7 +1963,7 @@ implicitly_declare (tree functionid) ...@@ -1963,7 +1963,7 @@ implicitly_declare (tree functionid)
in the external scope because they're pushed before the file in the external scope because they're pushed before the file
scope gets created. Catch this here and rebind them into the scope gets created. Catch this here and rebind them into the
file scope. */ file scope. */
if (!DECL_BUILT_IN (decl) && DECL_SOURCE_LINE (decl) == 0) if (!DECL_BUILT_IN (decl) && DECL_IS_BUILTIN (decl))
{ {
bind (functionid, decl, file_scope); bind (functionid, decl, file_scope);
return decl; return decl;
...@@ -2290,8 +2290,12 @@ c_init_decl_processing (void) ...@@ -2290,8 +2290,12 @@ c_init_decl_processing (void)
/* Declarations from c_common_nodes_and_builtins must not be associated /* Declarations from c_common_nodes_and_builtins must not be associated
with this input file, lest we get differences between using and not with this input file, lest we get differences between using and not
using preprocessed headers. */ using preprocessed headers. */
input_location.file = "<internal>"; #ifdef USE_MAPPED_LOCATION
input_location = BUILTINS_LOCATION;
#else
input_location.file = "<built-in>";
input_location.line = 0; input_location.line = 0;
#endif
build_common_tree_nodes (flag_signed_char); build_common_tree_nodes (flag_signed_char);
......
...@@ -32,9 +32,8 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA ...@@ -32,9 +32,8 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
void void
dump_stmt (dump_info_p di, tree t) dump_stmt (dump_info_p di, tree t)
{ {
location_t *locus = EXPR_LOCUS (t); if (EXPR_HAS_LOCATION (t))
if (locus) dump_int (di, "line", EXPR_LINENO (t));
dump_int (di, "line", locus->line);
} }
/* Dump any C-specific tree codes and attributes of common codes. */ /* Dump any C-specific tree codes and attributes of common codes. */
......
...@@ -458,7 +458,7 @@ gimplify_switch_stmt (tree *stmt_p) ...@@ -458,7 +458,7 @@ gimplify_switch_stmt (tree *stmt_p)
*stmt_p = build (SWITCH_EXPR, SWITCH_TYPE (stmt), SWITCH_COND (stmt), *stmt_p = build (SWITCH_EXPR, SWITCH_TYPE (stmt), SWITCH_COND (stmt),
body, NULL_TREE); body, NULL_TREE);
annotate_with_locus (*stmt_p, stmt_locus); SET_EXPR_LOCATION (*stmt_p, stmt_locus);
gimplify_stmt (stmt_p); gimplify_stmt (stmt_p);
*stmt_p = finish_bc_block (break_block, *stmt_p); *stmt_p = finish_bc_block (break_block, *stmt_p);
......
...@@ -197,11 +197,15 @@ cb_line_change (cpp_reader *pfile ATTRIBUTE_UNUSED, const cpp_token *token, ...@@ -197,11 +197,15 @@ cb_line_change (cpp_reader *pfile ATTRIBUTE_UNUSED, const cpp_token *token,
int parsing_args) int parsing_args)
{ {
if (token->type != CPP_EOF && !parsing_args) if (token->type != CPP_EOF && !parsing_args)
#ifdef USE_MAPPED_LOCATION
input_location = token->src_loc;
#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
} }
void void
...@@ -216,10 +220,17 @@ fe_file_change (const struct line_map *new_map) ...@@ -216,10 +220,17 @@ fe_file_change (const struct line_map *new_map)
we already did in compile_file. */ we already did in compile_file. */
if (! MAIN_FILE_P (new_map)) if (! MAIN_FILE_P (new_map))
{ {
#ifdef USE_MAPPED_LOCATION
int included_at = LAST_SOURCE_LINE_LOCATION (new_map - 1);
input_location = included_at;
push_srcloc (new_map->start_location);
#else
int included_at = LAST_SOURCE_LINE (new_map - 1); int included_at = LAST_SOURCE_LINE (new_map - 1);
input_line = included_at; input_line = included_at;
push_srcloc (new_map->to_file, 1); push_srcloc (new_map->to_file, 1);
#endif
(*debug_hooks->start_source_file) (included_at, new_map->to_file); (*debug_hooks->start_source_file) (included_at, new_map->to_file);
#ifndef NO_IMPLICIT_EXTERN_C #ifndef NO_IMPLICIT_EXTERN_C
if (c_header_level) if (c_header_level)
...@@ -249,8 +260,12 @@ fe_file_change (const struct line_map *new_map) ...@@ -249,8 +260,12 @@ fe_file_change (const struct line_map *new_map)
update_header_times (new_map->to_file); update_header_times (new_map->to_file);
in_system_header = new_map->sysp != 0; in_system_header = new_map->sysp != 0;
#ifdef USE_MAPPED_LOCATION
input_location = new_map->start_location;
#else
input_filename = new_map->to_file; input_filename = new_map->to_file;
input_line = new_map->to_line; input_line = new_map->to_line;
#endif
/* Hook for C++. */ /* Hook for C++. */
extract_interface_info (); extract_interface_info ();
...@@ -264,7 +279,9 @@ cb_def_pragma (cpp_reader *pfile, source_location loc) ...@@ -264,7 +279,9 @@ cb_def_pragma (cpp_reader *pfile, source_location loc)
-Wunknown-pragmas has been given. */ -Wunknown-pragmas has been given. */
if (warn_unknown_pragmas > in_system_header) if (warn_unknown_pragmas > in_system_header)
{ {
#ifndef USE_MAPPED_LOCATION
const struct line_map *map = linemap_lookup (&line_table, loc); const struct line_map *map = linemap_lookup (&line_table, loc);
#endif
const unsigned char *space, *name; const unsigned char *space, *name;
const cpp_token *s; const cpp_token *s;
...@@ -278,7 +295,11 @@ cb_def_pragma (cpp_reader *pfile, source_location loc) ...@@ -278,7 +295,11 @@ cb_def_pragma (cpp_reader *pfile, source_location loc)
name = cpp_token_as_text (pfile, s); name = cpp_token_as_text (pfile, s);
} }
#ifdef USE_MAPPED_LOCATION
input_location = loc;
#else
input_line = SOURCE_LINE (map, loc); input_line = SOURCE_LINE (map, loc);
#endif
warning ("ignoring #pragma %s %s", space, name); warning ("ignoring #pragma %s %s", space, name);
} }
} }
......
...@@ -51,8 +51,6 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA ...@@ -51,8 +51,6 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
#define TARGET_OPTF(ARG) #define TARGET_OPTF(ARG)
#endif #endif
static int saved_lineno;
/* CPP's options. */ /* CPP's options. */
static cpp_options *cpp_opts; static cpp_options *cpp_opts;
...@@ -998,7 +996,7 @@ c_common_post_options (const char **pfilename) ...@@ -998,7 +996,7 @@ c_common_post_options (const char **pfilename)
init_c_lex (); init_c_lex ();
/* Yuk. WTF is this? I do know ObjC relies on it somewhere. */ /* Yuk. WTF is this? I do know ObjC relies on it somewhere. */
input_line = 0; input_location = UNKNOWN_LOCATION;
} }
cb = cpp_get_callbacks (parse_in); cb = cpp_get_callbacks (parse_in);
...@@ -1006,8 +1004,7 @@ c_common_post_options (const char **pfilename) ...@@ -1006,8 +1004,7 @@ c_common_post_options (const char **pfilename)
cb->dir_change = cb_dir_change; cb->dir_change = cb_dir_change;
cpp_post_options (parse_in); cpp_post_options (parse_in);
saved_lineno = input_line; input_location = UNKNOWN_LOCATION;
input_line = 0;
/* If an error has occurred in cpplib, note it so we fail /* If an error has occurred in cpplib, note it so we fail
immediately. */ immediately. */
...@@ -1033,8 +1030,6 @@ c_common_post_options (const char **pfilename) ...@@ -1033,8 +1030,6 @@ c_common_post_options (const char **pfilename)
bool bool
c_common_init (void) c_common_init (void)
{ {
input_line = saved_lineno;
/* Set up preprocessor arithmetic. Must be done after call to /* Set up preprocessor arithmetic. Must be done after call to
c_common_nodes_and_builtins for type nodes to be good. */ c_common_nodes_and_builtins for type nodes to be good. */
cpp_opts->precision = TYPE_PRECISION (intmax_type_node); cpp_opts->precision = TYPE_PRECISION (intmax_type_node);
......
...@@ -6315,7 +6315,7 @@ init_function_start (tree subr) ...@@ -6315,7 +6315,7 @@ init_function_start (tree subr)
function. Also tell final how to output a linenum before the function. Also tell final how to output a linenum before the
function prologue. Note linenums could be missing, e.g. when function prologue. Note linenums could be missing, e.g. when
compiling a Java .class file. */ compiling a Java .class file. */
if (DECL_SOURCE_LINE (subr)) if (! DECL_IS_BUILTIN (subr))
emit_line_note (DECL_SOURCE_LOCATION (subr)); emit_line_note (DECL_SOURCE_LOCATION (subr));
/* Make sure first insn is a note even if we don't want linenums. /* Make sure first insn is a note even if we don't want linenums.
......
...@@ -156,7 +156,7 @@ xcoff_assign_fundamental_type_number (tree decl) ...@@ -156,7 +156,7 @@ xcoff_assign_fundamental_type_number (tree decl)
size_t i; size_t i;
/* Do not waste time searching the list for non-intrinsic types. */ /* Do not waste time searching the list for non-intrinsic types. */
if (DECL_NAME (decl) == 0 || DECL_SOURCE_LINE (decl) > 0) if (DECL_NAME (decl) == 0 || ! DECL_IS_BUILTIN (decl))
return 0; return 0;
name = IDENTIFIER_POINTER (DECL_NAME (decl)); name = IDENTIFIER_POINTER (DECL_NAME (decl));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment