This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
[Fortran,patch] Fix problem with IMPORT (PR27546)
- From: Tobias Burnus <burnus at net-b dot de>
- To: "'fortran at gcc dot gnu dot org'" <fortran at gcc dot gnu dot org>, gcc-patches <gcc-patches at gcc dot gnu dot org>
- Date: Sat, 18 Nov 2006 11:41:13 +0100
- Subject: [Fortran,patch] Fix problem with IMPORT (PR27546)
:ADDPATCH fortran:
This fixes one of the two problems IMPORT has.
(I will now to find the proper solutions for the "IMPORT :: symbol-list"
problem, which is really disjunct.)
This used to give an error as "dp" couldn't be found, derived types
could be found before.
integer, parameter :: dp = 8
interface
subroutine foo(x)
import
real(dp) :: x
end subroutine foo
end interface
The patch is really trivial!
(I know I looked at primary.c if before, but seemingly not close enough. :-(
I did a build and regression test on x86_64-unknown-linux-gnu.
I had no failures (when ignoring the results with -froll-loops and
-funroll-all-loops).
Ok for the trunk?
Tobias
fortran/
2006-11-17 Tobias Burnus <burnus@net-b.de>
PR fortran/27546
* primary.c (gfc_match_rvalue): Added IMPORT support.
testsuite/
2006-11-17 Tobias Burnus <burnus@net-b.de>
PR fortran/27546
* gfortran.dg/import.f90: Extended test.
* gfortran.dg/import2.f90: Extended test.
Index: gcc/testsuite/gfortran.dg/import.f90
===================================================================
--- gcc/testsuite/gfortran.dg/import.f90 (Revision 118945)
+++ gcc/testsuite/gfortran.dg/import.f90 (Arbeitskopie)
@@ -13,18 +13,36 @@
end subroutine test
-subroutine bar(x)
+subroutine bar(x,y)
type myType
sequence
integer :: i
end type myType
type(myType) :: x
+ integer(8) :: y
+ if(y /= 8) call abort()
if(x%i /= 2) call abort()
x%i = 5
+ y = 42
end subroutine bar
+module testmod
+ implicit none
+ integer, parameter :: kind = 8
+ type modType
+ real :: rv
+ end type modType
+ interface
+ subroutine other(x,y)
+ import
+ real(kind) :: x
+ type(modType) :: y
+ end subroutine
+ end interface
+end module testmod
program foo
+ integer, parameter :: dp = 8
type myType
sequence
integer :: i
@@ -34,9 +52,10 @@
integer :: i
end type myType3
interface
- subroutine bar(x)
+ subroutine bar(x,y)
import
type(myType) :: x
+ integer(dp) :: y
end subroutine bar
subroutine test(x)
import :: myType3
@@ -47,10 +66,13 @@
type(myType) :: y
type(myType3) :: z
+ integer(8) :: i8
y%i = 2
- call bar(y)
- if(y%i /= 5) call abort()
+ i8 = 8
+ call bar(y,i8)
+ if(y%i /= 5 .or. i8/= 42) call abort()
z%i = 7
call test(z)
if(z%i /= 1) call abort()
end program foo
+! { dg-final { cleanup-modules "testmod" } }
Index: gcc/testsuite/gfortran.dg/import2.f90
===================================================================
--- gcc/testsuite/gfortran.dg/import2.f90 (Revision 118945)
+++ gcc/testsuite/gfortran.dg/import2.f90 (Arbeitskopie)
@@ -15,18 +15,36 @@
end subroutine test
-subroutine bar(x)
+subroutine bar(x,y)
type myType
sequence
integer :: i
end type myType
type(myType) :: x
+ integer(8) :: y
+ if(y /= 8) call abort()
if(x%i /= 2) call abort()
x%i = 5
+ y = 42
end subroutine bar
+module testmod
+ implicit none
+ integer, parameter :: kind = 8
+ type modType
+ real :: rv
+ end type modType
+ interface
+ subroutine other(x,y)
+ import ! { dg-error "Fortran 2003: IMPORT statement" }
+ type(modType) :: y ! { dg-error "not been declared within the interface" }
+ real(kind) :: x ! { dg-error "has not been declared" }
+ end subroutine
+ end interface
+end module testmod
program foo
+ integer, parameter :: dp = 8
type myType
sequence
integer :: i
@@ -36,9 +54,10 @@
integer :: i
end type myType3
interface
- subroutine bar(x)
+ subroutine bar(x,y)
import ! { dg-error "Fortran 2003: IMPORT statement" }
type(myType) :: x ! { dg-error "not been declared within the interface" }
+ integer(dp) :: y ! { dg-error "has not been declared" }
end subroutine bar
subroutine test(x)
import :: myType3 ! { dg-error "Fortran 2003: IMPORT statement" }
@@ -49,10 +68,13 @@
type(myType) :: y
type(myType3) :: z
+ integer(dp) :: i8
y%i = 2
- call bar(y) ! { dg-error "Type/rank mismatch in argument" }
- if(y%i /= 5) call abort()
+ i8 = 8
+ call bar(y,i8) ! { dg-error "Type/rank mismatch in argument" }
+ if(y%i /= 5 .or. i8/= 42) call abort()
z%i = 7
call test(z) ! { dg-error "Type/rank mismatch in argument" }
if(z%i /= 1) call abort()
end program foo
+! { dg-final { cleanup-modules "testmod" } }
Index: gcc/fortran/primary.c
===================================================================
--- gcc/fortran/primary.c (Revision 118945)
+++ gcc/fortran/primary.c (Arbeitskopie)
@@ -1917,7 +1917,8 @@
if (m != MATCH_YES)
return m;
- if (gfc_find_state (COMP_INTERFACE) == SUCCESS)
+ if (gfc_find_state (COMP_INTERFACE) == SUCCESS
+ && !gfc_current_ns->has_import_set)
i = gfc_get_sym_tree (name, NULL, &symtree);
else
i = gfc_get_ha_sym_tree (name, &symtree);