aboutsummaryrefslogtreecommitdiff
path: root/gcc/toplev.c
diff options
context:
space:
mode:
authorPer Bothner <per@bothner.com>2004-06-30 10:58:21 -0700
committerPer Bothner <bothner@gcc.gnu.org>2004-06-30 10:58:21 -0700
commitc166747038bc41ee6702618828e5c915cc4e47ea (patch)
treebf7c0b00dcfa76e28cdeb61f5339d2924ef9dc16 /gcc/toplev.c
parentb5674962f18be68ae4b22042b09fd251ccd09ed1 (diff)
downloadgcc-c166747038bc41ee6702618828e5c915cc4e47ea.zip
gcc-c166747038bc41ee6702618828e5c915cc4e47ea.tar.gz
gcc-c166747038bc41ee6702618828e5c915cc4e47ea.tar.bz2
Conditionally compile support for --enable-mapped_location.
* input.h: #include line-map.h for source_location typedef. (BUILTINS_LOCATION, UNKNOWN_LOCATION, expand_location, LOCATION_FILE, LOCATION_LINE): New macros and functions. (expanded_location, source_locus): New typedefs. (push_srcloc): Change parameter list if USE_MAPPED_LOCATION. * rtl.def (NOTE, ASM_OPERANDS): Modify specifcation, if USE_MAPPED_LOCATION. * rtl.h (NOTE_DELETED_LABEL_NAME): New macro. (NOTE_SOURCE_LOCATION, NOTE_EXPNDED_LOCATION, SET_INSN_DELETED): New conditional macros. (ASM_OPERANDS_SOURCE_FILE, ASM_OPERANDS_SOURCE_LINE): Replace by ASM_OPERANDS_SOURCE_LOCATION if USE_MAPPED_LOCATION. * tree.h (EXPR_LOCATION, SET_EXPR_LOCATION, EXPR_HAS_LOCATION, EXPR_LOCUS, SET_EXPR_LOCUS, EXPR_FILENAME, EXPR_LINENO, DECL_IS_BUILTIN): New macros, most depending on USE_MAPPED__LOCATION. (tree_exp): Change type of locus to use new source_locus typedef. * tree.c (build1_stat): Use SET_EXPR_LOCATION. (annotate_with_locus, annotate_with_file_line): Conditionalize. (expand_location): New function. * toplev.c (unknown_location): New static, when USE_MAPPED_LOCATION. (push_srcloc, pop_loc): Adjust parameter handling. (process_options): Don't set input_filename by itself. (lang_dependent_init): Save, set input_location to <built-in>. (warn_deprecated_use): Use expand_location. From-SVN: r83918
Diffstat (limited to 'gcc/toplev.c')
-rw-r--r--gcc/toplev.c52
1 files changed, 41 insertions, 11 deletions
diff --git a/gcc/toplev.c b/gcc/toplev.c
index 1ce344c..e318ac3 100644
--- a/gcc/toplev.c
+++ b/gcc/toplev.c
@@ -140,6 +140,10 @@ static const char **save_argv;
const char *main_input_filename;
+#ifndef USE_MAPPED_LOCATION
+location_t unknown_location = { NULL, 0 };
+#endif
+
/* Used to enable -fvar-tracking, -fweb and -frename-registers according
to optimize and default_debug_hooks in process_options (). */
#define AUTODETECT_FLAG_VAR_TRACKING 2
@@ -879,9 +883,12 @@ warn_deprecated_use (tree node)
return;
if (DECL_P (node))
- warning ("`%s' is deprecated (declared at %s:%d)",
- IDENTIFIER_POINTER (DECL_NAME (node)),
- DECL_SOURCE_FILE (node), DECL_SOURCE_LINE (node));
+ {
+ expanded_location xloc = expand_location (DECL_SOURCE_LOCATION (node));
+ warning ("`%s' is deprecated (declared at %s:%d)",
+ IDENTIFIER_POINTER (DECL_NAME (node)),
+ xloc.file, xloc.line);
+ }
else if (TYPE_P (node))
{
const char *what = NULL;
@@ -893,19 +900,24 @@ warn_deprecated_use (tree node)
&& DECL_NAME (TYPE_NAME (node)))
what = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (node)));
- if (what)
+ if (decl)
{
- if (decl)
+ expanded_location xloc
+ = expand_location (DECL_SOURCE_LOCATION (decl));
+ if (what)
warning ("`%s' is deprecated (declared at %s:%d)", what,
- DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl));
+ xloc.file, xloc.line);
else
- warning ("`%s' is deprecated", what);
+ warning ("type is deprecated (declared at %s:%d)",
+ xloc.file, xloc.line);
}
- else if (decl)
- warning ("type is deprecated (declared at %s:%d)",
- DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl));
else
- warning ("type is deprecated");
+ {
+ if (what)
+ warning ("type is deprecated");
+ else
+ warning ("`%s' is deprecated", what);
+ }
}
}
@@ -914,15 +926,23 @@ warn_deprecated_use (tree node)
INPUT_LOCATION accordingly. */
void
+#ifdef USE_MAPPED_LOCATION
+push_srcloc (location_t fline)
+#else
push_srcloc (const char *file, int line)
+#endif
{
struct file_stack *fs;
fs = xmalloc (sizeof (struct file_stack));
fs->location = input_location;
fs->next = input_file_stack;
+#ifdef USE_MAPPED_LOCATION
+ input_location = fline;
+#else
input_filename = file;
input_line = line;
+#endif
input_file_stack = fs;
input_file_stack_tick++;
}
@@ -1607,7 +1627,9 @@ process_options (void)
sets the original filename if appropriate (e.g. foo.i -> foo.c)
so we can correctly initialize debug output. */
no_backend = lang_hooks.post_options (&main_input_filename);
+#ifndef USE_MAPPED_LOCATION
input_filename = main_input_filename;
+#endif
#ifdef OVERRIDE_OPTIONS
/* Some machines may reject certain combinations of options. */
@@ -1928,12 +1950,20 @@ backend_init (void)
static int
lang_dependent_init (const char *name)
{
+ location_t save_loc = input_location;
if (dump_base_name == 0)
dump_base_name = name ? name : "gccdump";
/* Other front-end initialization. */
+#ifdef USE_MAPPED_LOCATION
+ input_location = BUILTINS_LOCATION;
+#else
+ input_filename = "<built-in>";
+ input_line = 0;
+#endif
if (lang_hooks.init () == 0)
return 0;
+ input_location = save_loc;
init_asm_output (name);