diff options
author | dodji <dodji@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-08-28 20:14:46 +0000 |
---|---|---|
committer | dodji <dodji@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-08-28 20:14:46 +0000 |
commit | 1dc92c5913ffe255be1126b46a4a977d26e4ae19 (patch) | |
tree | eceb7d4375de4bb00babcce955c7e39bab611ff1 /gcc/fortran/scanner.c | |
parent | b5cdaa0b3401db4ed1bcf12e74d33323569b9b40 (diff) |
Fix the use of linemap_add and remove unnecessary kludge
libcpp/
* line-map.c (linemap_add): Assert that reason must not be
LC_RENAME when called for the first time on a "main input file".
c-family/
* c-pch.c (c_common_read_pch): Call linemap_add with LC_ENTER as it's
the first time it's being called on this main TU.
gcc/lto/
* lto-lang.c (lto_init): Likewise. Also, avoid calling
linemap_add twice.
gcc/fortran/
* scanner.c (load_file): Don't abuse LC_RENAME reason while
(indirectly) calling linemap_add.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@178146 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/fortran/scanner.c')
-rw-r--r-- | gcc/fortran/scanner.c | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/gcc/fortran/scanner.c b/gcc/fortran/scanner.c index 0c127d49e02d..120d55022b82 100644 --- a/gcc/fortran/scanner.c +++ b/gcc/fortran/scanner.c @@ -1887,6 +1887,11 @@ load_file (const char *realfilename, const char *displayedname, bool initial) int len, line_len; bool first_line; const char *filename; + /* If realfilename and displayedname are different and non-null then + surely realfilename is the preprocessed form of + displayedname. */ + bool preprocessed_p = (realfilename && displayedname + && strcmp (realfilename, displayedname)); filename = displayedname ? displayedname : realfilename; @@ -1925,9 +1930,24 @@ load_file (const char *realfilename, const char *displayedname, bool initial) } } - /* Load the file. */ + /* Load the file. - f = get_file (filename, initial ? LC_RENAME : LC_ENTER); + A "non-initial" file means a file that is being included. In + that case we are creating an LC_ENTER map. + + An "initial" file means a main file; one that is not included. + That file has already got at least one (surely more) line map(s) + created by gfc_init. So the subsequent map created in that case + must have LC_RENAME reason. + + This latter case is not true for a preprocessed file. In that + case, although the file is "initial", the line maps created by + gfc_init was used during the preprocessing of the file. Now that + the preprocessing is over and we are being fed the result of that + preprocessing, we need to create a brand new line map for the + preprocessed file, so the reason is going to be LC_ENTER. */ + + f = get_file (filename, (initial && !preprocessed_p) ? LC_RENAME : LC_ENTER); if (!initial) add_file_change (f->filename, f->inclusion_line); current_file = f; |