Bug 60355 - [F08] constraint C519 for BIND attribute not enforced
Summary: [F08] constraint C519 for BIND attribute not enforced
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 7.1.1
: P3 normal
Target Milestone: ---
Assignee: Thomas Koenig
URL:
Keywords:
Depends on:
Blocks: F2008
  Show dependency treegraph
 
Reported: 2014-02-27 08:46 UTC by Vladimir Fuka
Modified: 2017-09-13 16:54 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2015-09-05 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Vladimir Fuka 2014-02-27 08:46:09 UTC
bind(C) test_bind
end

is compiled without error or warning with

gfortran -std=f2008

but

C519 A variable with the BIND attribute shall be declared in the specification part of a module.
Comment 1 Dominique d'Humieres 2015-09-05 10:25:12 UTC
Confirmed at r227506.
Comment 2 Thomas Koenig 2017-08-02 12:21:51 UTC
Apparently only for implicitly-typed variables.

This works as expected:

program main
  integer, bind(c) :: i
end program main
$ gfortran a.f90 
a.f90:2:23:

   integer, bind(c) :: i
                       1
Error: Variable 'i' at (1) cannot be BIND(C) because it is neither a COMMON block nor declared at the module level scope
Comment 3 Thomas Koenig 2017-08-02 12:32:59 UTC
I have a patch.
Comment 4 Thomas Koenig 2017-08-11 17:46:48 UTC
Author: tkoenig
Date: Fri Aug 11 17:45:36 2017
New Revision: 251054

URL: https://gcc.gnu.org/viewcvs?rev=251054&root=gcc&view=rev
Log:
2017-08-11  Thomas Koenig  <tkoenig@gcc.gnu.org>

	PR fortran/60355
	* resolve.c (resolve_symbol): Adjust (and reformat)
	comment.  Perform check if a BIND(C) is declared
	at module level regardless of whether it is typed
	implicitly or not.

2017-08-11  Thomas Koenig  <tkoenig@gcc.gnu.org>

	PR fortran/60355
	* gfortran.dg (bind_c_usage_30): New test.


Added:
    trunk/gcc/testsuite/gfortran.dg/bind_c_usage_30.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/resolve.c
    trunk/gcc/testsuite/ChangeLog
Comment 5 Thomas Koenig 2017-08-12 13:19:45 UTC
Fixed on trunk, closing.
Comment 6 Aldy Hernandez 2017-09-13 16:54:21 UTC
Author: aldyh
Date: Wed Sep 13 16:53:49 2017
New Revision: 252408

URL: https://gcc.gnu.org/viewcvs?rev=252408&root=gcc&view=rev
Log:
2017-08-11  Thomas Koenig  <tkoenig@gcc.gnu.org>

	PR fortran/60355
	* resolve.c (resolve_symbol): Adjust (and reformat)
	comment.  Perform check if a BIND(C) is declared
	at module level regardless of whether it is typed
	implicitly or not.

2017-08-11  Thomas Koenig  <tkoenig@gcc.gnu.org>

	PR fortran/60355
	* gfortran.dg (bind_c_usage_30): New test.

Added:
    branches/range-gen2/gcc/testsuite/gfortran.dg/bind_c_usage_30.f90
Modified:
    branches/range-gen2/gcc/fortran/ChangeLog
    branches/range-gen2/gcc/fortran/resolve.c
    branches/range-gen2/gcc/testsuite/ChangeLog