gfortran properly handles the "#line" which come from #include
statements and look as
# 1234 "include_file_name.f90" 1
Here, the syntax is "# linenumber filename flags", where flags is a
space-delimited list of the flags 1,2,3, or 4. The problem is that the
gfortran didn't handle the case of having no flag.
Additionally, I now also go through the new-file handling for system
headers.
Build and regtested on x86-64-gnu-linux.
OK for the trunk?
Tobias
PS: I didn't include a test case; one could create one using
-fdump-tree-original-lineno, if you think that it makes sense.
2012-07-17 Tobias Burnus <bur...@net-b.de>
PR fortran/53993
* scanner.c (preprocessor_line): Fix parsing of a "#line"
which has no flags.
diff --git a/gcc/fortran/scanner.c b/gcc/fortran/scanner.c
index 4fad58b..df9f01d 100644
--- a/gcc/fortran/scanner.c
+++ b/gcc/fortran/scanner.c
@@ -1654,6 +1654,9 @@ preprocessor_line (gfc_char_t *c)
gfc_file *f;
int escaped, unescape;
char *filename;
+ enum {FLAG_NEW_FILE = 1, FLAG_PREV_FILE, FLAG_SYSHEADER, FLAG_EXTERN_C};
+
+ /* The expected syntax is "# linenumber filename flags". */
c++;
while (*c == ' ' || *c == '\t')
@@ -1739,20 +1742,24 @@ preprocessor_line (gfc_char_t *c)
flag[i] = true;
}
+ /* No flag implies that one might have a new file. */
+ if (!flag[FLAG_NEW_FILE] && !flag[FLAG_PREV_FILE] && !flag[FLAG_SYSHEADER])
+ flag[FLAG_NEW_FILE] = true;
+
/* Convert the filename in wide characters into a filename in narrow
characters. */
filename = gfc_widechar_to_char (wide_filename, -1);
/* Interpret flags. */
- if (flag[1]) /* Starting new file. */
+ if (flag[FLAG_NEW_FILE] || flag[FLAG_SYSHEADER]) /* Starting new file. */
{
f = get_file (filename, LC_RENAME);
add_file_change (f->filename, f->inclusion_line);
current_file = f;
}
- if (flag[2]) /* Ending current file. */
+ if (flag[FLAG_PREV_FILE]) /* Ending current file. */
{
if (!current_file->up
|| filename_cmp (current_file->up->filename, filename) != 0)