This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
Re: [PATCH, Fortran] ABSTRACT INTERFACE
- From: "Janus Weil" <jaydub66 at googlemail dot com>
- To: "Tobias Burnus" <burnus at net-b dot de>
- Cc: "Tobias Schlüter" <tobias dot schlueter at physik dot uni-muenchen dot de>, gcc-patches at gcc dot gnu dot org, "fortran at gcc dot gnu dot org" <fortran at gcc dot gnu dot org>
- Date: Wed, 22 Aug 2007 10:59:39 +0200
- Subject: Re: [PATCH, Fortran] ABSTRACT INTERFACE
- Dkim-signature: a=rsa-sha1; c=relaxed/relaxed; d=googlemail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:references; b=tGTbMmZn1rAVhoAoQTdoPCNsTppUVtpntu5gtAoTIP5ypBmcC+PDba6tnxpcxVR7nSpXLg7m8UN3ms6tqwHNk+XQ8UGE1Lzr7F0ed5EPs8IH872rOgTqC5XSP9BcLxqGnEll6sDU/SpISyO5hEZM/MesW2HlEWIcBM+RFMzMY7M=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=googlemail.com; s=beta; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:references; b=pFzWSARqVC5hNHNB3H6GBlR7SRB6jWZ/KOfNY3mniT5MaOx65rfXb4gkwTgJPASzcEiV8K6bOG3ZFH1waVWOZduj50k17CaydTzUNsYtmAsde+DHMfCNqXYuPEf16CY48pJRA4kcEnEstGxVtm4p3/9Pk4eDpLuwmGYjTOxJDbQ=
- References: <854832d40708180729p583cd306p1bef676f5553cadd@mail.gmail.com> <46C71FB3.4010909@physik.uni-muenchen.de> <46C73DA9.8040806@net-b.de> <46C86DB4.4050801@physik.uni-muenchen.de> <46C8A367.9070209@net-b.de>
Hi all,
I think I found a bug in the implementation of abstract interfaces.
Consider the following code:
program p
abstract interface
subroutine s()
end subroutine
end interface
contains
subroutine x() bind(c,name="xyz")
end subroutine
end program
This fails with:
subroutine x() bind(c,name="xyz")
1
Error: NAME not allowed on BIND(C) for ABSTRACT INTERFACE at (1)
which clearly shouldn't happen, since the subroutine is not inside the
interface, but below it. Therefore I propose the attached patch, which
should fix this, and which also makes a small modification to
match_attr_spec to pass on any errors it gets from gfc_match_bind_c.
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.
Index: gcc/fortran/decl.c
===================================================================
--- gcc/fortran/decl.c (revision 127658)
+++ 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;