2020-02-26 07:22:14 +08:00
|
|
|
! RUN: %B/test/Semantics/test_errors.sh %s %flang %t
|
2019-04-19 00:17:31 +08:00
|
|
|
! Check for semantic errors in ALLOCATE statements
|
|
|
|
|
2019-06-11 04:30:29 +08:00
|
|
|
! Creating a symbol that allocate should accept
|
|
|
|
module share
|
|
|
|
real, pointer :: rp
|
|
|
|
end module share
|
|
|
|
|
2019-05-22 23:00:19 +08:00
|
|
|
module m
|
|
|
|
! Creating symbols that allocate should not accept
|
|
|
|
type :: a_type
|
|
|
|
real, allocatable :: x
|
|
|
|
contains
|
|
|
|
procedure, pass :: foo => mfoo
|
|
|
|
procedure, pass :: bar => mbar
|
|
|
|
end type
|
|
|
|
|
|
|
|
contains
|
|
|
|
function mfoo(x)
|
2020-02-12 04:14:04 +08:00
|
|
|
class(a_type) :: x
|
|
|
|
class(a_type), allocatable :: foo
|
2019-05-22 23:00:19 +08:00
|
|
|
foo = x
|
|
|
|
end function
|
|
|
|
subroutine mbar(x)
|
2019-06-24 01:59:32 +08:00
|
|
|
class(a_type) :: x
|
2019-05-22 23:00:19 +08:00
|
|
|
end subroutine
|
|
|
|
end module
|
|
|
|
|
2019-04-19 00:17:31 +08:00
|
|
|
subroutine C932(ed1, ed5, ed7, edc9, edc10, okad1, okpd1, okacd5)
|
|
|
|
! Each allocate-object shall be a data pointer or an allocatable variable.
|
2019-06-11 04:30:29 +08:00
|
|
|
use :: share
|
2019-05-22 23:00:19 +08:00
|
|
|
use :: m, only: a_type
|
2019-04-19 00:17:31 +08:00
|
|
|
type TestType1
|
|
|
|
integer, allocatable :: ok(:)
|
2019-08-07 05:14:33 +08:00
|
|
|
integer :: nok(10)
|
2019-04-19 00:17:31 +08:00
|
|
|
end type
|
|
|
|
type TestType2
|
|
|
|
integer, pointer :: ok
|
|
|
|
integer :: nok
|
|
|
|
end type
|
2019-05-22 23:00:19 +08:00
|
|
|
interface
|
|
|
|
function foo(x)
|
|
|
|
real(4) :: foo, x
|
|
|
|
end function
|
|
|
|
subroutine bar()
|
|
|
|
end subroutine
|
|
|
|
end interface
|
2019-04-19 00:17:31 +08:00
|
|
|
real ed1(:), e2
|
|
|
|
real, save :: e3[*]
|
|
|
|
real , target :: e4, ed5(:)
|
|
|
|
real , parameter :: e6 = 5.
|
2019-05-22 23:00:19 +08:00
|
|
|
procedure(foo), pointer :: proc_ptr1 => NULL()
|
|
|
|
procedure(bar), pointer :: proc_ptr2
|
2019-04-19 00:17:31 +08:00
|
|
|
type(TestType1) ed7
|
|
|
|
type(TestType2) e8
|
|
|
|
type(TestType1) edc9[*]
|
|
|
|
type(TestType2) edc10[*]
|
2019-05-22 23:00:19 +08:00
|
|
|
class(a_type), allocatable :: a_var
|
2019-04-19 00:17:31 +08:00
|
|
|
|
|
|
|
real, allocatable :: oka1(:, :), okad1(:, :), oka2
|
|
|
|
real, pointer :: okp1(:, :), okpd1(:, :), okp2
|
|
|
|
real, pointer, save :: okp3
|
|
|
|
real, allocatable, save :: oka3, okac4[:,:]
|
|
|
|
real, allocatable :: okacd5(:, :)[:]
|
|
|
|
|
2019-05-22 23:00:19 +08:00
|
|
|
!ERROR: Name in ALLOCATE statement must be a variable name
|
|
|
|
allocate(foo)
|
|
|
|
!ERROR: Name in ALLOCATE statement must be a variable name
|
|
|
|
allocate(bar)
|
|
|
|
!ERROR: Name in ALLOCATE statement must be a variable name
|
|
|
|
allocate(C932)
|
|
|
|
!ERROR: Name in ALLOCATE statement must be a variable name
|
|
|
|
allocate(proc_ptr1)
|
|
|
|
!ERROR: Name in ALLOCATE statement must be a variable name
|
|
|
|
allocate(proc_ptr2)
|
|
|
|
!ERROR: Name in ALLOCATE statement must be a variable name
|
|
|
|
allocate(a_var%foo)
|
|
|
|
!ERROR: Name in ALLOCATE statement must be a variable name
|
|
|
|
allocate(a_var%bar)
|
|
|
|
|
[flang] Allocate semantic checks (second part)
Implement semantic checks and realted tests for constraints:
C937, C938, C939, C940, C941, C942, C945 (second part),
C946, C947, C948, C949 and C950.
Original-commit: flang-compiler/f18@b4965d272b1749d554e3d1388c0a7856591741e8
Tree-same-pre-rewrite: false
2019-04-26 16:10:04 +08:00
|
|
|
!ERROR: Entity in ALLOCATE statement must have the ALLOCATABLE or POINTER attribute
|
2019-04-19 00:17:31 +08:00
|
|
|
allocate(ed1)
|
[flang] Allocate semantic checks (second part)
Implement semantic checks and realted tests for constraints:
C937, C938, C939, C940, C941, C942, C945 (second part),
C946, C947, C948, C949 and C950.
Original-commit: flang-compiler/f18@b4965d272b1749d554e3d1388c0a7856591741e8
Tree-same-pre-rewrite: false
2019-04-26 16:10:04 +08:00
|
|
|
!ERROR: Entity in ALLOCATE statement must have the ALLOCATABLE or POINTER attribute
|
2019-04-19 00:17:31 +08:00
|
|
|
allocate(e2)
|
[flang] Allocate semantic checks (second part)
Implement semantic checks and realted tests for constraints:
C937, C938, C939, C940, C941, C942, C945 (second part),
C946, C947, C948, C949 and C950.
Original-commit: flang-compiler/f18@b4965d272b1749d554e3d1388c0a7856591741e8
Tree-same-pre-rewrite: false
2019-04-26 16:10:04 +08:00
|
|
|
!ERROR: Entity in ALLOCATE statement must have the ALLOCATABLE or POINTER attribute
|
2019-04-19 00:17:31 +08:00
|
|
|
allocate(e3)
|
[flang] Allocate semantic checks (second part)
Implement semantic checks and realted tests for constraints:
C937, C938, C939, C940, C941, C942, C945 (second part),
C946, C947, C948, C949 and C950.
Original-commit: flang-compiler/f18@b4965d272b1749d554e3d1388c0a7856591741e8
Tree-same-pre-rewrite: false
2019-04-26 16:10:04 +08:00
|
|
|
!ERROR: Entity in ALLOCATE statement must have the ALLOCATABLE or POINTER attribute
|
2019-04-19 00:17:31 +08:00
|
|
|
allocate(e4)
|
[flang] Allocate semantic checks (second part)
Implement semantic checks and realted tests for constraints:
C937, C938, C939, C940, C941, C942, C945 (second part),
C946, C947, C948, C949 and C950.
Original-commit: flang-compiler/f18@b4965d272b1749d554e3d1388c0a7856591741e8
Tree-same-pre-rewrite: false
2019-04-26 16:10:04 +08:00
|
|
|
!ERROR: Entity in ALLOCATE statement must have the ALLOCATABLE or POINTER attribute
|
2019-04-19 00:17:31 +08:00
|
|
|
allocate(ed5)
|
[flang] Allocate semantic checks (second part)
Implement semantic checks and realted tests for constraints:
C937, C938, C939, C940, C941, C942, C945 (second part),
C946, C947, C948, C949 and C950.
Original-commit: flang-compiler/f18@b4965d272b1749d554e3d1388c0a7856591741e8
Tree-same-pre-rewrite: false
2019-04-26 16:10:04 +08:00
|
|
|
!ERROR: Name in ALLOCATE statement must be a variable name
|
2019-04-19 00:17:31 +08:00
|
|
|
allocate(e6)
|
[flang] Allocate semantic checks (second part)
Implement semantic checks and realted tests for constraints:
C937, C938, C939, C940, C941, C942, C945 (second part),
C946, C947, C948, C949 and C950.
Original-commit: flang-compiler/f18@b4965d272b1749d554e3d1388c0a7856591741e8
Tree-same-pre-rewrite: false
2019-04-26 16:10:04 +08:00
|
|
|
!ERROR: Entity in ALLOCATE statement must have the ALLOCATABLE or POINTER attribute
|
2019-04-19 00:17:31 +08:00
|
|
|
allocate(ed7)
|
[flang] Allocate semantic checks (second part)
Implement semantic checks and realted tests for constraints:
C937, C938, C939, C940, C941, C942, C945 (second part),
C946, C947, C948, C949 and C950.
Original-commit: flang-compiler/f18@b4965d272b1749d554e3d1388c0a7856591741e8
Tree-same-pre-rewrite: false
2019-04-26 16:10:04 +08:00
|
|
|
!ERROR: Entity in ALLOCATE statement must have the ALLOCATABLE or POINTER attribute
|
2019-04-19 00:17:31 +08:00
|
|
|
allocate(ed7%nok(2))
|
[flang] Allocate semantic checks (second part)
Implement semantic checks and realted tests for constraints:
C937, C938, C939, C940, C941, C942, C945 (second part),
C946, C947, C948, C949 and C950.
Original-commit: flang-compiler/f18@b4965d272b1749d554e3d1388c0a7856591741e8
Tree-same-pre-rewrite: false
2019-04-26 16:10:04 +08:00
|
|
|
!ERROR: Entity in ALLOCATE statement must have the ALLOCATABLE or POINTER attribute
|
2019-04-19 00:17:31 +08:00
|
|
|
allocate(ed8)
|
[flang] Allocate semantic checks (second part)
Implement semantic checks and realted tests for constraints:
C937, C938, C939, C940, C941, C942, C945 (second part),
C946, C947, C948, C949 and C950.
Original-commit: flang-compiler/f18@b4965d272b1749d554e3d1388c0a7856591741e8
Tree-same-pre-rewrite: false
2019-04-26 16:10:04 +08:00
|
|
|
!ERROR: Entity in ALLOCATE statement must have the ALLOCATABLE or POINTER attribute
|
2019-04-19 00:17:31 +08:00
|
|
|
allocate(ed8)
|
[flang] Allocate semantic checks (second part)
Implement semantic checks and realted tests for constraints:
C937, C938, C939, C940, C941, C942, C945 (second part),
C946, C947, C948, C949 and C950.
Original-commit: flang-compiler/f18@b4965d272b1749d554e3d1388c0a7856591741e8
Tree-same-pre-rewrite: false
2019-04-26 16:10:04 +08:00
|
|
|
!ERROR: Entity in ALLOCATE statement must have the ALLOCATABLE or POINTER attribute
|
2019-04-19 00:17:31 +08:00
|
|
|
allocate(edc9%nok)
|
[flang] Allocate semantic checks (second part)
Implement semantic checks and realted tests for constraints:
C937, C938, C939, C940, C941, C942, C945 (second part),
C946, C947, C948, C949 and C950.
Original-commit: flang-compiler/f18@b4965d272b1749d554e3d1388c0a7856591741e8
Tree-same-pre-rewrite: false
2019-04-26 16:10:04 +08:00
|
|
|
!ERROR: Entity in ALLOCATE statement must have the ALLOCATABLE or POINTER attribute
|
2019-04-19 00:17:31 +08:00
|
|
|
allocate(edc10)
|
|
|
|
|
|
|
|
! No errors expected below:
|
2019-05-22 23:00:19 +08:00
|
|
|
allocate(a_var)
|
|
|
|
allocate(a_var%x)
|
2019-04-19 00:17:31 +08:00
|
|
|
allocate(oka1(5, 7), okad1(4, 8), oka2)
|
|
|
|
allocate(okp1(5, 7), okpd1(4, 8), okp2)
|
|
|
|
allocate(okp1(5, 7), okpd1(4, 8), okp2)
|
|
|
|
allocate(okp3, oka3)
|
|
|
|
allocate(okac4[2:4,4:*])
|
|
|
|
allocate(okacd5(1:2,3:4)[5:*])
|
[flang] Allocate semantic checks (second part)
Implement semantic checks and realted tests for constraints:
C937, C938, C939, C940, C941, C942, C945 (second part),
C946, C947, C948, C949 and C950.
Original-commit: flang-compiler/f18@b4965d272b1749d554e3d1388c0a7856591741e8
Tree-same-pre-rewrite: false
2019-04-26 16:10:04 +08:00
|
|
|
allocate(ed7%ok(7))
|
|
|
|
allocate(e8%ok)
|
|
|
|
allocate(edc9%ok(4))
|
|
|
|
allocate(edc10%ok)
|
2019-06-11 04:30:29 +08:00
|
|
|
allocate(rp)
|
2019-04-19 00:17:31 +08:00
|
|
|
end subroutine
|