OSDN Git Service

fortran/
authorburnus <burnus@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 15 Nov 2006 10:02:21 +0000 (10:02 +0000)
committerburnus <burnus@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 15 Nov 2006 10:02:21 +0000 (10:02 +0000)
2006-11-15  Tobias Burnus  <burnus@net-b.de>

       PR fortran/29806
       * parse.c (parse_contained): Check for empty contains statement.

testsuite/
2006-11-15  Tobias Burnus  <burnus@net-b.de>

       PR fortran/29806
       * gfortran.dg/contains.f90: New test.
       * gfortran.dg/derived_function_interface_1.f90: Add a dg-warning.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@118851 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/fortran/ChangeLog
gcc/fortran/parse.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/contains.f90 [new file with mode: 0644]
gcc/testsuite/gfortran.dg/derived_function_interface_1.f90

index 3206979..4486399 100644 (file)
@@ -1,3 +1,8 @@
+2006-11-15  Tobias Burnus  <burnus@net-b.de>
+
+       PR fortran/29806
+       * parse.c (parse_contained): Check for empty contains statement.
+
 2006-11-15  Bud Davis <bdavis9659@sbcglobal.net>
 
        PR fortran/28974
index 5aabbb4..9d85516 100644 (file)
@@ -2757,6 +2757,7 @@ parse_contained (int module)
   gfc_statement st;
   gfc_symbol *sym;
   gfc_entry_list *el;
+  int contains_statements = 0;
 
   push_state (&s1, COMP_CONTAINS, NULL);
   parent_ns = gfc_current_ns;
@@ -2777,6 +2778,7 @@ parse_contained (int module)
 
        case ST_FUNCTION:
        case ST_SUBROUTINE:
+  contains_statements = 1;
          accept_statement (st);
 
          push_state (&s2,
@@ -2860,6 +2862,11 @@ parse_contained (int module)
   gfc_free_namespace (ns);
 
   pop_state ();
+  if (!contains_statements)
+    /* This is valid in Fortran 2008.  */
+    gfc_notify_std (GFC_STD_GNU, "Extension: "
+                    "CONTAINS statement without FUNCTION "
+                    "or SUBROUTINE statement at %C");
 }
 
 
index a53e25c..0288e55 100644 (file)
@@ -1,3 +1,9 @@
+2006-11-15  Tobias Burnus  <burnus@net-b.de>
+
+       PR fortran/29806
+       * gfortran.dg/contains.f90: New test.
+       * gfortran.dg/derived_function_interface_1.f90: Add a dg-warning.
+
 2006-11-15  Jakub Jelinek  <jakub@redhat.com>
 
        PR tree-optimization/29581
diff --git a/gcc/testsuite/gfortran.dg/contains.f90 b/gcc/testsuite/gfortran.dg/contains.f90
new file mode 100644 (file)
index 0000000..221488a
--- /dev/null
@@ -0,0 +1,11 @@
+! { dg-do compile }
+! { dg-options "-std=f2003" }
+! Check whether empty contains are allowd
+! PR fortran/29806
+module x
+ contains
+end module x ! { dg-error "CONTAINS statement without FUNCTION or SUBROUTINE statement" }
+
+program y
+  contains
+end program y ! { dg-error "CONTAINS statement without FUNCTION or SUBROUTINE statement" }
index 2cee73c..09916be 100644 (file)
@@ -37,4 +37,4 @@ contains
   type(foo) function fun() ! { dg-error "already has an explicit interface" }
   end function fun  ! { dg-error "Expecting END PROGRAM" }
 
-end
+end ! { dg-warning "CONTAINS statement without FUNCTION or SUBROUTINE statement" }