From 0aeea61509ed90e6e006b41b16aaab3cb785b45e Mon Sep 17 00:00:00 2001 From: MinchaoLiang Date: Tue, 15 Nov 2022 11:24:05 +0800 Subject: [PATCH 1/2] 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..1cd534f --- /dev/null +++ b/8-add-test-cases-for-types-2.patch @@ -0,0 +1,459 @@ +commit 7d09541e387b6417ae98e708f5669f2db62bf09c +Author: MinchaoLiang +Date: Tue Nov 15 11:19:00 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..7feacfd +--- /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..c52bde1 +--- /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..3380620 +--- /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..bb1893c +--- /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..6f44984 +--- /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..8168efe +--- /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..3b9b430 +--- /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..7c60d01 +--- /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..946a306 +--- /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..b71a357 +--- /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..c72f975 +--- /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..044a541 +--- /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..0117936 +--- /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..f203408 +--- /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..dd1348d +--- /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..f353991 +--- /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..5c638d6 +--- /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..be12595 +--- /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-08.md b/test/Semantics/result-08.md +new file mode 100644 +index 0000000..6131933 +--- /dev/null ++++ b/test/Semantics/result-08.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..bbad2fb 100644 --- a/flang.spec +++ b/flang.spec @@ -2,7 +2,7 @@ Name: flang Version: flang_20210324 -Release: 12 +Release: 13 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 +* Tue Nov 15 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 6c56fde5aa3e10d5929609a1dd8b259786fdf060 Mon Sep 17 00:00:00 2001 From: LMC Date: Tue, 15 Nov 2022 03:43:55 +0000 Subject: [PATCH 2/2] 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 1cd534f..9d5a088 100644 --- a/8-add-test-cases-for-types-2.patch +++ b/8-add-test-cases-for-types-2.patch @@ -1,5 +1,5 @@ commit 7d09541e387b6417ae98e708f5669f2db62bf09c -Author: MinchaoLiang +Author: MinchaoLiang Date: Tue Nov 15 11:19:00 2022 +0800 add test cases for types 2 -- Gitee