From e513a086f036e9d3951fa7c184fdc323feefbae1 Mon Sep 17 00:00:00 2001 From: Tobias Burnus Date: Sat, 19 Jul 2008 20:27:00 +0200 Subject: [PATCH] re PR fortran/36342 (Missing file name in compilation diagnostics of preprocessed fortran source) 2008-07-19 Tobias Burnus PR fortran/36342 * scanner.c (load_file): Add argument to destinguish between true filename and displayed filename. (include_line,gfc_new_file): Adapt accordingly. From-SVN: r137985 --- gcc/fortran/ChangeLog | 7 +++++++ gcc/fortran/scanner.c | 17 ++++++++++------- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 6077028231a..dc592eda24b 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,10 @@ +2008-07-19 Tobias Burnus + + PR fortran/36342 + * scanner.c (load_file): Add argument to destinguish between + true filename and displayed filename. + (include_line,gfc_new_file): Adapt accordingly. + 2008-07-19 Tobias Burnus * check.c (gfc_check_cshift,gfc_check_eoshift,gfc_check_unpack): Add rank diff --git a/gcc/fortran/scanner.c b/gcc/fortran/scanner.c index 6e6017a9004..3087c62e41b 100644 --- a/gcc/fortran/scanner.c +++ b/gcc/fortran/scanner.c @@ -1672,7 +1672,7 @@ preprocessor_line (gfc_char_t *c) } -static try load_file (const char *, bool); +static try load_file (const char *, const char *, bool); /* include_line()-- Checks a line buffer to see if it is an include line. If so, we call load_file() recursively to load the included @@ -1743,7 +1743,7 @@ include_line (gfc_char_t *line) read by anything else. */ filename = gfc_widechar_to_char (begin, -1); - load_file (filename, false); + load_file (filename, NULL, false); gfc_free (filename); return true; } @@ -1752,7 +1752,7 @@ include_line (gfc_char_t *line) /* Load a file into memory by calling load_line until the file ends. */ static try -load_file (const char *filename, bool initial) +load_file (const char *realfilename, const char *displayedname, bool initial) { gfc_char_t *line; gfc_linebuf *b; @@ -1760,6 +1760,9 @@ load_file (const char *filename, bool initial) FILE *input; int len, line_len; bool first_line; + const char *filename; + + filename = displayedname ? displayedname : realfilename; for (f = current_file; f; f = f->up) if (strcmp (filename, f->filename) == 0) @@ -1776,7 +1779,7 @@ load_file (const char *filename, bool initial) gfc_src_file = NULL; } else - input = gfc_open_file (filename); + input = gfc_open_file (realfilename); if (input == NULL) { gfc_error_now ("Can't open file '%s'", filename); @@ -1785,7 +1788,7 @@ load_file (const char *filename, bool initial) } else { - input = gfc_open_included_file (filename, false, false); + input = gfc_open_included_file (realfilename, false, false); if (input == NULL) { gfc_error_now ("Can't open included file '%s'", filename); @@ -1927,10 +1930,10 @@ gfc_new_file (void) { result = gfc_cpp_preprocess (gfc_source_file); if (!gfc_cpp_preprocess_only ()) - result = load_file (gfc_cpp_temporary_file (), true); + result = load_file (gfc_cpp_temporary_file (), gfc_source_file, true); } else - result = load_file (gfc_source_file, true); + result = load_file (gfc_source_file, NULL, true); gfc_current_locus.lb = line_head; gfc_current_locus.nextc = (line_head == NULL) ? NULL : line_head->line; -- 2.30.2