llvm/flang/test/semantics/resolve35.f90
Tim Keith d396a8845b [flang] Resolve kind parameters on literal constants
When the kind parameter is a constant name, that name must be resolved.

Add `CheckIntrinsicKind` and `CheckIntrinsicSize` for common checking of
valid intrinsic kinds. Previous we had different forms of the error
message depending on the context ( "unsupported INTEGER(KIND=47)" and
"INTEGER(KIND=47) is not a supported type").

Report error for parameters without initialization where are they
declared (in `Post(EntityDecl)`) rather than where they are referenced
(in `AnalyzeExpr`).

Remove error message from `AnalyzeKindParam`: `AnalyzeExpr` will report
the error (e.g. not integer, not constant, etc.).

Remove "name was not resolved" error from `AnalyzeExpr`: it should be
reported by name resolution.

Original-commit: flang-compiler/f18@9b0a99ce66
Reviewed-on: https://github.com/flang-compiler/f18/pull/281
Tree-same-pre-rewrite: false
2019-02-08 16:03:23 -08:00

121 lines
2.8 KiB
Fortran

! Copyright (c) 2018-2019, NVIDIA CORPORATION. All rights reserved.
!
! Licensed under the Apache License, Version 2.0 (the "License");
! you may not use this file except in compliance with the License.
! You may obtain a copy of the License at
!
! http://www.apache.org/licenses/LICENSE-2.0
!
! Unless required by applicable law or agreed to in writing, software
! distributed under the License is distributed on an "AS IS" BASIS,
! WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
! See the License for the specific language governing permissions and
! limitations under the License.
! Construct names
subroutine s1
real :: foo
!ERROR: 'foo' is already declared in this scoping unit
foo: block
end block foo
end
subroutine s2(x)
logical :: x
foo: if (x) then
end if foo
!ERROR: 'foo' is already declared in this scoping unit
foo: do i = 1, 10
end do foo
end
subroutine s3
real :: a(10,10), b(10,10)
type y; end type
integer(8) :: x
!ERROR: Index name 'y' conflicts with existing identifier
forall(x=1:10, y=1:10)
a(x, y) = b(x, y)
end forall
!ERROR: Index name 'y' conflicts with existing identifier
forall(x=1:10, y=1:10) a(x, y) = b(x, y)
end
subroutine s4
real :: a(10), b(10)
complex :: x
integer :: i(2)
!ERROR: Variable 'x' is not integer
forall(x=1:10)
a(x) = b(x)
end forall
!ERROR: Variable 'y' is not integer
forall(y=1:10)
a(y) = b(y)
end forall
!ERROR: Index variable 'i' is not scalar
forall(i=1:10)
a(i) = b(i)
end forall
end
subroutine s5
real :: a(10), b(10)
!ERROR: 'i' is already declared in this scoping unit
forall(i=1:10, i=1:10)
a(i) = b(i)
end forall
end
subroutine s6
integer, parameter :: n = 4
real, dimension(n) :: x
data(x(i), i=1, n) / n * 0.0 /
!ERROR: Index name 't' conflicts with existing identifier
forall(t=1:n) x(t) = 0.0
contains
subroutine t
end
end
subroutine s7
!ERROR: 'i' is already declared in this scoping unit
do concurrent(integer::i=1:5) local(j, i) &
!ERROR: 'j' is already declared in this scoping unit
local_init(k, j) &
!ERROR: Variable 'a' not found
shared(a)
a(i) = j + 1
end do
end
subroutine s8
implicit none
!ERROR: No explicit type declared for 'i'
do concurrent(i=1:5) &
!ERROR: No explicit type declared for 'j'
local(j) &
!ERROR: No explicit type declared for 'k'
local_init(k)
end do
end
subroutine s9
external bad1
real, parameter :: bad2 = 1.0
x = cos(0.)
do concurrent(i=1:2) &
!ERROR: Locality attribute not allowed on 'bad1'
local(bad1) &
!ERROR: Locality attribute not allowed on 'bad2'
local(bad2) &
!ERROR: Locality attribute not allowed on 'bad3'
local(bad3) &
!ERROR: Locality attribute not allowed on 'cos'
local(cos)
end do
contains
subroutine bad3
end
end