public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/108650] New: Error: IMPORT statement only permitted in an INTERFACE body | but it should be allowed in any contained routine to control scope
@ 2023-02-03 0:22 Boyce at engineer dot com
2023-02-03 7:19 ` [Bug fortran/108650] " kargl at gcc dot gnu.org
2023-06-02 15:24 ` kargl at gcc dot gnu.org
0 siblings, 2 replies; 3+ messages in thread
From: Boyce at engineer dot com @ 2023-02-03 0:22 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108650
Bug ID: 108650
Summary: Error: IMPORT statement only permitted in an INTERFACE
body | but it should be allowed in any contained
routine to control scope
Product: gcc
Version: 11.3.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
Assignee: unassigned at gcc dot gnu.org
Reporter: Boyce at engineer dot com
Target Milestone: ---
Created attachment 54398
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=54398&action=edit
Source code, bash file to compile, and error message
import should be allowed within contained subroutines to
control access to global variables from parent routine.
From:
http://armnlib.uqam.ca/PDF/The_New_Features_of_Fortran_2018.pdf
The import statement can be used in a contained subprogram or
block construct to control host association.
It does not look like import is on the F2018 standard website:
https://gcc.gnu.org/wiki/Fortran2018Status
but it should work within contained routines:
https://www.intel.com/content/www/us/en/develop/documentation/fortran-compiler-oneapi-dev-guide-and-reference/top/language-reference/a-to-z-reference/h-to-i/import.html
I tested this code with with 11.3.0 and 12.1.0
I attached the following source code:
--------------------------------------------
module test
implicit none
!
save
integer:: a = 0
integer:: b = 0
integer:: c = 0
!
contains
!
subroutine sub1(x)
import:: a ! raises error that import only allowed in
interface
real, intent(inout):: x
a = a + 1
x = x + 1.0
end subroutine
!
subroutine sub2(x)
real, intent(inout):: x
x = x + 1.0
!
contains
!
function positive(x) result(ans)
import, none ! raises error that import only allowed in
interface
real, intent(in):: x
logical:: ans
ans = x>=0.0
end function
end subroutine
end module
program MAIN
use test
implicit none
real:: var
var = 1.0
call sub1(var)
call sub2(var)
!
end program
--------------------------------------------
$ gfortran --version
Copyright (C) 2021 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ gfortran-12 main.f90
12 | import:: a ! raises error that import only alowed in
interface
| 1
Error: IMPORT statement at (1) only permitted in an INTERFACE body
main.f90:25:15:
25 | import, none
| 1
Error: IMPORT statement at (1) only permitted in an INTERFACE body
main.f90:34:7:
-------------------------------------------------------------------------------
$ gfortran-12 --version
GNU Fortran (Ubuntu 12.1.0-2ubuntu1~22.04) 12.1.0
Copyright (C) 2022 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ gfortran-12 main.f90
25 | import, none
| 1
Error: IMPORT statement at (1) only permitted in an INTERFACE body
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug fortran/108650] Error: IMPORT statement only permitted in an INTERFACE body | but it should be allowed in any contained routine to control scope
2023-02-03 0:22 [Bug fortran/108650] New: Error: IMPORT statement only permitted in an INTERFACE body | but it should be allowed in any contained routine to control scope Boyce at engineer dot com
@ 2023-02-03 7:19 ` kargl at gcc dot gnu.org
2023-06-02 15:24 ` kargl at gcc dot gnu.org
1 sibling, 0 replies; 3+ messages in thread
From: kargl at gcc dot gnu.org @ 2023-02-03 7:19 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108650
kargl at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |kargl at gcc dot gnu.org
--- Comment #1 from kargl at gcc dot gnu.org ---
This is duplicate of at least one other bug report.
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug fortran/108650] Error: IMPORT statement only permitted in an INTERFACE body | but it should be allowed in any contained routine to control scope
2023-02-03 0:22 [Bug fortran/108650] New: Error: IMPORT statement only permitted in an INTERFACE body | but it should be allowed in any contained routine to control scope Boyce at engineer dot com
2023-02-03 7:19 ` [Bug fortran/108650] " kargl at gcc dot gnu.org
@ 2023-06-02 15:24 ` kargl at gcc dot gnu.org
1 sibling, 0 replies; 3+ messages in thread
From: kargl at gcc dot gnu.org @ 2023-06-02 15:24 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108650
kargl at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution|--- |DUPLICATE
--- Comment #2 from kargl at gcc dot gnu.org ---
Dup.
*** This bug has been marked as a duplicate of bug 106035 ***
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-06-02 15:24 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-03 0:22 [Bug fortran/108650] New: Error: IMPORT statement only permitted in an INTERFACE body | but it should be allowed in any contained routine to control scope Boyce at engineer dot com
2023-02-03 7:19 ` [Bug fortran/108650] " kargl at gcc dot gnu.org
2023-06-02 15:24 ` kargl at gcc dot gnu.org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).