Bug 35031 - ELEMENTAL procedure with BIND(C)
Summary: ELEMENTAL procedure with BIND(C)
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.3.0
: P4 normal
Target Milestone: 7.5
Assignee: kargls
URL:
Keywords: accepts-invalid
Depends on:
Blocks: ISO_C_Binding
  Show dependency treegraph
 
Reported: 2008-01-30 16:12 UTC by Tobias Burnus
Modified: 2019-01-12 00:34 UTC (History)
5 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2008-02-04 17:34:53


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tobias Burnus 2008-01-30 16:12:13 UTC
ELEMENTAL conflicts with BIND(C).

However, the following is not rejected (diagnosed) by gfortran:

   elemental subroutine sub(x)
     integer, intent(in) :: x
     entry sub_c(x) bind(c)
   end subroutine sub

Actually, this is a loop hole in the Fortran 2003 standard, which will be presumably fixed by an erratum. (It passed the J3 ballot, WG3 and ISO approval are still needed.) See F03/0086:

ANSWER:

 No, it is not allowed. Constraint C1242 was intended to disallow
 the combination of elemental and BIND(C), but it inadvertently
 failed to cover the case shown in the above example.

EDITS

 Replace C1242 in subclause 12.5.2.1 with
 [280:6-7]
 "C1242 An ELEMENTAL procedure shall not have the BIND attribute.".
Comment 1 Tobias Burnus 2008-06-02 16:06:40 UTC
Draft 2003 corrigendum 3: ftp://ftp.nag.co.uk/sc22wg5/N1701-N1750/N1727.pdf
(Not yet sent to ISO and thus also not ISO approved.)
Comment 2 Daniel Franke 2010-05-09 13:34:04 UTC
(In reply to comment #1)
> Draft 2003 corrigendum 3: ftp://ftp.nag.co.uk/sc22wg5/N1701-N1750/N1727.pdf
> (Not yet sent to ISO and thus also not ISO approved.)

See ftp://ftp.nag.co.uk/sc22wg5/N1701-N1750/N1731.pdf
Comment 3 Francois-Xavier Coudert 2014-07-09 22:38:52 UTC
That code is now rejected (for a wrong reason), due to PR61765.
Comment 4 Dominique d'Humieres 2015-11-04 10:46:24 UTC
This is

C1252 An elemental procedure shall not have the BIND attribute.

in subclause 12.6.2.1 of my Fortran 2015 draft.
Comment 5 kargls 2019-01-11 23:41:36 UTC
Author: kargl
Date: Fri Jan 11 23:41:04 2019
New Revision: 267864

URL: https://gcc.gnu.org/viewcvs?rev=267864&root=gcc&view=rev
Log:
2019-01-11  Steven G. Kargl  <kargl@gcc.gnu.org>

	PR fortran/35031
	* decl.c (gfc_match_entry): Check for F2018:C1546.  Fix nearby
	mis-indentation.
 
2019-01-11  Steven G. Kargl  <kargl@gcc.gnu.org>

	PR fortran/35031
	* gfortran.dg/pr35031.f90: new test.

Added:
    trunk/gcc/testsuite/gfortran.dg/pr35031.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/decl.c
    trunk/gcc/testsuite/ChangeLog
Comment 6 kargls 2019-01-12 00:15:26 UTC
Author: kargl
Date: Sat Jan 12 00:14:55 2019
New Revision: 267869

URL: https://gcc.gnu.org/viewcvs?rev=267869&root=gcc&view=rev
Log:
2019-01-11  Steven G. Kargl  <kargl@gcc.gnu.org>

	PR fortran/35031
	* decl.c (gfc_match_entry): Check for F2018:C1546.  Fix nearby
	mis-indentation.
 
2019-01-11  Steven G. Kargl  <kargl@gcc.gnu.org>

	PR fortran/35031
	* gfortran.dg/pr35031.f90: new test.

Added:
    branches/gcc-8-branch/gcc/testsuite/gfortran.dg/pr35031.f90
Modified:
    branches/gcc-8-branch/gcc/fortran/ChangeLog
    branches/gcc-8-branch/gcc/fortran/decl.c
    branches/gcc-8-branch/gcc/testsuite/ChangeLog
Comment 7 kargls 2019-01-12 00:33:32 UTC
Author: kargl
Date: Sat Jan 12 00:33:01 2019
New Revision: 267874

URL: https://gcc.gnu.org/viewcvs?rev=267874&root=gcc&view=rev
Log:
2019-01-11  Steven G. Kargl  <kargl@gcc.gnu.org>

	PR fortran/35031
	* decl.c (gfc_match_entry): Check for F2018:C1546.  Fix nearby
	mis-indentation.
 
2019-01-11  Steven G. Kargl  <kargl@gcc.gnu.org>

	PR fortran/35031
	* gfortran.dg/pr35031.f90: new test.

Added:
    branches/gcc-7-branch/gcc/testsuite/gfortran.dg/pr35031.f90
Modified:
    branches/gcc-7-branch/gcc/fortran/ChangeLog
    branches/gcc-7-branch/gcc/fortran/decl.c
    branches/gcc-7-branch/gcc/testsuite/ChangeLog
Comment 8 kargls 2019-01-12 00:34:29 UTC
Fixed on trunk, branch8, and branch-7.  Closing.