diff --git a/18-add-test-cases-for-types-3.patch b/18-add-test-cases-for-types-3.patch new file mode 100644 index 0000000000000000000000000000000000000000..5985d2b5ec7fd46e10663d1bea24b2ffa6b0a97c --- /dev/null +++ b/18-add-test-cases-for-types-3.patch @@ -0,0 +1,501 @@ +commit c4239f85e62267499ac03d21d55b47b8a77b5689 +Author: MinchaoLiang +Date: Fri Jan 20 12:28:42 2023 +0800 + + add test cases for types 3 + +diff --git a/test/Semantics/0759_C764.f90 b/test/Semantics/0759_C764.f90 +new file mode 100644 +index 0000000..0d22270 +--- /dev/null ++++ b/test/Semantics/0759_C764.f90 +@@ -0,0 +1,14 @@ ++! Test C764:If initial-data-target appears in a component-initialization in a ++! component-decl, component-name shall be data-pointer-initialization compatible with it. ++ ++module m ++implicit none ++ type t ++ ! ERROR: No explicit type declared for 'avc' ++ integer,pointer :: k=> avc ++ end type t ++end module m ++program main ++use m ++implicit none ++end +\ No newline at end of file +diff --git a/test/Semantics/0760_C765_target.f90 b/test/Semantics/0760_C765_target.f90 +new file mode 100644 +index 0000000..71dcb4b +--- /dev/null ++++ b/test/Semantics/0760_C765_target.f90 +@@ -0,0 +1,16 @@ ++! Test C765:A designator that is an initial-data-target shall designate a nonallocatable, noncoindexed ++! variable that has the TARGET and SAVE attributes and does not have a vector subscript. Every subscript, ++! section subscript, substring starting point, and substring ending point in designator shall be a constant expression. ++ ++module m ++implicit none ++ ! ERROR: An initial data target may not be a reference to an object 'a' that lacks the TARGET attribute ++ real :: a ++ type t ++ real,pointer :: b=>a ++ end type t ++end module m ++program main ++use m ++implicit none ++end +\ No newline at end of file +diff --git a/test/Semantics/0761_C765_allocatable.f90 b/test/Semantics/0761_C765_allocatable.f90 +new file mode 100644 +index 0000000..04650e2 +--- /dev/null ++++ b/test/Semantics/0761_C765_allocatable.f90 +@@ -0,0 +1,16 @@ ++! Test C765:A designator that is an initial-data-target shall designate a nonallocatable, noncoindexed ++! variable that has the TARGET and SAVE attributes and does not have a vector subscript. Every subscript, ++! section subscript, substring starting point, and substring ending point in designator shall be a constant expression. ++ ++module m ++implicit none ++ ! ERROR: An initial data target may not be a reference to an ALLOCATABLE 'a' ++ real,target,save,allocatable :: a ++ type t ++ real,pointer :: b=>a ++ end type t ++end module m ++program main ++use m ++implicit none ++end +\ No newline at end of file +diff --git a/test/Semantics/0763_C768.f90 b/test/Semantics/0763_C768.f90 +new file mode 100644 +index 0000000..5628e63 +--- /dev/null ++++ b/test/Semantics/0763_C768.f90 +@@ -0,0 +1,21 @@ ++! Test C768:If => procedure-name appears in a type-bound-proc-decl, ++!the double-colon separator shall appear. ++ ++module m ++implicit none ++ type v ++ real :: k = 0., n = 0. ++ contains ++ !Semantic check result: OK. ++ procedure g => f ++ end type v ++ contains ++ real function f( this ) ++ class(v), intent(in) :: this ++ f = this%k+this%n ++ end function f ++end module m ++program main ++use m ++implicit none ++end +\ No newline at end of file +diff --git a/test/Semantics/0764_C769.f90 b/test/Semantics/0764_C769.f90 +new file mode 100644 +index 0000000..8cc77b5 +--- /dev/null ++++ b/test/Semantics/0764_C769.f90 +@@ -0,0 +1,18 @@ ++! Test C769:The procedure-name shall be the name of an accessible module procedure or an ++! external procedure that has an explicit interface. ++ ++module m ++implicit none ++ type v ++ real :: k = 0., n = 0. ++ contains ++ !ERROR:The binding of 'g' ('p') must be either an accessible module procedure or an external procedure with an explicit interface ++ !ERROR:No explicit type declared for 'p' ++ procedure:: g => p ++ end type v ++ contains ++end module m ++program main ++use m ++implicit none ++end +\ No newline at end of file +diff --git a/test/Semantics/0765_C770.f90 b/test/Semantics/0765_C770.f90 +new file mode 100644 +index 0000000..78ce8d0 +--- /dev/null ++++ b/test/Semantics/0765_C770.f90 +@@ -0,0 +1,21 @@ ++! Test C770:A binding-name in a type-bound-proc-decl in a derived type definition shall not be the ++! same as any other binding-name within that derived type definition. ++ ++module m ++implicit none ++ type v ++ real :: k = 0., n = 0. ++ contains ++ !ERROR:Type parameter, component, or procedure binding 'k' already defined in this type ++ procedure:: k => f ++ end type v ++ contains ++ real function f( this ) ++ class(v), intent(in) :: this ++ f = this%k+this%n ++ end function f ++end module m ++program main ++use m ++implicit none ++end +\ No newline at end of file +diff --git a/test/Semantics/0766_C771.f90 b/test/Semantics/0766_C771.f90 +new file mode 100644 +index 0000000..102a349 +--- /dev/null ++++ b/test/Semantics/0766_C771.f90 +@@ -0,0 +1,29 @@ ++! Test C771:Within the specification-part of a module, each type-bound-generic-stmt shall specify, ++! either implicitly or explicitly, the same accessibility as every other type-bound-generic-stmt with ++! that generic-spec in the same derived type. ++ ++module m ++implicit none ++ type v ++ real :: k = 0., n = 0. ++ contains ++ procedure,pass :: f3 ++ procedure,pass :: f2 ++ !ERROR:'operator(*)' does not have the same accessibility as its previous declaration ++ generic,public:: operator(*) => f2 ++ generic,private:: operator(*) => f3 ++ end type v ++ contains ++ real function f3(a,b) ++ class(v), intent(in) :: a ++ class(v), intent(in) :: b ++ end function f3 ++ real function f2(a,b) ++ class(v), intent(in) :: a ++ class(v), intent(in) :: b ++ end function f2 ++end module m ++program main ++use m ++implicit none ++end +\ No newline at end of file +diff --git a/test/Semantics/0768_C773.f90 b/test/Semantics/0768_C773.f90 +new file mode 100644 +index 0000000..43f5ec8 +--- /dev/null ++++ b/test/Semantics/0768_C773.f90 +@@ -0,0 +1,29 @@ ++! Test C773:A binding-name in a type-bound GENERIC statement shall not specify a specific binding that was ++! inherited or specified previously for the same generic identifier in that derived type definition. ++ ++module m ++implicit none ++ type v ++ real :: k = 0., n = 0. ++ contains ++ procedure,pass :: f2 ++ procedure,pass :: f ++ generic:: assignment(=) => f ++ !ERROR:Binding name 'f' was already specified for generic 'assignment(=)' ++ generic:: assignment(=) => f ++ generic:: operator(*) => f2 ++ end type v ++ contains ++ subroutine f(a,b) ++ class(v), intent(out) :: a ++ class(v), intent(in) :: b ++ end subroutine f ++ real function f2(a,b) ++ class(v), intent(in) :: a ++ class(v), intent(in) :: b ++ end function f2 ++end module m ++program main ++use m ++implicit none ++end +\ No newline at end of file +diff --git a/test/Semantics/0773_C778_nopass.f90 b/test/Semantics/0773_C778_nopass.f90 +new file mode 100644 +index 0000000..709540b +--- /dev/null ++++ b/test/Semantics/0773_C778_nopass.f90 +@@ -0,0 +1,20 @@ ++! Test C778:The same binding-attr shall not appear more than once in a given binding-attr-list. ++ ++module m ++implicit none ++ type v ++ real :: k = 0., n = 0. ++ contains ++ !WARNING:Attribute 'NOPASS' cannot be used more than once ++ procedure,nopass,nopass:: g => f ++ end type v ++ contains ++ real function f( this ) ++ class(v), intent(in) :: this ++ f = this%k+this%n ++ end function f ++end module m ++program main ++use m ++implicit none ++end +\ No newline at end of file +diff --git a/test/Semantics/0774_C778_non_overridable.f90 b/test/Semantics/0774_C778_non_overridable.f90 +new file mode 100644 +index 0000000..0499814 +--- /dev/null ++++ b/test/Semantics/0774_C778_non_overridable.f90 +@@ -0,0 +1,20 @@ ++! Test C778:The same binding-attr shall not appear more than once in a given binding-attr-list. ++ ++module m ++implicit none ++ type v ++ real :: k = 0., n = 0. ++ contains ++ !WARNING:Attribute 'NON_OVERRIDABLE' cannot be used more than once ++ procedure,non_overridable,non_overridable:: g => f ++ end type v ++ contains ++ real function f( this ) ++ class(v), intent(in) :: this ++ f = this%k+this%n ++ end function f ++end module m ++program main ++use m ++implicit none ++end +\ No newline at end of file +diff --git a/test/Semantics/0775_C778_public.f90 b/test/Semantics/0775_C778_public.f90 +new file mode 100644 +index 0000000..e21c53f +--- /dev/null ++++ b/test/Semantics/0775_C778_public.f90 +@@ -0,0 +1,20 @@ ++! Test C778:The same binding-attr shall not appear more than once in a given binding-attr-list. ++ ++module m ++implicit none ++ type v ++ real :: k = 0., n = 0. ++ contains ++ !WARNING:Attribute 'PUBLIC' cannot be used more than once ++ procedure,public,public:: g => f ++ end type v ++ contains ++ real function f( this ) ++ class(v), intent(in) :: this ++ f = this%k+this%n ++ end function f ++end module m ++program main ++use m ++implicit none ++end +\ No newline at end of file +diff --git a/test/Semantics/0776_C778_private.f90 b/test/Semantics/0776_C778_private.f90 +new file mode 100644 +index 0000000..9b15419 +--- /dev/null ++++ b/test/Semantics/0776_C778_private.f90 +@@ -0,0 +1,20 @@ ++! Test C778:The same binding-attr shall not appear more than once in a given binding-attr-list. ++ ++module m ++implicit none ++ type v ++ real :: k = 0., n = 0. ++ contains ++ !WARNING:Attribute 'PRIVATE' cannot be used more than once ++ procedure,private,private:: g => f ++ end type v ++ contains ++ real function f( this ) ++ class(v), intent(in) :: this ++ f = this%k+this%n ++ end function f ++end module m ++program main ++use m ++implicit none ++end +\ No newline at end of file +diff --git a/test/Semantics/0777_C778_pass.f90 b/test/Semantics/0777_C778_pass.f90 +new file mode 100644 +index 0000000..86f28ee +--- /dev/null ++++ b/test/Semantics/0777_C778_pass.f90 +@@ -0,0 +1,20 @@ ++! Test C778:The same binding-attr shall not appear more than once in a given binding-attr-list. ++ ++module m ++implicit none ++ type v ++ real :: k = 0., n = 0. ++ contains ++ !WARNING:Attribute 'PASS' cannot be used more than once ++ procedure,pass(p),pass(p):: g => f ++ end type v ++ contains ++ real function f( this,p ) ++ class(v), intent(in) :: this,p ++ f = this%k+this%n ++ end function f ++end module m ++program main ++use m ++implicit none ++end +\ No newline at end of file +diff --git a/test/Semantics/0778_C779.f90 b/test/Semantics/0778_C779.f90 +new file mode 100644 +index 0000000..da3ec22 +--- /dev/null ++++ b/test/Semantics/0778_C779.f90 +@@ -0,0 +1,24 @@ ++! Test C779:If the interface of the binding has no dummy argument of the type being defined, NOPASS shall appear. ++ ++module m ++implicit none ++ type v ++ integer:: m(1:2,1:2) ++ contains ++ !ERROR:Passed-object dummy argument 't' of procedure 'g' must be of type 'v' but is 'INTEGER(4)' ++ procedure:: g => load ++ end type v ++ contains ++ subroutine load ( t, U ) ++ integer,intent(out) :: t ++ type(v), intent(out), allocatable :: U ( : ) ++ t = 2 ++ allocate(U(t)) ++ U(1)% m = reshape ( [ 0, 1, 1, 0 ], [ 2, 2 ] ) ++ U (2)%m = reshape ( [ 0, 1, 1, 0 ], [ 2, 2 ] ) ++ end subroutine load ++end module m ++program main ++use m ++implicit none ++end +\ No newline at end of file +diff --git a/test/Semantics/0779_C780.f90 b/test/Semantics/0779_C780.f90 +new file mode 100644 +index 0000000..aae5307 +--- /dev/null ++++ b/test/Semantics/0779_C780.f90 +@@ -0,0 +1,20 @@ ++! Test C780: If PASS (arg-name) appears, the interface of the binding shall have a dummy argument named arg-name. ++ ++module m ++implicit none ++ type v ++ real :: k = 0., n = 0. ++ contains ++ !ERROR:'j' is not a dummy argument of procedure interface 'f' ++ procedure,pass(j):: g => f ++ end type v ++ contains ++ real function f( this,p ) ++ class(v), intent(in) :: this,p ++ f = this%k+this%n ++ end function f ++end module m ++program main ++use m ++implicit none ++end +\ No newline at end of file +diff --git a/test/Semantics/0780_C781.f90 b/test/Semantics/0780_C781.f90 +new file mode 100644 +index 0000000..00c00fd +--- /dev/null ++++ b/test/Semantics/0780_C781.f90 +@@ -0,0 +1,20 @@ ++! Test C781: PASS and NOPASS shall not both appear in the same binding-attr-list. ++ ++module m ++implicit none ++ type v ++ real :: k = 0., n = 0. ++ contains ++ !ERROR:Attributes 'PASS' and 'NOPASS' conflict with each other ++ procedure,nopass,pass:: g => f ++ end type v ++ contains ++ real function f( this ) ++ class(v), intent(in) :: this ++ f = this%k+this%n ++ end function f ++end module m ++program main ++use m ++implicit none ++end +\ No newline at end of file +diff --git a/test/Semantics/0781_C782.f90 b/test/Semantics/0781_C782.f90 +new file mode 100644 +index 0000000..60d56e3 +--- /dev/null ++++ b/test/Semantics/0781_C782.f90 +@@ -0,0 +1,20 @@ ++! Test C782:NON_OVERRIDABLE and DEFERRED shall not both appear in the same binding-attr-list. ++ ++module m ++implicit none ++ type v ++ real :: k = 0., n = 0. ++ contains ++ !ERROR:DEFERRED is only allowed when an interface-name is provided ++ procedure,non_overridable,deferred:: g => f ++ end type v ++ contains ++ real function f( this ) ++ class(v), intent(in) :: this ++ f = this%k+this%n ++ end function f ++end module m ++program main ++use m ++implicit none ++end +\ No newline at end of file +diff --git a/test/Semantics/result-08.md b/test/Semantics/result-18.md +new file mode 100644 +index 0000000..0d1e8cf +--- /dev/null ++++ b/test/Semantics/result-18.md +@@ -0,0 +1,22 @@ ++| Constraint | flang-new | gfortran | ifort | ++| :------------------: | :-------: | :------: | :---: | ++| C764 | ERROR | ERROR | ERROR | ++| C765 target | ERROR | ERROR | ERROR | ++| C765 allocatable | ERROR | ERROR | ERROR | ++| C768 | OK | ERROR | OK | ++| C769 | ERROR | ERROR | ERROR | ++| C770 | ERROR | ERROR | ERROR | ++| C771 | ERROR | ERROR | ERROR | ++| C773 | ERROR | ERROR | ERROR | ++| C775 | ERROR | ERROR | ERROR | ++| C776 | ERROR | ERROR | ERROR | ++| C777 | ERROR | ERROR | ERROR | ++| C778 nopass | WARNING | ERROR | ERROR | ++| C778 non_overridable | WARNING | ERROR | ERROR | ++| C778 public | WARNING | ERROR | ERROR | ++| C778 private | WARNING | ERROR | ERROR | ++| C778 pass | WARNING | ERROR | ERROR | ++| C779 | ERROR | ERROR | ERROR | ++| C780 | ERROR | ERROR | ERROR | ++| C781 | ERROR | ERROR | ERROR | ++| C782 | ERROR | ERROR | ERROR | diff --git a/flang.spec b/flang.spec index 9ceda8d09b42cfb0a054244bfd311087973cb1da..328696c7cd5bf4ac2d21defebec1a2fb8a533259 100644 --- a/flang.spec +++ b/flang.spec @@ -2,7 +2,7 @@ Name: flang Version: flang_20210324 -Release: 20 +Release: 21 Summary: Fortran language compiler targeting LLVM License: Apache-2.0 @@ -28,6 +28,7 @@ Patch13: 14-add-test-cases-for-attribute-declarations-and-specifications-2.patch Patch14: 15-add-test-cases-for-types-2.patch Patch15: 16-add-c-and-cxx-memory-align-investigation.patch Patch16: 17-add-fortran-memory-align-investigation.patch +Patch17: 18-add-test-cases-for-types-3.patch %description Flang depends on a fork of the LLVM project (https://github.com/flang-compiler/classic-flang-llvm-project). The fork made some changes to the upstream LLVM project to support Flang toolchain. Flang cannot build independently for now. @@ -49,6 +50,9 @@ TODO: support build Flang. %changelog +* Fri Jan 20 2023 MinchaoLiang - flang_20210324-21 +- Add patch for add test cases for types 3 + * Mon Jan 16 2023 wangzhewei - flang_20210324-20 - Fix patch 7 and patch 14