mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-04-18 16:11:30 +08:00
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
This commit is contained in:
parent
c166747038
commit
3c20847b83
@ -26,6 +26,21 @@
|
||||
(lang_dependent_init): Save, set input_location to <built-in>.
|
||||
(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>
|
||||
Eric Christopher <echristo@redhat.com>
|
||||
|
||||
|
@ -143,7 +143,7 @@ struct edge_def GTY((chain_next ("%h.pred_next")))
|
||||
PTR GTY ((skip (""))) aux;
|
||||
|
||||
/* 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 probability; /* biased by REG_BR_PROB_BASE */
|
||||
|
@ -801,8 +801,12 @@ fname_decl (unsigned int rid, tree id)
|
||||
To avoid this problem set the lineno to 0 here; that prevents
|
||||
it from appearing in the RTL. */
|
||||
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;
|
||||
#endif
|
||||
|
||||
stmts = push_stmt_list ();
|
||||
decl = (*make_fname_decl) (id, fname_vars[ix].pretty);
|
||||
@ -811,7 +815,7 @@ fname_decl (unsigned int rid, tree id)
|
||||
saved_function_name_decls
|
||||
= tree_cons (decl, stmts, saved_function_name_decls);
|
||||
*fname_vars[ix].decl = decl;
|
||||
input_location = saved_locus;
|
||||
input_location = saved_location;
|
||||
}
|
||||
if (!ix && !current_function_decl)
|
||||
pedwarn ("%J'%D' is not defined outside of function scope", decl, decl);
|
||||
@ -3599,20 +3603,22 @@ void
|
||||
c_do_switch_warnings (splay_tree cases, tree switch_stmt)
|
||||
{
|
||||
splay_tree_node default_node;
|
||||
location_t *switch_locus;
|
||||
location_t switch_location;
|
||||
tree type;
|
||||
|
||||
if (!warn_switch && !warn_switch_enum && !warn_switch_default)
|
||||
return;
|
||||
|
||||
switch_locus = EXPR_LOCUS (switch_stmt);
|
||||
if (!switch_locus)
|
||||
switch_locus = &input_location;
|
||||
if (EXPR_HAS_LOCATION (switch_stmt))
|
||||
switch_location = EXPR_LOCATION (switch_stmt);
|
||||
else
|
||||
switch_location = input_location;
|
||||
|
||||
type = SWITCH_TYPE (switch_stmt);
|
||||
|
||||
default_node = splay_tree_lookup (cases, (splay_tree_key) NULL);
|
||||
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
|
||||
exactly all enumeration literals are covered by the cases.
|
||||
@ -3647,7 +3653,7 @@ c_do_switch_warnings (splay_tree cases, tree switch_stmt)
|
||||
/* Warn if there are enumerators that don't correspond to
|
||||
case expressions. */
|
||||
warning ("%Henumeration value `%E' not handled in switch",
|
||||
switch_locus, TREE_PURPOSE (chain));
|
||||
&switch_location, TREE_PURPOSE (chain));
|
||||
}
|
||||
}
|
||||
|
||||
|
16
gcc/c-decl.c
16
gcc/c-decl.c
@ -1114,7 +1114,7 @@ diagnose_mismatched_decls (tree newdecl, tree olddecl,
|
||||
}
|
||||
}
|
||||
else if (TREE_CODE (olddecl) == FUNCTION_DECL
|
||||
&& DECL_SOURCE_LINE (olddecl) == 0)
|
||||
&& DECL_IS_BUILTIN (olddecl))
|
||||
{
|
||||
/* A conflicting function declaration for a predeclared
|
||||
function that isn't actually built in. Objective C uses
|
||||
@ -1223,7 +1223,7 @@ diagnose_mismatched_decls (tree newdecl, tree olddecl,
|
||||
default. Objective C uses these. See also above.
|
||||
FIXME: Make Objective C use normal builtins. */
|
||||
if (TREE_CODE (olddecl) == FUNCTION_DECL
|
||||
&& DECL_SOURCE_LINE (olddecl) == 0)
|
||||
&& DECL_IS_BUILTIN (olddecl))
|
||||
return false;
|
||||
else
|
||||
{
|
||||
@ -1671,7 +1671,7 @@ warn_if_shadowing (tree new)
|
||||
/* Shadow warnings wanted? */
|
||||
if (!warn_shadow
|
||||
/* No shadow warnings for internally generated vars. */
|
||||
|| DECL_SOURCE_LINE (new) == 0
|
||||
|| DECL_IS_BUILTIN (new)
|
||||
/* No shadow warnings for vars made for inlining. */
|
||||
|| DECL_FROM_INLINE (new)
|
||||
/* Don't warn about the parm names in function declarator
|
||||
@ -1755,7 +1755,7 @@ warn_if_shadowing (tree new)
|
||||
static void
|
||||
clone_underlying_type (tree x)
|
||||
{
|
||||
if (DECL_SOURCE_LINE (x) == 0)
|
||||
if (DECL_IS_BUILTIN (x))
|
||||
{
|
||||
if (TYPE_NAME (TREE_TYPE (x)) == 0)
|
||||
TYPE_NAME (TREE_TYPE (x)) = x;
|
||||
@ -1963,7 +1963,7 @@ implicitly_declare (tree functionid)
|
||||
in the external scope because they're pushed before the file
|
||||
scope gets created. Catch this here and rebind them into the
|
||||
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);
|
||||
return decl;
|
||||
@ -2290,8 +2290,12 @@ c_init_decl_processing (void)
|
||||
/* Declarations from c_common_nodes_and_builtins must not be associated
|
||||
with this input file, lest we get differences between using and not
|
||||
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;
|
||||
#endif
|
||||
|
||||
build_common_tree_nodes (flag_signed_char);
|
||||
|
||||
|
@ -32,9 +32,8 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
|
||||
void
|
||||
dump_stmt (dump_info_p di, tree t)
|
||||
{
|
||||
location_t *locus = EXPR_LOCUS (t);
|
||||
if (locus)
|
||||
dump_int (di, "line", locus->line);
|
||||
if (EXPR_HAS_LOCATION (t))
|
||||
dump_int (di, "line", EXPR_LINENO (t));
|
||||
}
|
||||
|
||||
/* Dump any C-specific tree codes and attributes of common codes. */
|
||||
|
@ -458,7 +458,7 @@ gimplify_switch_stmt (tree *stmt_p)
|
||||
|
||||
*stmt_p = build (SWITCH_EXPR, SWITCH_TYPE (stmt), SWITCH_COND (stmt),
|
||||
body, NULL_TREE);
|
||||
annotate_with_locus (*stmt_p, stmt_locus);
|
||||
SET_EXPR_LOCATION (*stmt_p, stmt_locus);
|
||||
gimplify_stmt (stmt_p);
|
||||
|
||||
*stmt_p = finish_bc_block (break_block, *stmt_p);
|
||||
|
21
gcc/c-lex.c
21
gcc/c-lex.c
@ -197,11 +197,15 @@ cb_line_change (cpp_reader *pfile ATTRIBUTE_UNUSED, const cpp_token *token,
|
||||
int 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;
|
||||
const struct line_map *map = linemap_lookup (&line_table, loc);
|
||||
input_line = SOURCE_LINE (map, loc);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
@ -216,10 +220,17 @@ fe_file_change (const struct line_map *new_map)
|
||||
we already did in compile_file. */
|
||||
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);
|
||||
|
||||
input_line = included_at;
|
||||
push_srcloc (new_map->to_file, 1);
|
||||
#endif
|
||||
(*debug_hooks->start_source_file) (included_at, new_map->to_file);
|
||||
#ifndef NO_IMPLICIT_EXTERN_C
|
||||
if (c_header_level)
|
||||
@ -249,8 +260,12 @@ fe_file_change (const struct line_map *new_map)
|
||||
|
||||
update_header_times (new_map->to_file);
|
||||
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_line = new_map->to_line;
|
||||
#endif
|
||||
|
||||
/* Hook for C++. */
|
||||
extract_interface_info ();
|
||||
@ -264,7 +279,9 @@ cb_def_pragma (cpp_reader *pfile, source_location loc)
|
||||
-Wunknown-pragmas has been given. */
|
||||
if (warn_unknown_pragmas > in_system_header)
|
||||
{
|
||||
#ifndef USE_MAPPED_LOCATION
|
||||
const struct line_map *map = linemap_lookup (&line_table, loc);
|
||||
#endif
|
||||
const unsigned char *space, *name;
|
||||
const cpp_token *s;
|
||||
|
||||
@ -278,7 +295,11 @@ cb_def_pragma (cpp_reader *pfile, source_location loc)
|
||||
name = cpp_token_as_text (pfile, s);
|
||||
}
|
||||
|
||||
#ifdef USE_MAPPED_LOCATION
|
||||
input_location = loc;
|
||||
#else
|
||||
input_line = SOURCE_LINE (map, loc);
|
||||
#endif
|
||||
warning ("ignoring #pragma %s %s", space, name);
|
||||
}
|
||||
}
|
||||
|
@ -51,8 +51,6 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
|
||||
#define TARGET_OPTF(ARG)
|
||||
#endif
|
||||
|
||||
static int saved_lineno;
|
||||
|
||||
/* CPP's options. */
|
||||
static cpp_options *cpp_opts;
|
||||
|
||||
@ -998,7 +996,7 @@ c_common_post_options (const char **pfilename)
|
||||
init_c_lex ();
|
||||
|
||||
/* 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);
|
||||
@ -1006,8 +1004,7 @@ c_common_post_options (const char **pfilename)
|
||||
cb->dir_change = cb_dir_change;
|
||||
cpp_post_options (parse_in);
|
||||
|
||||
saved_lineno = input_line;
|
||||
input_line = 0;
|
||||
input_location = UNKNOWN_LOCATION;
|
||||
|
||||
/* If an error has occurred in cpplib, note it so we fail
|
||||
immediately. */
|
||||
@ -1033,8 +1030,6 @@ c_common_post_options (const char **pfilename)
|
||||
bool
|
||||
c_common_init (void)
|
||||
{
|
||||
input_line = saved_lineno;
|
||||
|
||||
/* Set up preprocessor arithmetic. Must be done after call to
|
||||
c_common_nodes_and_builtins for type nodes to be good. */
|
||||
cpp_opts->precision = TYPE_PRECISION (intmax_type_node);
|
||||
|
@ -6315,7 +6315,7 @@ init_function_start (tree subr)
|
||||
function. Also tell final how to output a linenum before the
|
||||
function prologue. Note linenums could be missing, e.g. when
|
||||
compiling a Java .class file. */
|
||||
if (DECL_SOURCE_LINE (subr))
|
||||
if (! DECL_IS_BUILTIN (subr))
|
||||
emit_line_note (DECL_SOURCE_LOCATION (subr));
|
||||
|
||||
/* 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)
|
||||
size_t i;
|
||||
|
||||
/* 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;
|
||||
|
||||
name = IDENTIFIER_POINTER (DECL_NAME (decl));
|
||||
|
Loading…
x
Reference in New Issue
Block a user