diff --git a/18-add-test-cases-for-attribute-declarations-and-specifications-3.patch b/18-add-test-cases-for-attribute-declarations-and-specifications-3.patch new file mode 100644 index 0000000000000000000000000000000000000000..9b141a1bf2a927c09fc8839ed4248076221d36c6 --- /dev/null +++ b/18-add-test-cases-for-attribute-declarations-and-specifications-3.patch @@ -0,0 +1,349 @@ +commit 694dda91063d30ded6d09bf3d51074c5f9c482f3 +Author: wzw +Date: Mon Jan 23 13:50:24 2023 +0800 + + [flang] Add test cases for attribute declarations and specifications 3 + Add test cases for attribute declarations and specifications 3 + +diff --git a/test/Semantics/0856_C863.f90 b/test/Semantics/0856_C863.f90 +new file mode 100644 +index 0000000..3c6b318 +--- /dev/null ++++ b/test/Semantics/0856_C863.f90 +@@ -0,0 +1,10 @@ ++! RUN: %python %S/test_errors.py %s %flang_fc1 ++! Test C863: An entity with the VALUE attribute shall be a dummy data object. ++! It shall not be an assumed-size array, a coarray, or a variable with a coarray ++! ultimate component. ++ ++subroutine test(x) ++ integer, value :: x ++ ! ERROR: VALUE attribute may apply only to a dummy argument ++ integer, value :: y ++end subroutine test +diff --git a/test/Semantics/0857_C864.f90 b/test/Semantics/0857_C864.f90 +new file mode 100644 +index 0000000..e65cb01 +--- /dev/null ++++ b/test/Semantics/0857_C864.f90 +@@ -0,0 +1,16 @@ ++! RUN: %python %S/test_errors.py %s %flang_fc1 ++! Test C864: An entity with the VALUE attribute shall not have the ALLOCATABLE, ++! INTENT (INOUT), INTENT (OUT), POINTER, or VOLATILE attributes. ++ ++subroutine test(a, b, c, d, e) ++ ! ERROR: VALUE attribute may not apply to an ALLOCATABLE ++ integer, value, allocatable :: a ++ ! ERROR: VALUE attribute may not apply to an INTENT(IN OUT) argument ++ integer, value, intent(inout) :: b ++ ! ERROR: VALUE attribute may not apply to an INTENT(OUT) argument ++ integer, value, intent(out) :: c ++ ! ERROR: VALUE attribute may not apply to a POINTER ++ integer, value, pointer :: d ++ ! ERROR: VALUE attribute may not apply to a VOLATILE ++ integer, value, volatile :: e ++end subroutine test +diff --git a/test/Semantics/0858_C865.f90 b/test/Semantics/0858_C865.f90 +new file mode 100644 +index 0000000..317d44a +--- /dev/null ++++ b/test/Semantics/0858_C865.f90 +@@ -0,0 +1,19 @@ ++! RUN: %python %S/test_errors.py %s %flang_fc1 ++! Test C865: A dummy argument of a procedure with the BIND attribute shall not ++! have both the OPTIONAL and VALUE attributes. ++ ++program main ++ use , intrinsic :: iso_c_binding, only : c_char, c_int, c_null_char ++ interface ++ integer function test(a, b) bind(C, name="test") ++ import :: c_char, c_int ++ implicit none ++ ! ERROR: Function cannot have both an explicit type prefix and a RESULT suffix ++ integer :: test = 1 ++ ! ERROR: VALUE attribute may not apply to an assumed-size array ++ ! ERROR: VALUE attribute may not apply to an array in a BIND(C) procedure ++ character(kind=c_char,len=1), value :: a(*) ++ character(kind=c_char,len=1), optional :: b(*) ++ end function test ++ end interface ++end program main +diff --git a/test/Semantics/0859_C866.f90 b/test/Semantics/0859_C866.f90 +new file mode 100644 +index 0000000..b9832fe +--- /dev/null ++++ b/test/Semantics/0859_C866.f90 +@@ -0,0 +1,8 @@ ++! RUN: %python %S/test_errors.py %s %flang_fc1 ++! Test C866: An entity with the VOLATILE attribute shall be a variable ++! that is not an INTENT (IN) dummy argument. ++ ++subroutine test(a) ++ ! ERROR: VOLATILE attribute may not apply to an INTENT(IN) argument ++ integer, volatile, intent(in) :: a ++end subroutine test +diff --git a/test/Semantics/0860_C867.f90 b/test/Semantics/0860_C867.f90 +new file mode 100644 +index 0000000..8da6de4 +--- /dev/null ++++ b/test/Semantics/0860_C867.f90 +@@ -0,0 +1,14 @@ ++! RUN: %python %S/test_errors.py %s %flang_fc1 ++! Test C867: The VOLATILE attribute shall not be specified for a coarray, or a ++! variable with a coarray ultimate component, that is accessed by use (14.2.2) ++! or host (19.5.1.4) association. ++ ++module m ++ ! ERROR: VOLATILE attribute may not apply to a coarray accessed by USE or host association ++ character(len = 20) :: a[*] ++end module m ++ ++program main ++ use m ++ volatile :: a ++end program main +diff --git a/test/Semantics/0861_C869.f90 b/test/Semantics/0861_C869.f90 +new file mode 100644 +index 0000000..651703b +--- /dev/null ++++ b/test/Semantics/0861_C869.f90 +@@ -0,0 +1,15 @@ ++! RUN: %python %S/test_errors.py %s %flang_fc1 ++! Test C869: (R827) An access-stmt shall appear only in the specification-part ++! of a module. Only one accessibility statement with an omitted access-id-list ++! is permitted in the specification-part of a module. ++ ++module m ++ private :: a ++end module m ++ ++ ++program main ++ use m ++ ! ERROR: PRIVATE statement may only appear in the specification part of a module ++ private :: x ++end program main +diff --git a/test/Semantics/0862_C872.f90 b/test/Semantics/0862_C872.f90 +new file mode 100644 +index 0000000..51fbb19 +--- /dev/null ++++ b/test/Semantics/0862_C872.f90 +@@ -0,0 +1,14 @@ ++! RUN: %python %S/test_errors.py %s %flang_fc1 ++! Test C872: The name of a module shall appear at most once in all of the ++! access-stmts in a module. ++ ++module m1 ++ integer :: x ++end module m1 ++ ++module m2 ++ use m1 ++ private :: m1 ++ ! ERROR: The accessibility of 'm1' has already been specified as PRIVATE ++ public :: m1 ++end module m2 +diff --git a/test/Semantics/0863_C873.f90 b/test/Semantics/0863_C873.f90 +new file mode 100644 +index 0000000..55e162b +--- /dev/null ++++ b/test/Semantics/0863_C873.f90 +@@ -0,0 +1,12 @@ ++! RUN: %python %S/test_errors.py %s %flang_fc1 ++! Test C873: (R832) If the language-binding-spec has a NAME= specifier, the ++! bind-entity-list shall consist of a single bind-entity. ++ ++module test_type ++ type, bind(c) :: a ++ integer(4) :: j = -1 ++ end type a ++ ! ERROR: Two entities have the same BIND(C) name 'test' ++ type(a), bind(c, name="test") :: x, y ++end module test_type ++ +diff --git a/test/Semantics/0864_C874.f90 b/test/Semantics/0864_C874.f90 +new file mode 100644 +index 0000000..18e5498 +--- /dev/null ++++ b/test/Semantics/0864_C874.f90 +@@ -0,0 +1,8 @@ ++! RUN: %python %S/test_errors.py %s %flang_fc1 ++! Test C874: A data-stmt-object or data-i-do-object shall not be a coindexed variable. ++ ++subroutine test() ++ character(len=10), save :: a[*] ++ ! ERROR: Data object must not be a coindexed variable ++ data a[1] / 'aaaaa' / ++end subroutine test +diff --git a/test/Semantics/0865_C875.f90 b/test/Semantics/0865_C875.f90 +new file mode 100644 +index 0000000..f983ebb +--- /dev/null ++++ b/test/Semantics/0865_C875.f90 +@@ -0,0 +1,11 @@ ++! RUN: %python %S/test_errors.py %s %flang_fc1 ++! Test C875: (R839) A data-stmt-object that is a variable shall be a ++! designator. Each subscript, section subscript, substring starting point, and ++! substring ending point in the variable shall be a constant expression. ++ ++program main ++ integer, dimension(0:9) :: a ++ integer :: x = 5 ++ ! ERROR: Data object must have constant subscripts ++ data a(0:x) / 5 * 0 / ++end program main +diff --git a/test/Semantics/0866_C882.f90 b/test/Semantics/0866_C882.f90 +new file mode 100644 +index 0000000..344e28e +--- /dev/null ++++ b/test/Semantics/0866_C882.f90 +@@ -0,0 +1,9 @@ ++! RUN: %python %S/test_errors.py %s %flang_fc1 ++! Test C882: (R844) The data-stmt-repeat shall be positive or zero. If the ++! data-stmt-repeat is a named constant, it shall have been defined previously. ++ ++! ERROR: Could not parse 0870_C882.f90 ++program main ++ integer, dimension(5) :: a ++ data a / -5 * 3 / ++end program main +diff --git a/test/Semantics/0867_C883.f90 b/test/Semantics/0867_C883.f90 +new file mode 100644 +index 0000000..0d20ede +--- /dev/null ++++ b/test/Semantics/0867_C883.f90 +@@ -0,0 +1,12 @@ ++! RUN: %python %S/test_errors.py %s %flang_fc1 ++! Test C883: (R845) If a DATA statement constant value is a named constant or a ++! structure constructor, the named constant or derived type shall have been ++! defined previously. ++ ++program main ++ integer, dimension(3) :: x, y ++ integer, parameter :: a = 10 ++ data x / 3 * a / ++ ! ERROR: DATA statement value 'int(b,kind=4)' for 'y(1_8)' is not a constant ++ data y / 3 * b / ++end program main +diff --git a/test/Semantics/0868_C884.f90 b/test/Semantics/0868_C884.f90 +new file mode 100644 +index 0000000..9a4a5a5 +--- /dev/null ++++ b/test/Semantics/0868_C884.f90 +@@ -0,0 +1,17 @@ ++! RUN: %python %S/test_errors.py %s %flang_fc1 ++! Test C884: (R845) If a data-stmt-constant is a structure-constructor, it ++! shall be a constant expression. ++ ++program main ++ type t ++ integer :: a, b ++ end type t ++ ++ type(t) :: x, y ++ integer, parameter :: m = 10 ++ integer :: n = 20 ++ ++ ! ERROR: DATA statement value 't(a=n,b=n)' for 'x' is not a constant ++ data x / t(a=n, b=n) / ++ data y / t(a=m, b=m) / ++end program main +diff --git a/test/Semantics/0869_C885.f90 b/test/Semantics/0869_C885.f90 +new file mode 100644 +index 0000000..ff6e5e7 +--- /dev/null ++++ b/test/Semantics/0869_C885.f90 +@@ -0,0 +1,17 @@ ++! RUN: %python %S/test_errors.py %s %flang_fc1 ++! Test C885: (R846) int-constant-subobject shall be of type integer. ++ ++program main ++ type t ++ integer :: a ++ character :: b ++ end type t ++ ++ type(t), parameter :: m = t(a=5, b='a') ++ integer, dimension(5) :: x, y ++ ++ data x / m % a * 5 / ++ ! ERROR: Must have INTEGER type, but is CHARACTER(KIND=1,LEN=1_8) ++ data y / m % b * 5 / ++ ++end program main +diff --git a/test/Semantics/0870_C886.f90 b/test/Semantics/0870_C886.f90 +new file mode 100644 +index 0000000..2508543 +--- /dev/null ++++ b/test/Semantics/0870_C886.f90 +@@ -0,0 +1,17 @@ ++! RUN: %python %S/test_errors.py %s %flang_fc1 ++! Test C886: (R847) constant-subobject shall be a subobject of a constant. ++ ++program main ++ type t ++ integer :: a ++ end type t ++ ++ type(t) :: m = t(a=5) ++ type(t), parameter :: n = t(a = 5) ++ integer, dimension(5) :: x, y ++ ++ ! ERROR: DATA statement value 'm%a' for 'x(1_8)' is not a constant ++ data x / 5 * m % a / ++ data y / 5 * n % a / ++ ++end program main +diff --git a/test/Semantics/0871_C887.f90 b/test/Semantics/0871_C887.f90 +new file mode 100644 +index 0000000..6011dea +--- /dev/null ++++ b/test/Semantics/0871_C887.f90 +@@ -0,0 +1,16 @@ ++! RUN: %python %S/test_errors.py %s %flang_fc1 ++! Test C887: (R847) Any subscript, substring starting point, or substring ending ++! point shall be a constant expression. ++ ++program main ++ character(len=10), parameter :: a = 'abcdefghik' ++ character(len=5) :: b, c, d ++ integer :: x1 = 3, y1 = 7 ++ integer, parameter :: x2 = 3, y2 = 7 ++ ++ ! ERROR: DATA statement value '%SET_LENGTH(a(int(x1,kind=8):int(y1,kind=8)),5_8)' for 'b' is not a constant ++ data b / a(x1 : y1) / ++ data c / a(x2 : y2) / ++ data d / a(3 : 7) / ++ ++end program main +diff --git a/test/Semantics/result-08.md b/test/Semantics/result-08.md +index 33c5faf..7313234 100644 +--- a/test/Semantics/result-08.md ++++ b/test/Semantics/result-08.md +@@ -49,9 +49,25 @@ + | C852 | ERROR | ERROR | ERROR | + | C854 | ERROR | ERROR | ERROR | + | C855 | --- | --- | --- | +-| C856 | OK | ERROR | ERROR | ++| C856 | ERROR | ERROR | ERROR | + | C857 | ERROR (OK in some cases) | ERROR | ERROR | + | C858 | OK | ERROR | OK | + | C860 | ERROR | ERROR | ERROR | + | C861 | ERROR | ERROR | ERROR | + | C862 | ERROR | ERROR | ERROR | ++| C863 | ERROR | ERROR | ERROR | ++| C864 | ERROR | ERROR | ERROR | ++| C865 | ERROR | ERROR | ERROR | ++| C866 | ERROR | ERROR | ERROR | ++| C867 | ERROR | OK | ERROR | ++| C869 | ERROR | ERROR | ERROR | ++| C872 | ERROR | ERROR | ERROR | ++| C873 | ERROR | ERROR | ERROR | ++| C874 | ERROR | ERROR | ERROR | ++| C875 | ERROR | ERROR | ERROR | ++| C882 | ERROR | ERROR | ERROR | ++| C883 | ERROR | ERROR | ERROR | ++| C884 | ERROR | ERROR | ERROR | ++| C885 | ERROR | ERROR | ERROR | ++| C886 | ERROR | ERROR | ERROR | ++| C887 | ERROR | ERROR | ERROR | diff --git a/flang.spec b/flang.spec index 9ceda8d09b42cfb0a054244bfd311087973cb1da..d838b8b6454d3ee1cbca58d2313d2004c8465d85 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-attribute-declarations-and-specifications-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 +* Mon Jan 23 2023 wangzhewei - flang_20210324-21 +- Add patch for add test cases for attribute declarations and specifications 3 + * Mon Jan 16 2023 wangzhewei - flang_20210324-20 - Fix patch 7 and patch 14