re PR fortran/24176 (gfortran segfaults on empty source)
authorRichard Guenther <rguenther@suse.de>
Wed, 5 Oct 2005 09:38:29 +0000 (09:38 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Wed, 5 Oct 2005 09:38:29 +0000 (09:38 +0000)
2005-10-05  Richard Guenther  <rguenther@suse.de>

PR fortran/24176
* parse.c (gfc_parse_file): Exit early for empty files.

* gfortran.fortran-torture/compile/empty.f90: New testcase.

From-SVN: r104984

gcc/fortran/ChangeLog
gcc/fortran/parse.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.fortran-torture/compile/empty.f90 [new file with mode: 0644]

index 0ee880d6a2f239c476bcdf18805795d499552f20..5663b315bc90b29de791183d0eeaf9d2ce985659 100644 (file)
@@ -1,3 +1,8 @@
+2005-10-05  Richard Guenther  <rguenther@suse.de>
+
+       PR fortran/24176
+       * parse.c (gfc_parse_file): Exit early for empty files.
+
 2005-10-03  Steve Ellcey  <sje@cup.hp.com>
 
        * fortran/trans-types.c (gfc_init_kinds): Only pass float, double,
index 1e28a7e090c23784ebcb328d15ae22d949c65900..043c3b49e0a0ae2e2741443f3c4eed6375e053f6 100644 (file)
@@ -2560,6 +2560,10 @@ gfc_parse_file (void)
 
   seen_program = 0;
 
+  /* Exit early for empty files.  */
+  if (gfc_at_eof ())
+    goto done;
+
 loop:
   gfc_init_2 ();
   st = next_statement ();
index 6790aa87479ac6b40737ce6369e4bf54928196fe..b24ca2cbfed25b2950a31305c70881721f31120f 100644 (file)
@@ -1,3 +1,8 @@
+2005-10-05  Richard Guenther  <rguenther@suse.de>
+
+       PR fortran/24176
+       * gfortran.fortran-torture/compile/empty.f90: New testcase.
+
 2005-10-05  Nathan Sidwell  <nathan@codesourcery.com>
 
        PR c++/23513
diff --git a/gcc/testsuite/gfortran.fortran-torture/compile/empty.f90 b/gcc/testsuite/gfortran.fortran-torture/compile/empty.f90
new file mode 100644 (file)
index 0000000..e69de29