aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran/scanner.c
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2007-12-05 20:50:56 +0100
committerJakub Jelinek <jakub@gcc.gnu.org>2007-12-05 20:50:56 +0100
commit60332588d6194a8636748a484f102d8b36eef80d (patch)
treecab5c222f0441c84dd8b90bf0301cd07c43d705d /gcc/fortran/scanner.c
parentbce623434fce35c3d515224b70e08d03fabce691 (diff)
downloadgcc-60332588d6194a8636748a484f102d8b36eef80d.zip
gcc-60332588d6194a8636748a484f102d8b36eef80d.tar.gz
gcc-60332588d6194a8636748a484f102d8b36eef80d.tar.bz2
re PR debug/33739 (Failure of gfortran.dg/literal_character_constant_1_*.F with -m64 -g on Darwin)
PR debug/33739 * gfortran.h (gfc_file): Remove included_by field, add sibling and down. (gfc_start_source_files, gfc_end_source_files): New prototypes. * parse.c (gfc_parse_file): Call gfc_start_source_files and gfc_end_source_files instead of calling the debugging hooks directly. * error.c (show_locus): Use up field instead of included_by. * scanner.c (change_file, gfc_start_source_files, gfc_end_source_files): New functions. (gfc_advance_line): Call change_file instead of calling debug hooks directly. (get_file): Set up rather than included_by. Initialize down and sibling. (preprocessor_line, load_file): Don't set up field here. * gfortran.dg/debug_2.f: New test. From-SVN: r130629
Diffstat (limited to 'gcc/fortran/scanner.c')
-rw-r--r--gcc/fortran/scanner.c103
1 files changed, 80 insertions, 23 deletions
diff --git a/gcc/fortran/scanner.c b/gcc/fortran/scanner.c
index b9e7114..1bea10f 100644
--- a/gcc/fortran/scanner.c
+++ b/gcc/fortran/scanner.c
@@ -299,6 +299,65 @@ gfc_at_eol (void)
return (*gfc_current_locus.nextc == '\0');
}
+static void
+change_file (gfc_file *to)
+{
+ if (current_file == NULL)
+ return;
+
+ while (current_file != to)
+ if (current_file->down)
+ {
+ gfc_file *f = current_file->down;
+ /* Ensure we don't enter it ever again. */
+ current_file->down = NULL;
+ current_file = f;
+ (*debug_hooks->start_source_file) (current_file->inclusion_line,
+ current_file->filename);
+ }
+ else if (current_file->sibling)
+ current_file = current_file->sibling;
+ else
+ {
+ gcc_assert (current_file->up);
+ (*debug_hooks->end_source_file) (current_file->inclusion_line + 1);
+ current_file = current_file->up;
+ }
+}
+
+void
+gfc_start_source_files (void)
+{
+ /* If the debugger wants the name of the main source file,
+ we give it. */
+ if (debug_hooks->start_end_main_source_file)
+ (*debug_hooks->start_source_file) (0, gfc_source_file);
+
+ if (gfc_current_locus.lb && gfc_current_locus.lb->file)
+ {
+ current_file = gfc_current_locus.lb->file;
+ while (current_file->up)
+ current_file = current_file->up;
+ change_file (gfc_current_locus.lb->file);
+ }
+ else
+ current_file = NULL;
+}
+
+void
+gfc_end_source_files (void)
+{
+ if (current_file != NULL)
+ {
+ gfc_file *to = current_file;
+ while (to->up)
+ to = to->up;
+ change_file (to);
+ }
+
+ if (debug_hooks->start_end_main_source_file)
+ (*debug_hooks->end_source_file) (0);
+}
/* Advance the current line pointer to the next line. */
@@ -315,26 +374,11 @@ gfc_advance_line (void)
}
if (gfc_current_locus.lb->next
- && gfc_current_locus.lb->next->file != gfc_current_locus.lb->file)
+ && gfc_current_locus.lb->next->file != gfc_current_locus.lb->file
+ && !gfc_current_locus.lb->next->dbg_emitted)
{
- if (gfc_current_locus.lb->next->file
- && !gfc_current_locus.lb->next->dbg_emitted
- && gfc_current_locus.lb->file->up == gfc_current_locus.lb->next->file)
- {
- /* We exit from an included file. */
- (*debug_hooks->end_source_file)
- (gfc_linebuf_linenum (gfc_current_locus.lb->next));
- gfc_current_locus.lb->next->dbg_emitted = true;
- }
- else if (gfc_current_locus.lb->next->file != gfc_current_locus.lb->file
- && !gfc_current_locus.lb->next->dbg_emitted)
- {
- /* We enter into a new file. */
- (*debug_hooks->start_source_file)
- (gfc_linebuf_linenum (gfc_current_locus.lb),
- gfc_current_locus.lb->next->file->filename);
- gfc_current_locus.lb->next->dbg_emitted = true;
- }
+ change_file (gfc_current_locus.lb->next->file);
+ gfc_current_locus.lb->next->dbg_emitted = true;
}
gfc_current_locus.lb = gfc_current_locus.lb->next;
@@ -1219,9 +1263,24 @@ get_file (const char *name, enum lc_reason reason ATTRIBUTE_UNUSED)
f->next = file_head;
file_head = f;
- f->included_by = current_file;
+ f->up = current_file;
+ /* Already cleared by gfc_getmem.
+ f->down = NULL;
+ f->sibling = NULL; */
if (current_file != NULL)
- f->inclusion_line = current_file->line;
+ {
+ f->inclusion_line = current_file->line;
+ if (current_file->down == NULL)
+ current_file->down = f;
+ else
+ {
+ gfc_file *s;
+
+ for (s = current_file->down; s->sibling; s = s->sibling)
+ ;
+ s->sibling = f;
+ }
+ }
#ifdef USE_MAPPED_LOCATION
linemap_add (line_table, reason, false, f->filename, 1);
@@ -1331,7 +1390,6 @@ preprocessor_line (char *c)
if (flag[1]) /* Starting new file. */
{
f = get_file (filename, LC_RENAME);
- f->up = current_file;
current_file = f;
}
@@ -1499,7 +1557,6 @@ load_file (const char *filename, bool initial)
/* Load the file. */
f = get_file (filename, initial ? LC_RENAME : LC_ENTER);
- f->up = current_file;
current_file = f;
current_file->line = 1;
line = NULL;