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]

Re: [PATCH, Fortran] ABSTRACT INTERFACE


2007/8/22, Tobias Burnus <burnus@net-b.de>:
> I think the patch is ok, but you miss a test case.

Alright, there you go. I incorporated the sample code that falsely
triggers the error into the existing testcase, which covers this error
message.
Regtested on i686-pc-linux-gnu with no failures.
Cheers,
Janus


2007-08-22  Janus Weil  <jaydub66@gmail.com>

      * decl.c (match_attr_spec): Pass on errors from gfc_match_bind_c.
      (gfc_match_bind_c): Bugfix in check for NAME= with abstract interfaces.


2007-08-22  Janus Weil  <jaydub66@gmail.com>

      * interface_abstract_1.f90: Extended test case.
Index: gcc/testsuite/gfortran.dg/interface_abstract_1.f90
===================================================================
--- gcc/testsuite/gfortran.dg/interface_abstract_1.f90	(revision 127700)
+++ gcc/testsuite/gfortran.dg/interface_abstract_1.f90	(working copy)
@@ -12,4 +12,10 @@ abstract interface
   subroutine real() ! { dg-error "cannot be the same as an intrinsic type" }
   end subroutine real
 end interface
+
+contains
+
+  subroutine sub() bind(C,name="subC")
+  end subroutine
+
 end
Index: gcc/fortran/decl.c
===================================================================
--- gcc/fortran/decl.c	(revision 127700)
+++ gcc/fortran/decl.c	(working copy)
@@ -2549,8 +2549,11 @@ match_attr_spec (void)
 	      /* Chomp the comma.  */
 	      peek_char = gfc_next_char ();
 	      /* Try and match the bind(c).  */
-	      if (gfc_match_bind_c (NULL) == MATCH_YES)
+	      m = gfc_match_bind_c (NULL);
+	      if (m == MATCH_YES)
 		d = DECL_IS_BIND_C;
+	      else if (m == MATCH_ERROR)
+		goto cleanup;
 	    }
 	}
 
@@ -4183,7 +4186,8 @@ gfc_match_bind_c (gfc_symbol *sym)
 	strncpy (sym->binding_label, sym->name, strlen (sym->name) + 1);
     }
 
-  if (has_name_equals && current_interface.type == INTERFACE_ABSTRACT)
+  if (has_name_equals && gfc_current_state () == COMP_INTERFACE
+      && current_interface.type == INTERFACE_ABSTRACT)
     {
       gfc_error ("NAME not allowed on BIND(C) for ABSTRACT INTERFACE at %C");
       return MATCH_ERROR;

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