re PR fortran/22417 (gfortran preprocessing regression: nonsense warning about file...
authorJakub Jelinek <jakub@redhat.com>
Thu, 14 Jul 2005 07:15:00 +0000 (09:15 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Thu, 14 Jul 2005 07:15:00 +0000 (09:15 +0200)
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.

From-SVN: r102010

gcc/fortran/ChangeLog
gcc/fortran/scanner.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/g77/cpp5.F [new file with mode: 0644]
gcc/testsuite/gfortran.dg/g77/cpp5.h [new file with mode: 0644]
gcc/testsuite/gfortran.dg/g77/cpp5inc.h [new file with mode: 0644]

index a4897da..5f17e5e 100644 (file)
@@ -1,3 +1,9 @@
+2005-07-14  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.
+
 2005-07-14  Feng Wang  <fengwang@nudt.edu.cn>
        Steven G. Kargl  <kargls@comcast.net>
 
index fe28820..eee3a68 100644 (file)
@@ -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
index b3585c7..d0c2c65 100644 (file)
@@ -1,3 +1,10 @@
+2005-07-14  Jakub Jelinek  <jakub@redhat.com>
+
+       PR fortran/22417
+       * gfortran.dg/g77/cpp5.F: New test.
+       * gfortran.dg/g77/cpp5.h: New file.
+       * gfortran.dg/g77/cpp5inc.h: New file.
+
 2005-07-12  Paul Thomas  <pault@gcc.gnu.org>
 
        PR libfortran/16435
diff --git a/gcc/testsuite/gfortran.dg/g77/cpp5.F b/gcc/testsuite/gfortran.dg/g77/cpp5.F
new file mode 100644 (file)
index 0000000..8e35d78
--- /dev/null
@@ -0,0 +1,4 @@
+       ! { dg-do run }
+#include "cpp5.h"
+       IF (FOO().NE.1) CALL ABORT ()
+       END
diff --git a/gcc/testsuite/gfortran.dg/g77/cpp5.h b/gcc/testsuite/gfortran.dg/g77/cpp5.h
new file mode 100644 (file)
index 0000000..2e77f6a
--- /dev/null
@@ -0,0 +1,3 @@
+       FUNCTION FOO()
+#include "cpp5inc.h"
+       END FUNCTION
diff --git a/gcc/testsuite/gfortran.dg/g77/cpp5inc.h b/gcc/testsuite/gfortran.dg/g77/cpp5inc.h
new file mode 100644 (file)
index 0000000..3cc86cd
--- /dev/null
@@ -0,0 +1 @@
+       FOO = 1