This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Fix fortran file left but not entered warning (PR fortran/22417)


Hi!

I have made a thinko in my last preprocessor_line patch and unfortunately
nothing in the testsuite caught this.  Sorry.
Here is a fix plus a testcase.  Without the first hunk 20010321-1.f testcase
fails, but treating flag 3 as file start is incorrect, only 1 is file start,
3 just signals a system header and can occur with both 1 (file enter), 2
(file leave) or even on a line changing # line.
Ok to commit?

2005-07-12  Jakub Jelinek  <jakub@redhat.com>

	PR fortran/22417
	* scanner.c (preprocessor_line): Don't treat flag 3 as the start of a new
	file.  Fix file left but not entered warning.

	* gfortran.dg/g77/cpp5.F: New test.
	* gfortran.dg/g77/cpp5.h: New file.
	* gfortran.dg/g77/cpp5inc.h: New file.

--- gcc/fortran/scanner.c.jj	2005-07-07 17:56:30.000000000 +0200
+++ gcc/fortran/scanner.c	2005-07-12 10:32:59.000000000 +0200
@@ -899,7 +899,7 @@ preprocessor_line (char *c)
 
   /* Interpret flags.  */
 
-  if (flag[1] || flag[3]) /* Starting new file.  */
+  if (flag[1]) /* Starting new file.  */
     {
       f = get_file (filename, LC_RENAME);
       f->up = current_file;
@@ -908,15 +908,15 @@ preprocessor_line (char *c)
 
   if (flag[2]) /* Ending current file.  */
     {
-      if (strcmp (current_file->filename, filename) != 0)
+      if (!current_file->up
+	  || strcmp (current_file->up->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;
+      current_file = current_file->up;
     }
 
   /* The name of the file can be a temporary file produced by
--- gcc/testsuite/gfortran.dg/g77/cpp5.F.jj	2005-07-12 08:22:51.000000000 +0200
+++ gcc/testsuite/gfortran.dg/g77/cpp5.F	2005-07-12 08:27:35.000000000 +0200
@@ -0,0 +1,4 @@
+	! { dg-do run }
+#include "cpp5.h"
+	IF (FOO().NE.1) CALL ABORT ()
+	END
--- gcc/testsuite/gfortran.dg/g77/cpp5.h.jj	2005-07-12 08:24:39.000000000 +0200
+++ gcc/testsuite/gfortran.dg/g77/cpp5.h	2005-07-12 08:25:48.000000000 +0200
@@ -0,0 +1,3 @@
+	FUNCTION FOO()
+#include "cpp5inc.h"
+	END FUNCTION
--- gcc/testsuite/gfortran.dg/g77/cpp5inc.h.jj	2005-07-12 08:25:28.000000000 +0200
+++ gcc/testsuite/gfortran.dg/g77/cpp5inc.h	2005-07-12 08:25:25.000000000 +0200
@@ -0,0 +1 @@
+	FOO = 1

	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]