mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-16 21:56:34 +00:00

When character lengths are known at compilation time, report an error when a data target with a known length does not match the explicit length of a pointer that is being associated with it; see 10.2.2.3 paragraph 5. Differential Revision: https://reviews.llvm.org/D142755
17 lines
673 B
Fortran
17 lines
673 B
Fortran
! RUN: %python %S/test_errors.py %s %flang_fc1
|
|
program main
|
|
type t
|
|
character(4), pointer :: p
|
|
end type
|
|
character(5), target :: buff = "abcde"
|
|
type(t) x
|
|
!ERROR: Target type CHARACTER(KIND=1,LEN=5_8) is not compatible with pointer type CHARACTER(KIND=1,LEN=4_8)
|
|
x = t(buff)
|
|
!ERROR: Target type CHARACTER(KIND=1,LEN=3_8) is not compatible with pointer type CHARACTER(KIND=1,LEN=4_8)
|
|
x = t(buff(3:))
|
|
!ERROR: Target type CHARACTER(KIND=1,LEN=5_8) is not compatible with pointer type CHARACTER(KIND=1,LEN=4_8)
|
|
x%p => buff
|
|
!ERROR: Target type CHARACTER(KIND=1,LEN=3_8) is not compatible with pointer type CHARACTER(KIND=1,LEN=4_8)
|
|
x%p => buff(1:3)
|
|
end
|