diff options
author | Jeff Law <law@gcc.gnu.org> | 2018-05-07 12:24:59 -0600 |
---|---|---|
committer | Jeff Law <law@gcc.gnu.org> | 2018-05-07 12:24:59 -0600 |
commit | 0d1f4de97d9b51e04f6678448fb7c796a8fba6b1 (patch) | |
tree | d02b9d2d698cff5b5b95e470ba9ab2a48256219c /gcc | |
parent | a989f6378b1b08aa3145c7bd77477282ddc5e553 (diff) | |
download | gcc-0d1f4de97d9b51e04f6678448fb7c796a8fba6b1.zip gcc-0d1f4de97d9b51e04f6678448fb7c796a8fba6b1.tar.gz gcc-0d1f4de97d9b51e04f6678448fb7c796a8fba6b1.tar.bz2 |
scanner.c (preprocessor_line): Call linemap_add after a line directive that changes the current filename.
* scanner.c (preprocessor_line): Call linemap_add after a line
directive that changes the current filename.
* gfortran.dg/linefile.f90: New test.
From-SVN: r260010
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/fortran/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/fortran/scanner.c | 4 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/testsuite/gfortran.dg/linefile.f90 | 18 |
4 files changed, 31 insertions, 0 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index b94feb9..3735dc6 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,8 @@ +2018-05-07 Jeff Law <law@redhat.comg> + + * scanner.c (preprocessor_line): Call linemap_add after a line + directive that changes the current filename. + 2018-05-06 Andre Vehreschild <vehre@gcc.gnu.org> PR fortran/85507 diff --git a/gcc/fortran/scanner.c b/gcc/fortran/scanner.c index aab5379..55d6daf 100644 --- a/gcc/fortran/scanner.c +++ b/gcc/fortran/scanner.c @@ -2107,6 +2107,10 @@ preprocessor_line (gfc_char_t *c) in the linemap. Alternative could be using GC or updating linemap to point to the new name, but there is no API for that currently. */ current_file->filename = xstrdup (filename); + + /* We need to tell the linemap API that the filename changed. Just + changing current_file is insufficient. */ + linemap_add (line_table, LC_RENAME, false, current_file->filename, line); } /* Set new line number. */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 652192b..e8b417a 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2018-05-07 Jeff Law <law@redhat.com> + + * gfortran.dg/linefile.f90: New test. + 2018-05-07 Christophe Lyon <christophe.lyon@linaro.org> * gcc.dg/nextafter-2.c: Add c99_runtime effective target diff --git a/gcc/testsuite/gfortran.dg/linefile.f90 b/gcc/testsuite/gfortran.dg/linefile.f90 new file mode 100644 index 0000000..8e1366b --- /dev/null +++ b/gcc/testsuite/gfortran.dg/linefile.f90 @@ -0,0 +1,18 @@ +! { dg-do compile } +! { dg-options "-Wall" } + +! This will verify that the # <line> <file> directive later does not +! mess up the diagnostic on this line +SUBROUTINE s(dummy) ! { dg-warning "Unused" } + INTEGER, INTENT(in) :: dummy +END SUBROUTINE + +# 12345 "foo-f" +SUBROUTINE s2(dummy) + INTEGER, INTENT(in) :: dummy +END SUBROUTINE +! We want to check that the # directive changes the filename in the +! diagnostic. Nothing else really matters here. dg-regexp allows us +! to see the entire diagnostic. We just have to make sure to consume +! the entire message. +! { dg-regexp "foo-f\[^\n]*" } |