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
This commit is contained in:
Jeff Law 2018-05-07 12:24:59 -06:00
parent a989f6378b
commit 0d1f4de97d
4 changed files with 31 additions and 0 deletions

View File

@ -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

View File

@ -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. */

View File

@ -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

View File

@ -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]*" }