diff --git a/15-add-test-cases-for-types-2.patch b/15-add-test-cases-for-types-2.patch new file mode 100644 index 0000000000000000000000000000000000000000..b5cfc41b8f1649217e03a5f3a6019c6f77b477ba --- /dev/null +++ b/15-add-test-cases-for-types-2.patch @@ -0,0 +1,478 @@ +commit 116893b8bed7e1f61e5461f2cca34462054021b3 +Author: MinchaoLiang +Date: Wed Dec 7 23:04:03 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..935c633 +--- /dev/null ++++ b/test/Semantics/0741_C752_array.f90 +@@ -0,0 +1,14 @@ ++! RUN: %python %S/test_errors.py %s %flang_fc1 ++! 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..12d32d6 +--- /dev/null ++++ b/test/Semantics/0742_C752_contiguous.f90 +@@ -0,0 +1,13 @@ ++! RUN: %python %S/test_errors.py %s %flang_fc1 ++! Test C752:If the CONTIGUOUS attribute is specified, the component shall be an array with the POINTER attribute. ++ ++module types ++ type :: t ++ ! ERROR: A CONTIGUOUS component must be an array with the POINTER attribute ++ real,contiguous :: S(10) ++ 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..4820722 +--- /dev/null ++++ b/test/Semantics/0743_C753_real.f90 +@@ -0,0 +1,13 @@ ++! RUN: %python %S/test_errors.py %s %flang_fc1 ++! Test C753:The * char-length option is permitted only if the component is of type character. ++ ++module types ++ type :: t ++ ! ERROR: REAL*5 is not a supported type ++ 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..13e4ae4 +--- /dev/null ++++ b/test/Semantics/0744_C753_logical.f90 +@@ -0,0 +1,13 @@ ++! RUN: %python %S/test_errors.py %s %flang_fc1 ++! Test C753:The * char-length option is permitted only if the component is of type character. ++ ++module types ++ type :: t ++ ! ERROR: LOGICAL*5 is not a supported type ++ 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..d71af36 +--- /dev/null ++++ b/test/Semantics/0745_C754_functions.f90 +@@ -0,0 +1,24 @@ ++! RUN: %python %S/test_errors.py %s %flang_fc1 ++! 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: Polymorphic argument requires an explicit interface ++ ! ERROR: Polymorphic argument requires an explicit interface ++ ! 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..fc6dd70 +--- /dev/null ++++ b/test/Semantics/0746_C754_variable.f90 +@@ -0,0 +1,17 @@ ++! RUN: %python %S/test_errors.py %s %flang_fc1 ++! 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..04a84d3 +--- /dev/null ++++ b/test/Semantics/0747_C755_public.f90 +@@ -0,0 +1,21 @@ ++! RUN: %python %S/test_errors.py %s %flang_fc1 ++! 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..8a603aa +--- /dev/null ++++ b/test/Semantics/0748_C755_private.f90 +@@ -0,0 +1,21 @@ ++! RUN: %python %S/test_errors.py %s %flang_fc1 ++! 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..85fe83d +--- /dev/null ++++ b/test/Semantics/0749_C755_nopass.f90 +@@ -0,0 +1,21 @@ ++! RUN: %python %S/test_errors.py %s %flang_fc1 ++! 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..091ab0d +--- /dev/null ++++ b/test/Semantics/0750_C755_pointer.f90 +@@ -0,0 +1,20 @@ ++! RUN: %python %S/test_errors.py %s %flang_fc1 ++! 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..1dd5eab +--- /dev/null ++++ b/test/Semantics/0751_C756.f90 +@@ -0,0 +1,19 @@ ++! RUN: %python %S/test_errors.py %s %flang_fc1 ++! 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),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..3173929 +--- /dev/null ++++ b/test/Semantics/0752_C757.f90 +@@ -0,0 +1,19 @@ ++! RUN: %python %S/test_errors.py %s %flang_fc1 ++! 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..73d7b9d +--- /dev/null ++++ b/test/Semantics/0753_C758.f90 +@@ -0,0 +1,20 @@ ++! RUN: %python %S/test_errors.py %s %flang_fc1 ++! 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..0da43df +--- /dev/null ++++ b/test/Semantics/0754_C759.f90 +@@ -0,0 +1,18 @@ ++! RUN: %python %S/test_errors.py %s %flang_fc1 ++! 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..1f7bee1 +--- /dev/null ++++ b/test/Semantics/0755_C761.f90 +@@ -0,0 +1,19 @@ ++! RUN: %python %S/test_errors.py %s %flang_fc1 ++! 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..1a1c373 +--- /dev/null ++++ b/test/Semantics/0756_C763_pointer.f90 +@@ -0,0 +1,16 @@ ++! RUN: %python %S/test_errors.py %s %flang_fc1 ++! 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_equal.f90 b/test/Semantics/0757_C763_equal.f90 +new file mode 100644 +index 0000000..b3c24ed +--- /dev/null ++++ b/test/Semantics/0757_C763_equal.f90 +@@ -0,0 +1,16 @@ ++! RUN: %python %S/test_errors.py %s %flang_fc1 ++! 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..1702a77 +--- /dev/null ++++ b/test/Semantics/0758_C763_allocatable.f90 +@@ -0,0 +1,16 @@ ++! RUN: %python %S/test_errors.py %s %flang_fc1 ++! 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-15.md b/test/Semantics/result-15.md +new file mode 100644 +index 0000000..6131933 +--- /dev/null ++++ b/test/Semantics/result-15.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 equal | ERROR | ERROR | ERROR | ++| C763 allocatable | ERROR | ERROR | ERROR | diff --git a/flang.spec b/flang.spec index 9e13516ece9e8d9f698835459dedafa30f7bc387..9a684060a4fafff506b861e6537c76a8bb418a70 100644 --- a/flang.spec +++ b/flang.spec @@ -2,7 +2,7 @@ Name: flang Version: flang_20210324 -Release: 15 +Release: 16 Summary: Fortran language compiler targeting LLVM License: Apache-2.0 @@ -25,6 +25,7 @@ Patch10: 11-test-interoperability-with-c-c-call-fortran-array.patch Patch11: 12-test-interoperability-with-c-c-call-fortran-function.patch Patch12: 13-test-interoperability-with-c-c-call-fortran-global-and-struct.patch Patch13: 14-add-test-cases-for-attribute-declarations-and-specifications-2.patch +Patch14: 15-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. @@ -46,6 +47,9 @@ TODO: support build Flang. %changelog +* Wed Dec 7 2022 MinchaoLiang - flang_20210324-16 +- Add patch for add test cases for types 2 + * Tue Nov 29 2022 wangzhewei - flang_20210324-15 - Add patch for add test cases for attribute declarations and specifications 2