aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc')
-rw-r--r--gcc/fortran/ChangeLog5
-rw-r--r--gcc/fortran/scanner.c4
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/gfortran.dg/linefile.f9018
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]*" }