diff options
author | Francois-Xavier Coudert <fxcoudert@gcc.gnu.org> | 2007-10-04 15:04:09 +0000 |
---|---|---|
committer | François-Xavier Coudert <fxcoudert@gcc.gnu.org> | 2007-10-04 15:04:09 +0000 |
commit | 9e8a67206955a2aa97f77991358c009992b30a95 (patch) | |
tree | 84713ee9ee2363bfb664ffc3692e457e1493f1ed | |
parent | 7dc83ebc4a15beeba41e01a0e1a9d3981bc6182c (diff) | |
download | gcc-9e8a67206955a2aa97f77991358c009992b30a95.zip gcc-9e8a67206955a2aa97f77991358c009992b30a95.tar.gz gcc-9e8a67206955a2aa97f77991358c009992b30a95.tar.bz2 |
re PR fortran/33502 (gfortran with .F suffix and -g3 option chokes on preprocessor syntax)
PR fortran/33502
* scanner.c (gfc_advance_line): Call debug_hooks->end_source_file
and debug_hooks->start_source_file when appropriate, and set
dbg_emitted.
(gfc_define_undef_line): New function.
(load_file): Don't error out on #define and #undef lines.
* parse.c (next_statement): Call gfc_define_undef_line.
(gfc_parse_file): Call debug_hooks->start_source_file and
debug_hooks->end_source_file for the main source file if
required.
* gfortran.h (gfc_linebuf): Add dbg_emitted field.
(gfc_define_undef_line): New prototype.
From-SVN: r129011
-rw-r--r-- | gcc/fortran/ChangeLog | 15 | ||||
-rw-r--r-- | gcc/fortran/gfortran.h | 2 | ||||
-rw-r--r-- | gcc/fortran/parse.c | 12 | ||||
-rw-r--r-- | gcc/fortran/scanner.c | 61 |
4 files changed, 88 insertions, 2 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index aaf9163..d9e368b 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,18 @@ +2007-10-04 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org> + + PR fortran/33502 + * scanner.c (gfc_advance_line): Call debug_hooks->end_source_file + and debug_hooks->start_source_file when appropriate, and set + dbg_emitted. + (gfc_define_undef_line): New function. + (load_file): Don't error out on #define and #undef lines. + * parse.c (next_statement): Call gfc_define_undef_line. + (gfc_parse_file): Call debug_hooks->start_source_file and + debug_hooks->end_source_file for the main source file if + required. + * gfortran.h (gfc_linebuf): Add dbg_emitted field. + (gfc_define_undef_line): New prototype. + 2007-10-04 Tobias Schlüter <tobi@gcc.gnu.org> PR fortran/33626 diff --git a/gcc/fortran/gfortran.h b/gcc/fortran/gfortran.h index 42002ce..5495ae7 100644 --- a/gcc/fortran/gfortran.h +++ b/gcc/fortran/gfortran.h @@ -723,6 +723,7 @@ typedef struct gfc_linebuf struct gfc_linebuf *next; int truncated; + bool dbg_emitted; char line[1]; } gfc_linebuf; @@ -1935,6 +1936,7 @@ int gfc_at_bol (void); int gfc_at_eol (void); void gfc_advance_line (void); int gfc_check_include (void); +int gfc_define_undef_line (void); void gfc_skip_comments (void); int gfc_next_char_literal (int); diff --git a/gcc/fortran/parse.c b/gcc/fortran/parse.c index 86e486c..14acb86 100644 --- a/gcc/fortran/parse.c +++ b/gcc/fortran/parse.c @@ -25,6 +25,7 @@ along with GCC; see the file COPYING3. If not see #include "gfortran.h" #include "match.h" #include "parse.h" +#include "debug.h" /* Current statement label. Zero means no statement label. Because new_st can get wiped during statement matching, we have to keep it separate. */ @@ -673,6 +674,9 @@ next_statement (void) break; } + if (gfc_define_undef_line ()) + continue; + st = (gfc_current_form == FORM_FIXED) ? next_fixed () : next_free (); if (st != ST_NONE) @@ -3270,6 +3274,11 @@ gfc_parse_file (void) gfc_statement st; locus prog_locus; + /* 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); + top.state = COMP_NONE; top.sym = NULL; top.previous = NULL; @@ -3380,6 +3389,9 @@ loop: goto loop; done: + if (debug_hooks->start_end_main_source_file) + (*debug_hooks->end_source_file) (0); + return SUCCESS; duplicate_main: diff --git a/gcc/fortran/scanner.c b/gcc/fortran/scanner.c index 682c60c..b9e7114 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,29 @@ gfc_advance_line (void) return; } + if (gfc_current_locus.lb->next + && gfc_current_locus.lb->next->file != gfc_current_locus.lb->file) + { + 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; + } + } + gfc_current_locus.lb = gfc_current_locus.lb->next; if (gfc_current_locus.lb != NULL) @@ -372,6 +397,28 @@ 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 || 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 @@ -1505,8 +1552,18 @@ 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 + && (strncmp (line, "#define ", 8) == 0 + || strncmp (line, "#undef ", 7) == 0)) + ; + else + { + preprocessor_line (line); + continue; + } } /* Preprocessed files have preprocessor lines added before the byte |