From c6465b35e880af562450a2c9184db093ef7b04b0 Mon Sep 17 00:00:00 2001 From: MinchaoLiang Date: Mon, 14 Nov 2022 21:20:22 +0800 Subject: [PATCH 1/4] add test cases for types 2 --- 8-add-test-cases-for-types-2.patch | 459 +++++++++++++++++++++++++++++ flang.spec | 6 +- 2 files changed, 464 insertions(+), 1 deletion(-) create mode 100644 8-add-test-cases-for-types-2.patch diff --git a/8-add-test-cases-for-types-2.patch b/8-add-test-cases-for-types-2.patch new file mode 100644 index 0000000..6f7bb1d --- /dev/null +++ b/8-add-test-cases-for-types-2.patch @@ -0,0 +1,459 @@ +commit 73125352957db63cc9cb32b64969bb45e418e493 +Author: MinchaoLiang +Date: Mon Nov 14 21:11:07 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..59fc826 +--- /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 | \ No newline at end of file diff --git a/flang.spec b/flang.spec index 13df369..4aae78b 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 +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. @@ -39,6 +40,9 @@ TODO: support build Flang. %changelog +* 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 - Add patch for add test cases for attribute declarations and specifications -- Gitee From b7889aeac6988fb79398a2f36335d19e45c56c73 Mon Sep 17 00:00:00 2001 From: LMC Date: Mon, 14 Nov 2022 13:26:33 +0000 Subject: [PATCH 2/4] 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 4aae78b..42af303 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 -- Gitee From d88336838f4c87d0a7e4e9b994dd16d4bd9044a4 Mon Sep 17 00:00:00 2001 From: LMC Date: Mon, 14 Nov 2022 13:43:08 +0000 Subject: [PATCH 3/4] update 8-add-test-cases-for-types-2.patch. Signed-off-by: LMC --- 8-add-test-cases-for-types-2.patch | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/8-add-test-cases-for-types-2.patch b/8-add-test-cases-for-types-2.patch index 6f7bb1d..f28b3fb 100644 --- a/8-add-test-cases-for-types-2.patch +++ b/8-add-test-cases-for-types-2.patch @@ -431,7 +431,7 @@ index 0000000..22b0c8a +implicit none +end \ No newline at end of file -diff --git a/test/Semantics/result.md b/test/Semantics/result.md +diff --git a/test/Semantics/result.md b/test/Semantics/result=08.md new file mode 100644 index 0000000..59fc826 --- /dev/null @@ -456,4 +456,4 @@ index 0000000..59fc826 +| C761 | ERROR | ERROR | ERROR | +| C763 pointer | ERROR | ERROR | ERROR | +| C763 = | ERROR | ERROR | ERROR | -+| C763 allocatable | ERROR | ERROR | ERROR | \ No newline at end of file ++| C763 allocatable | ERROR | ERROR | ERROR | -- Gitee From a1afc72d9e106719d888b4c9d2fe8679d517752a Mon Sep 17 00:00:00 2001 From: LMC Date: Mon, 14 Nov 2022 13:55:50 +0000 Subject: [PATCH 4/4] update 8-add-test-cases-for-types-2.patch. Signed-off-by: LMC --- 8-add-test-cases-for-types-2.patch | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/8-add-test-cases-for-types-2.patch b/8-add-test-cases-for-types-2.patch index f28b3fb..adae806 100644 --- a/8-add-test-cases-for-types-2.patch +++ b/8-add-test-cases-for-types-2.patch @@ -2,7 +2,9 @@ commit 73125352957db63cc9cb32b64969bb45e418e493 Author: MinchaoLiang Date: Mon Nov 14 21:11:07 2022 +0800 - add test cases for types 2 + [flang] 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 @@ -431,11 +433,11 @@ index 0000000..22b0c8a +implicit none +end \ No newline at end of file -diff --git a/test/Semantics/result.md b/test/Semantics/result=08.md +diff --git a/test/Semantics/result-08.md b/test/Semantics/result-08.md new file mode 100644 index 0000000..59fc826 --- /dev/null -+++ b/test/Semantics/result.md ++++ b/test/Semantics/result-08.md @@ -0,0 +1,20 @@ +| Constraint | flang-new | gfortran | ifort | +| :--------------: | :-------: | :------: | :---: | -- Gitee