Commit 4c3a6ca1 by Jakub Jelinek Committed by Jakub Jelinek

scanner.c (preprocessor_line): Only set current_file->line when errors have not been encountered.

	* scanner.c (preprocessor_line): Only set current_file->line when errors
	have not been encountered.  Warn and don't crash if a file leave
	preprocessor line has no corresponding entering line.  Formatting.

	* gfortran.dg/badline.f: New test.

From-SVN: r101717
parent 452190fb
2005-07-07 Jakub Jelinek <jakub@redhat.com>
* scanner.c (preprocessor_line): Only set current_file->line when errors
have not been encountered. Warn and don't crash if a file leave
preprocessor line has no corresponding entering line. Formatting.
2005-07-07 Steven Bosscher <stevenb@suse.de>
* primary.c (match_hollerith_constant): Use int, not unsigned int,
......
......@@ -839,15 +839,13 @@ preprocessor_line (char *c)
line = atoi (c);
/* Set new line number. */
current_file->line = line;
c = strchr (c, ' ');
if (c == NULL)
/* No file name given. */
{
/* No file name given. Set new line number. */
current_file->line = line;
return;
}
/* Skip spaces. */
while (*c == ' ' || *c == '\t')
......@@ -907,6 +905,14 @@ preprocessor_line (char *c)
if (flag[2]) /* Ending current file. */
{
if (strcmp (current_file->filename, filename) != 0)
{
gfc_warning_now ("%s:%d: file %s left but not entered",
current_file->filename, current_file->line,
filename);
return;
}
if (current_file->up)
current_file = current_file->up;
}
......@@ -920,6 +926,8 @@ preprocessor_line (char *c)
strcpy (current_file->filename, filename);
}
/* Set new line number. */
current_file->line = line;
return;
bad_cpp_line:
......
2005-07-07 Jakub Jelinek <jakub@redhat.com>
* gfortran.dg/badline.f: New test.
2005-07-07 Feng Wang <fengwang@nudt.edu.cn>
PR fortran/16531
......
subroutine foo
# 18 "src/badline.F" 2
end
! { dg-warning "left but not entered" "" { target *-*-* } 2 }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment