Peter Klausler 50960e9383 [flang] Catch character length errors in pointer associations
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
2023-02-01 12:12:43 -08:00

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