aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran/scanner.c
diff options
context:
space:
mode:
authorPer Bothner <per@bothner.com>2004-09-07 07:43:37 -0700
committerPaul Brook <pbrook@gcc.gnu.org>2004-09-07 14:43:37 +0000
commitc8cc8542fa03e78ff3a39734f5dad49b233be54f (patch)
tree52dd9f205592562d8c793717e022109001b07465 /gcc/fortran/scanner.c
parent5212068fdf32944f8a35909cd5e9eb8d420fbc76 (diff)
downloadgcc-c8cc8542fa03e78ff3a39734f5dad49b233be54f.zip
gcc-c8cc8542fa03e78ff3a39734f5dad49b233be54f.tar.gz
gcc-c8cc8542fa03e78ff3a39734f5dad49b233be54f.tar.bz2
error.c (show_locus): Handle mapped locations.
2004-09-07 Per Bothner <per@bothner.com> Paul Brook <paul@codesourcery.com> * error.c (show_locus): Handle mapped locations. * f95-lang.c (gfc_be_parse_file): Initialize mapped locations. * gfortran.h: Include input.h. (struct gfc_linebuf): Use source_location. * scanner.c (get_file): Initialize linemap. (preprocessor_line): Pass extra argument to get_file. (load_file): Ditto. Setup linemap. (gfc_new_file): Handle mapped locations. * trans-common.c (build_field, build_equiv_decl, build_common_decl): Set decl source locations. (gfc_trans_common): Set blank common block location. * trans-decl.c (gfc_set_decl_location): New function. (gfc_get_label_decl, gfc_get_symbol_decl): Use it. (trans_function_start): Move call to gfc_set_backend_locus.. (build_function_decl): ... to here. (build_entry_thunks): Set and restore the backend locus. (gfc_generate_constructors): Remove excess arguments to init_function_start. (gfc_generate_block_data): Add comments. Set the decl locus. * trans-io.c (set_error_locus): Handle mapped locations. * trans.c (gfc_get_backend_locus, gfc_get_backend_locus): Ditto. (gfc_trans_code): Use SET_EXPR_LOCATION. (gfc_generate_code): Override the location of the new symbol. * trans.h (gfc_set_decl_location): Add prototype. Co-Authored-By: Paul Brook <paul@codesourcery.com> From-SVN: r87142
Diffstat (limited to 'gcc/fortran/scanner.c')
-rw-r--r--gcc/fortran/scanner.c25
1 files changed, 21 insertions, 4 deletions
diff --git a/gcc/fortran/scanner.c b/gcc/fortran/scanner.c
index ae473d8..a470639 100644
--- a/gcc/fortran/scanner.c
+++ b/gcc/fortran/scanner.c
@@ -801,7 +801,7 @@ load_line (FILE * input, char **pbuf, char *filename, int linenum)
the file stack. */
static gfc_file *
-get_file (char *name)
+get_file (char *name, enum lc_reason reason)
{
gfc_file *f;
@@ -817,6 +817,10 @@ get_file (char *name)
if (current_file != NULL)
f->inclusion_line = current_file->line;
+#ifdef USE_MAPPED_LOCATION
+ linemap_add (&line_table, reason, false, f->filename, 1);
+#endif
+
return f;
}
@@ -874,7 +878,7 @@ preprocessor_line (char *c)
if (flag[1] || flag[3]) /* Starting new file. */
{
- f = get_file (filename);
+ f = get_file (filename, LC_RENAME);
f->up = current_file;
current_file = f;
}
@@ -999,7 +1003,7 @@ load_file (char *filename, bool initial)
/* Load the file. */
- f = get_file (filename);
+ f = get_file (filename, initial ? LC_RENAME : LC_ENTER);
f->up = current_file;
current_file = f;
current_file->line = 1;
@@ -1032,7 +1036,12 @@ load_file (char *filename, bool initial)
b = gfc_getmem (sizeof (gfc_linebuf) + len + 1);
+#ifdef USE_MAPPED_LOCATION
+ b->location
+ = linemap_line_start (&line_table, current_file->line++, 120);
+#else
b->linenum = current_file->line++;
+#endif
b->file = current_file;
strcpy (b->line, line);
@@ -1050,6 +1059,9 @@ load_file (char *filename, bool initial)
fclose (input);
current_file = current_file->up;
+#ifdef USE_MAPPED_LOCATION
+ linemap_add (&line_table, LC_LEAVE, 0, NULL, 0);
+#endif
return SUCCESS;
}
@@ -1167,7 +1179,12 @@ gfc_new_file (const char *filename, gfc_source_form form)
#if 0 /* Debugging aid. */
for (; line_head; line_head = line_head->next)
gfc_status ("%s:%3d %s\n", line_head->file->filename,
- line_head->linenum, line_head->line);
+#ifdef USE_MAPPED_LOCATION
+ LOCATION_LINE (line_head->location),
+#else
+ line_head->linenum,
+#endif
+ line_head->line);
exit (0);
#endif