From 6b5c59db8f9fcdaf35392a09a0960a21e8cdaaf0 Mon Sep 17 00:00:00 2001 From: MinchaoLiang Date: Mon, 14 Nov 2022 16:58:49 +0800 Subject: [PATCH 1/6] add test cases for types 2 --- 9-Add-test-cases-for-types-2.patch | 459 +++++++++++++++++++++++++++++ flang.spec | 6 +- 2 files changed, 464 insertions(+), 1 deletion(-) create mode 100644 9-Add-test-cases-for-types-2.patch diff --git a/9-Add-test-cases-for-types-2.patch b/9-Add-test-cases-for-types-2.patch new file mode 100644 index 0000000..78dbf1d --- /dev/null +++ b/9-Add-test-cases-for-types-2.patch @@ -0,0 +1,459 @@ +commit 2718a52eaea622336549b1244b384d607f81b7d4 +Author: MinchaoLiang +Date: Mon Nov 14 16:55:18 2022 +0800 + + add test cases for types 2 + +diff --git a/test/Semantics/0741_C752_array.f90 b/test/Semantics/0741_C752_array.f90 +new file mode 100644 +index 0000000..a555fb7 +--- /dev/null ++++ b/test/Semantics/0741_C752_array.f90 +@@ -0,0 +1,13 @@ ++! Test C752:If the CONTIGUOUS attribute is specified, the component shall be an array with the POINTER attribute. ++ ++module types ++ type :: t ++ ! ERROR: CONTIGUOUS POINTER must be an array ++ ! ERROR: A CONTIGUOUS component must be an array with the POINTER attribute ++ real,contiguous,pointer :: S ++ end type ++end module types ++program main ++use types ++implicit none ++end +\ No newline at end of file +diff --git a/test/Semantics/0742_C752_contiguous.f90 b/test/Semantics/0742_C752_contiguous.f90 +new file mode 100644 +index 0000000..87ba2dd +--- /dev/null ++++ b/test/Semantics/0742_C752_contiguous.f90 +@@ -0,0 +1,13 @@ ++! Test C752:If the CONTIGUOUS attribute is specified, the component shall be an array with the POINTER attribute. ++ ++module types ++ type :: t ++ ! ERROR: CONTIGUOUS POINTER must be an array ++ ! ERROR: A CONTIGUOUS component must be an array with the POINTER attribute ++ real,contiguous :: S(:) ++ end type ++end module types ++program main ++use types ++implicit none ++end +\ No newline at end of file +diff --git a/test/Semantics/0743_C753_real.f90 b/test/Semantics/0743_C753_real.f90 +new file mode 100644 +index 0000000..0d0a77e +--- /dev/null ++++ b/test/Semantics/0743_C753_real.f90 +@@ -0,0 +1,12 @@ ++! Test C753:The * char-length option is permitted only if the component is of type character. ++ ++module types ++ type :: t ++ ! ERROR: expected component definition ++ real *5 :: C ++ end type ++end module types ++program main ++use types ++implicit none ++end +\ No newline at end of file +diff --git a/test/Semantics/0744_C753_logical.f90 b/test/Semantics/0744_C753_logical.f90 +new file mode 100644 +index 0000000..dcaa38b +--- /dev/null ++++ b/test/Semantics/0744_C753_logical.f90 +@@ -0,0 +1,12 @@ ++! Test C753:The * char-length option is permitted only if the component is of type character. ++ ++module types ++ type :: t ++ ! ERROR: expected component definition ++ logical *5 :: C ++ end type ++end module types ++program main ++use types ++implicit none ++end +\ No newline at end of file +diff --git a/test/Semantics/0745_C754_functions.f90 b/test/Semantics/0745_C754_functions.f90 +new file mode 100644 +index 0000000..d3dd2cc +--- /dev/null ++++ b/test/Semantics/0745_C754_functions.f90 +@@ -0,0 +1,21 @@ ++! Test C754:Each type-param-value within a component-def-stmt shall be a colon or a specification expression ++! in which there are no references to specification functions or the intrinsic functions ALLOCATED, ++! ASSOCIATED, EXTENDS_TYPE_OF, PRESENT, or SAME_TYPE_AS, every specification inquiry ++! reference is a constant expression, and the value does not depend on the value of a variable. ++ ++module types ++ type t1 ++ real c ++ end type ++ type, extends(t1) :: t2 ++ end type ++ class(t1),pointer :: p,q ++ type :: t ++ ! ERROR: Invalid specification expression: reference to impure function 'c_sizeof' ++ character (int(c_sizeof(same_type_of(p,q)))) :: C ++ end type ++end module types ++program main ++use types ++implicit none ++end +\ No newline at end of file +diff --git a/test/Semantics/0746_C754_variable.f90 b/test/Semantics/0746_C754_variable.f90 +new file mode 100644 +index 0000000..a51fa85 +--- /dev/null ++++ b/test/Semantics/0746_C754_variable.f90 +@@ -0,0 +1,16 @@ ++! Test C754:Each type-param-value within a component-def-stmt shall be a colon or a specification expression ++! in which there are no references to specification functions or the intrinsic functions ALLOCATED, ++! ASSOCIATED, EXTENDS_TYPE_OF, PRESENT, or SAME_TYPE_AS, every specification inquiry ++! reference is a constant expression, and the value does not depend on the value of a variable. ++ ++module types ++ integer :: a ++ type :: t ++ ! ERROR: not yet implemented: derived type specification expression 'int(a,kind=8)' that is neither constant nor a length type parameter ++ character *(a) :: C ++ end type ++end module types ++program main ++use types ++implicit none ++end +\ No newline at end of file +diff --git a/test/Semantics/0747_C755_public.f90 b/test/Semantics/0747_C755_public.f90 +new file mode 100644 +index 0000000..da9d6af +--- /dev/null ++++ b/test/Semantics/0747_C755_public.f90 +@@ -0,0 +1,20 @@ ++! Test C755:The same proc-component-attr-spec shall not appear more ++! than once in a given proc-component-def-stmt ++ ++module m ++implicit none ++ type :: t ++ real:: x ++ contains ++ ! WARNING: Attribute 'PUBLIC' cannot be used more than once ++ procedure,public,public::add ++ end type ++ contains ++ type(t) function add(this) ++ class(t)::this ++ end function add ++end module m ++program main ++use m ++implicit none ++end +\ No newline at end of file +diff --git a/test/Semantics/0748_C755_private.f90 b/test/Semantics/0748_C755_private.f90 +new file mode 100644 +index 0000000..6f5da29 +--- /dev/null ++++ b/test/Semantics/0748_C755_private.f90 +@@ -0,0 +1,20 @@ ++! Test C755:The same proc-component-attr-spec shall not appear more ++! than once in a given proc-component-def-stmt ++ ++module m ++implicit none ++ type :: t ++ real:: x ++ contains ++ ! WARNING: Attribute 'PRIVATE' cannot be used more than once ++ procedure,private,private::add ++ end type ++ contains ++ type(t) function add(this) ++ class(t)::this ++ end function add ++end module m ++program main ++use m ++implicit none ++end +\ No newline at end of file +diff --git a/test/Semantics/0749_C755_nopass.f90 b/test/Semantics/0749_C755_nopass.f90 +new file mode 100644 +index 0000000..5b8563b +--- /dev/null ++++ b/test/Semantics/0749_C755_nopass.f90 +@@ -0,0 +1,20 @@ ++! Test C755:The same proc-component-attr-spec shall not appear more ++! than once in a given proc-component-def-stmt ++ ++module m ++implicit none ++ type :: t ++ real :: x ++ contains ++ ! WARNING: Attribute 'NOPASS' cannot be used more than once ++ procedure,nopass,nopass :: add ++ end type ++ contains ++ type(t) function add(this) ++ class(t) :: this ++ end function add ++end module m ++program main ++use m ++implicit none ++end +\ No newline at end of file +diff --git a/test/Semantics/0750_C755_pointer.f90 b/test/Semantics/0750_C755_pointer.f90 +new file mode 100644 +index 0000000..b7bdbf0 +--- /dev/null ++++ b/test/Semantics/0750_C755_pointer.f90 +@@ -0,0 +1,19 @@ ++! Test C755:The same proc-component-attr-spec shall not appear more ++! than once in a given proc-component-def-stmt ++ ++module m ++implicit none ++ type t ++ ! WARNING: Attribute 'POINTER' cannot be used more than once ++ procedure(interface1),pointer,pointer,nopass::p ++ end type t ++ abstract interface ++ integer function interface1(a) ++ real,intent(in)::a ++ end function interface1 ++ end interface ++end module m ++program main ++use m ++implicit none ++end +\ No newline at end of file +diff --git a/test/Semantics/0751_C756.f90 b/test/Semantics/0751_C756.f90 +new file mode 100644 +index 0000000..3aed578 +--- /dev/null ++++ b/test/Semantics/0751_C756.f90 +@@ -0,0 +1,18 @@ ++! Test C756:POINTER shall appear in each proc-component-attr-spec-list. ++ ++module m ++implicit none ++ type t ++ ! ERROR: Procedure component 'p' must have POINTER attribute ++ procedure(interface1),pointer,nopass::p ++ end type t ++ abstract interface ++ integer function interface1(a) ++ real,intent(in)::a ++ end function interface1 ++ end interface ++end module m ++program main ++use m ++implicit none ++end +\ No newline at end of file +diff --git a/test/Semantics/0752_C757.f90 b/test/Semantics/0752_C757.f90 +new file mode 100644 +index 0000000..0c1f760 +--- /dev/null ++++ b/test/Semantics/0752_C757.f90 +@@ -0,0 +1,18 @@ ++! Test C757:If the procedure pointer component has an implicit interface or ++! has no arguments, NOPASS shall be specified. ++ ++module m ++implicit none ++ type t ++ ! ERROR: Procedure component 'p' with no dummy arguments must have NOPASS attribute ++ procedure(interface1),pointer :: p ++ end type t ++ abstract interface ++ integer function interface1() ++ end function interface1 ++ end interface ++end module m ++program main ++use m ++implicit none ++end +\ No newline at end of file +diff --git a/test/Semantics/0753_C758.f90 b/test/Semantics/0753_C758.f90 +new file mode 100644 +index 0000000..3260846 +--- /dev/null ++++ b/test/Semantics/0753_C758.f90 +@@ -0,0 +1,19 @@ ++! Test C758: If PASS (arg-name) appears, the interface of the procedure ++! pointer component shall have a dummy argument named arg-name. ++ ++module m ++implicit none ++ type t ++ ! ERROR: 'b' is not a dummy argument of procedure interface 'interface1' ++ procedure(interface1),pointer,pass(b)::p ++ end type t ++ abstract interface ++ integer function interface1(a) ++ real,intent(in)::a ++ end function interface1 ++ end interface ++end module m ++program main ++use m ++implicit none ++end +\ No newline at end of file +diff --git a/test/Semantics/0754_C759.f90 b/test/Semantics/0754_C759.f90 +new file mode 100644 +index 0000000..959d389 +--- /dev/null ++++ b/test/Semantics/0754_C759.f90 +@@ -0,0 +1,17 @@ ++! Test C759: PASS and NOPASS shall not both appear in the same proc-component-attr-spec-list. ++ ++module m ++implicit none ++ type t ++ ! ERROR: Attributes 'PASS' and 'NOPASS' conflict with each other ++ procedure(interface1),pointer,nopass,pass :: p ++ end type t ++ abstract interface ++ integer function interface1() ++ end function interface1 ++ end interface ++end module m ++program main ++use m ++implicit none ++end +\ No newline at end of file +diff --git a/test/Semantics/0755_C761.f90 b/test/Semantics/0755_C761.f90 +new file mode 100644 +index 0000000..ca3b7d1 +--- /dev/null ++++ b/test/Semantics/0755_C761.f90 +@@ -0,0 +1,18 @@ ++! Test C761: If component-initialization appears, a double-colon separator shall ++! appear before the component-decl-list ++ ++module m ++implicit none ++ type t ++ ! ERROR: expected PROCEDURE declarations ++ procedure(interface1),pointer,nopass p => null() ++ end type t ++ abstract interface ++ integer function interface1() ++ end function interface1 ++ end interface ++end module m ++program main ++use m ++implicit none ++end +\ No newline at end of file +diff --git a/test/Semantics/0756_C763_pointer.f90 b/test/Semantics/0756_C763_pointer.f90 +new file mode 100644 +index 0000000..3a7e4a7 +--- /dev/null ++++ b/test/Semantics/0756_C763_pointer.f90 +@@ -0,0 +1,15 @@ ++! Test C763:If => appears in component-initialization, POINTER shall appear in the ++! component-attr-spec-list. If = appears in component-initialization, neither ++! POINTER nor ALLOCATABLE shall appear in the component-attr-spec-list. ++ ++module m ++implicit none ++ type t ++ ! ERROR: 'k' is not a pointer but is initialized like one ++ integer :: k => null ++ end type t ++end module m ++program main ++use m ++implicit none ++end +\ No newline at end of file +diff --git a/test/Semantics/0757_C763_=.f90 b/test/Semantics/0757_C763_=.f90 +new file mode 100644 +index 0000000..f9f1c99 +--- /dev/null ++++ b/test/Semantics/0757_C763_=.f90 +@@ -0,0 +1,15 @@ ++! Test C763:If => appears in component-initialization, POINTER shall appear in the ++! component-attr-spec-list. If = appears in component-initialization, neither ++! POINTER nor ALLOCATABLE shall appear in the component-attr-spec-list. ++ ++module m ++implicit none ++ type t ++ ! ERROR: 'k' is a pointer but is not initialized like one ++ integer,pointer :: k = 5 ++ end type t ++end module m ++program main ++use m ++implicit none ++end +\ No newline at end of file +diff --git a/test/Semantics/0758_C763_allocatable.f90 b/test/Semantics/0758_C763_allocatable.f90 +new file mode 100644 +index 0000000..22b0c8a +--- /dev/null ++++ b/test/Semantics/0758_C763_allocatable.f90 +@@ -0,0 +1,15 @@ ++! Test C763:If => appears in component-initialization, POINTER shall appear in the ++! component-attr-spec-list. If = appears in component-initialization, neither ++! POINTER nor ALLOCATABLE shall appear in the component-attr-spec-list. ++ ++module m ++implicit none ++ type t ++ ! ERROR: Allocatable object 'k' cannot be initialized ++ integer,allocatable :: k = 5 ++ end type t ++end module m ++program main ++use m ++implicit none ++end +\ No newline at end of file +diff --git a/test/Semantics/result.md b/test/Semantics/result.md +new file mode 100644 +index 0000000..6131933 +--- /dev/null ++++ b/test/Semantics/result.md +@@ -0,0 +1,20 @@ ++| Constraint | flang-new | gfortran | ifort | ++| :--------------: | :-------: | :------: | :---: | ++| C752 array | ERROR | ERROR | ERROR | ++| C752 contiguous | ERROR | ERROR | ERROR | ++| C753 real | ERROR | ERROR | ERROR | ++| C753 logical | ERROR | ERROR | ERROR | ++| C754 functions | ERROR | ERROR | ERROR | ++| C754 variable | ERROR | ERROR | ERROR | ++| C755 public | WARNING | ERROR | ERROR | ++| C755 private | WARNING | ERROR | ERROR | ++| C755 nopass | WARNING | ERROR | ERROR | ++| C755 pointer | WARNING | ERROR | ERROR | ++| C756 | ERROR | ERROR | ERROR | ++| C757 | ERROR | ERROR | ERROR | ++| C758 | ERROR | ERROR | ERROR | ++| C759 | ERROR | ERROR | ERROR | ++| C761 | ERROR | ERROR | ERROR | ++| C763 pointer | ERROR | ERROR | ERROR | ++| C763 = | ERROR | ERROR | ERROR | ++| C763 allocatable | ERROR | ERROR | ERROR | diff --git a/flang.spec b/flang.spec index 13df369..d22c3b7 100644 --- a/flang.spec +++ b/flang.spec @@ -2,7 +2,7 @@ Name: flang Version: flang_20210324 -Release: 12 +Release: 14 Summary: Fortran language compiler targeting LLVM License: Apache-2.0 @@ -18,6 +18,7 @@ Patch3: 4-add-test-cases-for-openmp-optimization.patch Patch4: 5-test-for-interoperability-with-c-c-call-fortran.patch Patch5: 6-Add-test-cases-for-types.patch Patch6: 7-add-test-cases-for-attribute-declarations-and-specifications.patch +Patch8: 9-Add-test-cases-for-types-2.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. @@ -39,6 +40,9 @@ TODO: support build Flang. %changelog +* Thu Nov 14 2022 MinchaoLiang - flang_20210324-13 +- Add patch for add test cases for types 2 + * Thu Oct 27 2022 wangzhewei - flang_20210324-12 - Add patch for add test cases for attribute declarations and specifications -- Gitee From e622f8f22c540a3d6aa5d49a388db0527c1a0e6b Mon Sep 17 00:00:00 2001 From: LMC Date: Mon, 14 Nov 2022 11:46:43 +0000 Subject: [PATCH 2/6] update flang.spec. Signed-off-by: LMC --- flang.spec | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/flang.spec b/flang.spec index d22c3b7..62cb451 100644 --- a/flang.spec +++ b/flang.spec @@ -2,7 +2,7 @@ Name: flang Version: flang_20210324 -Release: 14 +Release: 13 Summary: Fortran language compiler targeting LLVM License: Apache-2.0 @@ -18,7 +18,7 @@ Patch3: 4-add-test-cases-for-openmp-optimization.patch Patch4: 5-test-for-interoperability-with-c-c-call-fortran.patch Patch5: 6-Add-test-cases-for-types.patch Patch6: 7-add-test-cases-for-attribute-declarations-and-specifications.patch -Patch8: 9-Add-test-cases-for-types-2.patch +Patch7: 8-Add-test-cases-for-types-2.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. -- Gitee From f75e3ed1d4c6e465656b14a821a0a1a713a7e83f Mon Sep 17 00:00:00 2001 From: LMC Date: Mon, 14 Nov 2022 11:47:11 +0000 Subject: [PATCH 3/6] rename 9-Add-test-cases-for-types-2.patch to 8-Add-test-cases-for-types-2.patch. Signed-off-by: LMC --- ...-cases-for-types-2.patch => 8-Add-test-cases-for-types-2.patch | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename 9-Add-test-cases-for-types-2.patch => 8-Add-test-cases-for-types-2.patch (100%) diff --git a/9-Add-test-cases-for-types-2.patch b/8-Add-test-cases-for-types-2.patch similarity index 100% rename from 9-Add-test-cases-for-types-2.patch rename to 8-Add-test-cases-for-types-2.patch -- Gitee From bca0f301a49bc2f02adeffe8a2a5bc3da86a2040 Mon Sep 17 00:00:00 2001 From: LMC Date: Mon, 14 Nov 2022 12:05:34 +0000 Subject: [PATCH 4/6] update flang.spec. Signed-off-by: LMC --- flang.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flang.spec b/flang.spec index 62cb451..9825ed5 100644 --- a/flang.spec +++ b/flang.spec @@ -40,7 +40,7 @@ TODO: support build Flang. %changelog -* Thu Nov 14 2022 MinchaoLiang - flang_20210324-13 +* Thu Mon 14 2022 MinchaoLiang - flang_20210324-13 - Add patch for add test cases for types 2 * Thu Oct 27 2022 wangzhewei - flang_20210324-12 -- Gitee From 1963d591e0d599a6bbdaf45b5228c2102a56f09a Mon Sep 17 00:00:00 2001 From: LMC Date: Mon, 14 Nov 2022 12:16:35 +0000 Subject: [PATCH 5/6] update flang.spec. Signed-off-by: LMC --- flang.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flang.spec b/flang.spec index 9825ed5..561332a 100644 --- a/flang.spec +++ b/flang.spec @@ -40,7 +40,7 @@ TODO: support build Flang. %changelog -* Thu Mon 14 2022 MinchaoLiang - flang_20210324-13 +* Mon Nov 14 2022 MinchaoLiang - flang_20210324-13 - Add patch for add test cases for types 2 * Thu Oct 27 2022 wangzhewei - flang_20210324-12 -- Gitee From cbbf4d5bae7ddaa8bc84c333650a0fa215515727 Mon Sep 17 00:00:00 2001 From: LMC Date: Mon, 14 Nov 2022 12:29:49 +0000 Subject: [PATCH 6/6] update 8-Add-test-cases-for-types-2.patch. Signed-off-by: LMC --- 8-Add-test-cases-for-types-2.patch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/8-Add-test-cases-for-types-2.patch b/8-Add-test-cases-for-types-2.patch index 78dbf1d..1b8261a 100644 --- a/8-Add-test-cases-for-types-2.patch +++ b/8-Add-test-cases-for-types-2.patch @@ -2,7 +2,7 @@ commit 2718a52eaea622336549b1244b384d607f81b7d4 Author: MinchaoLiang Date: Mon Nov 14 16:55:18 2022 +0800 - add test cases for types 2 + Add test cases for types 2 diff --git a/test/Semantics/0741_C752_array.f90 b/test/Semantics/0741_C752_array.f90 new file mode 100644 -- Gitee