Files
clang-p2996/flang/test/Semantics/symbol19.f90
peter klausler 452d7ebc09 [flang] Ensure that intrinsic procedures are PURE &/or ELEMENTAL
The intrinsic procedure table properly classify the various
intrinsics, but the PURE and ELEMENTAL attributes that these
classifications imply don't always make it to the utility
predicates that test symbols for them, leading to spurious
error messages in some contexts.  So set those attribute flags
as appropriate in name resolution, using a new function to
isolate the tests.

An alternate solution, in which the predicates would query
the intrinsic procedure table for these attributes on demand,
was something I also tried, so that this information could
come directly from an authoritative source; but it would have
required references to the intrinsic table to be passed along
on too many seemingly unrelated APIs and ended up looking messy.

Several symbol table tests needed to have their expected outputs
augmented with the PURE and ELEMENTAL flags.  Some bogus messages
that were flagged as such in test/Semantics/doconcurrent01.f90 were
removed, since they are now correctly not emitted.

Differential Revision: https://reviews.llvm.org/D96878
2021-02-17 11:31:33 -08:00

53 lines
1.9 KiB
Fortran

! RUN: %S/test_symbols.sh %s %t %f18
! Test that a procedure is only implicitly resolved as an intrinsic function
! (resp. subroutine) if this is a function (resp. subroutine)
!DEF: /expect_external (Subroutine) Subprogram
subroutine expect_external
!DEF: /acos EXTERNAL (Subroutine) ProcEntity
!DEF: /expect_external/x (Implicit) ObjectEntity REAL(4)
call acos(x)
!DEF: /expect_external/i (Implicit) ObjectEntity INTEGER(4)
!DEF: /system_clock EXTERNAL (Function, Implicit) ProcEntity REAL(4)
!DEF: /expect_external/icount (Implicit) ObjectEntity INTEGER(4)
i = system_clock(icount)
end subroutine
!DEF: /expect_intrinsic (Subroutine) Subprogram
subroutine expect_intrinsic
!DEF: /expect_intrinsic/y (Implicit) ObjectEntity REAL(4)
!DEF: /expect_intrinsic/acos ELEMENTAL, INTRINSIC, PURE (Function) ProcEntity
!DEF: /expect_intrinsic/x (Implicit) ObjectEntity REAL(4)
y = acos(x)
!DEF: /expect_intrinsic/system_clock INTRINSIC (Subroutine) ProcEntity
!DEF: /expect_intrinsic/icount (Implicit) ObjectEntity INTEGER(4)
call system_clock(icount)
end subroutine
! Sanity check that the EXTERNAL attribute is not bypassed by
! implicit intrinsic resolution, even if it otherwise perfectly
! matches an intrinsic call.
!DEF: /expect_external_2 (Subroutine) Subprogram
subroutine expect_external_2
!DEF: /expect_external_2/matmul EXTERNAL (Function, Implicit) ProcEntity INTEGER(4)
external :: matmul
!DEF: /expect_external_2/cpu_time EXTERNAL (Subroutine) ProcEntity
external :: cpu_time
!DEF: /expect_external_2/x ObjectEntity REAL(4)
!DEF: /expect_external_2/y ObjectEntity REAL(4)
!DEF: /expect_external_2/z ObjectEntity REAL(4)
!DEF: /expect_external_2/t ObjectEntity REAL(4)
real x(2,2), y(2), z(2), t
!REF: /expect_external_2/z
!REF: /expect_external_2/matmul
!REF: /expect_external_2/x
!REF: /expect_external_2/y
z = matmul(x, y)
!REF: /expect_external_2/cpu_time
!REF: /expect_external_2/t
call cpu_time(t)
end subroutine