forked from lcompilers/lpython
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
And move it to integration_tests.
- Loading branch information
Showing
8 changed files
with
120 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
! Submodules test, taken from: | ||
! https://www.ibm.com/docs/en/xl-fortran-aix/15.1.3?topic=techniques-submodules-fortran-2008 | ||
MODULE m1 | ||
TYPE Base | ||
INTEGER :: i | ||
END TYPE | ||
|
||
INTERFACE | ||
MODULE SUBROUTINE sub1(i, b) ! Module procedure interface body for sub1 | ||
INTEGER, INTENT(IN) :: i | ||
TYPE(Base), INTENT(IN) :: b | ||
END SUBROUTINE | ||
END INTERFACE | ||
END MODULE | ||
|
||
MODULE m2 | ||
USE m1 ! Use association of module m1 | ||
|
||
INTERFACE | ||
REAL MODULE FUNCTION func1() ! Module procedure interface body for func1 | ||
END FUNCTION | ||
|
||
MODULE FUNCTION func2(b) ! Module procedure interface body for func2 | ||
TYPE(Base) :: b | ||
TYPE(Base) :: func2 | ||
END FUNCTION | ||
END INTERFACE | ||
END MODULE | ||
|
||
MODULE m4 | ||
USE m1 ! Use association of module m1 | ||
TYPE, EXTENDS(Base) :: NewType | ||
REAL :: j | ||
END TYPE | ||
END MODULE | ||
|
||
SUBMODULE (m1) m1sub | ||
USE m4 ! Use association of module m4 | ||
|
||
CONTAINS | ||
MODULE SUBROUTINE sub1(i, b) ! Implementation of sub1 declared in m1 | ||
INTEGER, INTENT(IN) :: i | ||
TYPE(Base), INTENT(IN) :: b | ||
PRINT *, "sub1", i, b | ||
END SUBROUTINE | ||
END SUBMODULE | ||
|
||
SUBMODULE (m2) m2sub | ||
|
||
CONTAINS | ||
REAL MODULE FUNCTION func1() ! Implementation of func1 declared in m2 | ||
func1 = 20 | ||
END FUNCTION | ||
END SUBMODULE | ||
|
||
SUBMODULE (m2:m2sub) m2sub2 | ||
|
||
CONTAINS | ||
MODULE FUNCTION func2(b) ! Implementation of func2 declared in m2 | ||
TYPE(Base) :: b | ||
TYPE(Base) :: func2 | ||
func2 = b | ||
END FUNCTION | ||
END SUBMODULE | ||
|
||
MODULE m3 | ||
INTERFACE | ||
SUBROUTINE interfaceSub1(i, b) | ||
USE m1 | ||
INTEGER, INTENT(IN) :: i | ||
TYPE(Base), INTENT(IN) :: b | ||
END SUBROUTINE | ||
|
||
REAL FUNCTION interfaceFunc1() | ||
END FUNCTION | ||
|
||
FUNCTION interfaceFunc2(b) | ||
USE m1 | ||
TYPE(Base) :: b | ||
TYPE(Base) :: interfaceFunc2 | ||
END FUNCTION | ||
END INTERFACE | ||
|
||
TYPE Container | ||
PROCEDURE(interfaceSub1), NOPASS, POINTER :: pp1 | ||
PROCEDURE(interfaceFunc1), NOPASS, POINTER :: pp2 | ||
PROCEDURE(interfaceFunc2), NOPASS, POINTER :: pp3 | ||
END TYPE | ||
END MODULE | ||
|
||
PROGRAM example | ||
USE m1 | ||
USE m2 | ||
USE m3 | ||
TYPE(Container) :: c1 | ||
c1%pp1 => sub1 | ||
c1%pp2 => func1 | ||
c1%pp3 => func2 | ||
|
||
CALL c1%pp1(10, Base(11)) | ||
PRINT *, "func1", int(c1%pp2()) | ||
PRINT *, "func2", c1%pp3(Base(5)) | ||
END PROGRAM |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"basename": "ast-submodule_01-2524ba9", | ||
"cmd": "lfortran --show-ast --no-color {infile} -o {outfile}", | ||
"infile": "tests/../integration_tests/submodule_01.f90", | ||
"infile_hash": "ed0ecc9003bb9cd8e6be1f4f77cd3e59f45d09f2ba2f64029dc3680e", | ||
"outfile": null, | ||
"outfile_hash": null, | ||
"stdout": "ast-submodule_01-2524ba9.stdout", | ||
"stdout_hash": "6d715a6d90ef8db704478de6c2c2db02e580cc5318daa854c4472b63", | ||
"stderr": null, | ||
"stderr_hash": null, | ||
"returncode": 0 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
(TranslationUnit [(Module m1 [] [] [(DerivedType Base [] [(Declaration (AttrType TypeInteger [] ()) [] [(i [] [] () None ())])] []) (Interface (InterfaceHeader) [(InterfaceProc (Subroutine sub1 [(i) (b)] [(SimpleAttribute AttrModule)] () [] [] [] [(Declaration (AttrType TypeInteger [] ()) [(AttrIntent In)] [(i [] [] () None ())]) (Declaration (AttrType TypeType [] Base) [(AttrIntent In)] [(b [] [] () None ())])] [] []))])] []) (Module m2 [(Use [] m1 [] .false.)] [] [(Interface (InterfaceHeader) [(InterfaceProc (Function func1 [] [(AttrType TypeReal [] ()) (SimpleAttribute AttrModule)] () () [] [] [] [] [] [])) (InterfaceProc (Function func2 [(b)] [(SimpleAttribute AttrModule)] () () [] [] [] [(Declaration (AttrType TypeType [] Base) [] [(b [] [] () None ())]) (Declaration (AttrType TypeType [] Base) [] [(func2 [] [] () None ())])] [] []))])] []) (Module m4 [(Use [] m1 [] .false.)] [] [(DerivedType NewType [(AttrExtends Base)] [(Declaration (AttrType TypeReal [] ()) [] [(j [] [] () None ())])] [])] []) (Submodule m1 () m1sub [(Use [] m4 [] .false.)] [] [] [(Subroutine sub1 [(i) (b)] [(SimpleAttribute AttrModule)] () [] [] [] [(Declaration (AttrType TypeInteger [] ()) [(AttrIntent In)] [(i [] [] () None ())]) (Declaration (AttrType TypeType [] Base) [(AttrIntent In)] [(b [] [] () None ())])] [(Print 0 () [(Str "sub1") i b])] [])]) (Submodule m2 () m2sub [] [] [] [(Function func1 [] [(AttrType TypeReal [] ()) (SimpleAttribute AttrModule)] () () [] [] [] [] [(= 0 func1 20)] [])]) (Submodule m2 m2sub m2sub2 [] [] [] [(Function func2 [(b)] [(SimpleAttribute AttrModule)] () () [] [] [] [(Declaration (AttrType TypeType [] Base) [] [(b [] [] () None ())]) (Declaration (AttrType TypeType [] Base) [] [(func2 [] [] () None ())])] [(= 0 func2 b)] [])]) (Module m3 [] [] [(Interface (InterfaceHeader) [(InterfaceProc (Subroutine interfaceSub1 [(i) (b)] [] () [(Use [] m1 [] .false.)] [] [] [(Declaration (AttrType TypeInteger [] ()) [(AttrIntent In)] [(i [] [] () None ())]) (Declaration (AttrType TypeType [] Base) [(AttrIntent In)] [(b [] [] () None ())])] [] [])) (InterfaceProc (Function interfaceFunc1 [] [(AttrType TypeReal [] ())] () () [] [] [] [] [] [])) (InterfaceProc (Function interfaceFunc2 [(b)] [] () () [(Use [] m1 [] .false.)] [] [] [(Declaration (AttrType TypeType [] Base) [] [(b [] [] () None ())]) (Declaration (AttrType TypeType [] Base) [] [(interfaceFunc2 [] [] () None ())])] [] []))]) (DerivedType Container [] [(Declaration (AttrType TypeProcedure [] interfaceSub1) [(SimpleAttribute AttrNoPass) (SimpleAttribute AttrPointer)] [(pp1 [] [] () None ())]) (Declaration (AttrType TypeProcedure [] interfaceFunc1) [(SimpleAttribute AttrNoPass) (SimpleAttribute AttrPointer)] [(pp2 [] [] () None ())]) (Declaration (AttrType TypeProcedure [] interfaceFunc2) [(SimpleAttribute AttrNoPass) (SimpleAttribute AttrPointer)] [(pp3 [] [] () None ())])] [])] []) (Program example [(Use [] m1 [] .false.) (Use [] m2 [] .false.) (Use [] m3 [] .false.)] [] [(Declaration (AttrType TypeType [] Container) [] [(c1 [] [] () None ())])] [(=> 0 pp1 sub1) (=> 0 pp2 func1) (=> 0 pp3 func2) (SubroutineCall 0 pp1 [(c1 [])] [(() 10 ()) (() (FuncCallOrArray Base [] [(() 11 ())] [] []) ())] []) (Print 0 () [(Str "func1") (FuncCallOrArray int [] [(() (FuncCallOrArray pp2 [(c1 [])] [] [] []) ())] [] [])]) (Print 0 () [(Str "func2") (FuncCallOrArray pp3 [(c1 [])] [(() (FuncCallOrArray Base [] [(() 5 ())] [] []) ())] [] [])])] [])]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters