Flang silently accepted declarations with both EXTERNAL and TARGET (or INTRINSIC and TARGET) attributes on the same entity. This violates the Fortran standard since TARGET requires a variable, but EXTERNAL/INTRINSIC makes the entity a procedure. Add CheckConflicting calls in CheckProcEntity to diagnose both cases. All other major Fortran compilers already reject these combinations. Fixes #197830 Assisted-by: Claude Opus 4.6. Co-authored-by: Matt P. Dziubinski <matt-p.dziubinski@hpe.com>
17 lines
560 B
Fortran
17 lines
560 B
Fortran
! RUN: %python %S/test_errors.py %s %flang_fc1
|
|
! Check that EXTERNAL/INTRINSIC and TARGET attributes conflict
|
|
|
|
subroutine test1()
|
|
!ERROR: 'f1' may not have both the EXTERNAL and TARGET attributes
|
|
real, target, external :: f1
|
|
!ERROR: 'f2' may not have both the EXTERNAL and TARGET attributes
|
|
real, external, target :: f2
|
|
! These are fine individually
|
|
real, external :: f3
|
|
real, target :: x1
|
|
end subroutine
|
|
|
|
subroutine test2()
|
|
!ERROR: 'abs' may not have both the INTRINSIC and TARGET attributes
|
|
integer, target, intrinsic :: abs
|
|
end subroutine
|