diff options
Diffstat (limited to 'gcc/fortran/scanner.c')
-rw-r--r-- | gcc/fortran/scanner.c | 57 |
1 files changed, 55 insertions, 2 deletions
diff --git a/gcc/fortran/scanner.c b/gcc/fortran/scanner.c index fe7d213..ef2bbcd9 100644 --- a/gcc/fortran/scanner.c +++ b/gcc/fortran/scanner.c @@ -45,6 +45,8 @@ along with GCC; see the file COPYING3. If not see #include "system.h" #include "gfortran.h" #include "toplev.h" +#include "debug.h" +#include "flags.h" /* Structure for holding module and include file search path. */ typedef struct gfc_directorylist @@ -312,6 +314,20 @@ gfc_advance_line (void) return; } + if (gfc_current_locus.lb->next) + { + if (gfc_current_locus.lb->file->next + && gfc_current_locus.lb->file->up == gfc_current_locus.lb->file->next) + /* We exit from an included file. */ + (*debug_hooks->end_source_file) + (gfc_linebuf_linenum (gfc_current_locus.lb->next)); + else if (gfc_current_locus.lb->next->file != gfc_current_locus.lb->file) + /* 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 = gfc_current_locus.lb->next; if (gfc_current_locus.lb != NULL) @@ -372,6 +388,31 @@ skip_comment_line (void) } +int +gfc_define_undef_line (void) +{ + /* All lines beginning with '#' are either #define or #undef. */ + if (! (debug_info_level == DINFO_LEVEL_VERBOSE + && (write_symbols == DWARF2_DEBUG + || write_symbols == VMS_AND_DWARF2_DEBUG)) + || gfc_peek_char () != '#') + return 0; + + if (strncmp (gfc_current_locus.nextc, "#define ", 8) == 0) + (*debug_hooks->define) (gfc_linebuf_linenum (gfc_current_locus.lb), + &(gfc_current_locus.nextc[8])); + + if (strncmp (gfc_current_locus.nextc, "#undef ", 7) == 0) + (*debug_hooks->undef) (gfc_linebuf_linenum (gfc_current_locus.lb), + &(gfc_current_locus.nextc[7])); + + /* Skip the rest of the line. */ + skip_comment_line (); + + return 1; +} + + /* Comment lines are null lines, lines containing only blanks or lines on which the first nonblank line is a '!'. Return true if !$ openmp conditional compilation sentinel was @@ -1500,8 +1541,20 @@ load_file (const char *filename, bool initial) if (line[0] == '#') { - preprocessor_line (line); - continue; + /* When -g3 is specified, it's possible that we emit #define + and #undef lines, which we need to pass to the middle-end + so that it can emit correct debug info. */ + if (debug_info_level == DINFO_LEVEL_VERBOSE + && (write_symbols == DWARF2_DEBUG + || write_symbols == VMS_AND_DWARF2_DEBUG) + && (strncmp (line, "#define ", 8) == 0 + || strncmp (line, "#undef ", 7) == 0)) + ; + else + { + preprocessor_line (line); + continue; + } } /* Preprocessed files have preprocessor lines added before the byte |