llvm-project/flang/test/Semantics/OpenMP/declare-reduction-mangled.f90
Eugene Epshteyn 413e71b700
[flang] Main program symbol no longer conflicts with the other symbols (#149169)
The following code is now accepted:
```
module m
end
program m
use m
end
```
The PROGRAM name doesn't really have an effect on the compilation
result, so it shouldn't result in symbol name conflicts.

This change makes the main program symbol name all uppercase in the
cooked character stream. This makes it distinct from all other symbol
names that are all lowercase in cooked character stream.

Modified the tests that were checking for lower case main program name.
2025-07-17 14:18:21 -04:00

52 lines
1.4 KiB
Fortran

! RUN: %flang_fc1 -fdebug-dump-symbols -fopenmp -fopenmp-version=50 %s | FileCheck %s
!! Test that the name mangling for min & max (also used for iand, ieor and ior).
module mymod
type :: tt
real r
end type tt
contains
function mymax(a, b)
type(tt) :: a, b, mymax
if (a%r > b%r) then
mymax = a
else
mymax = b
end if
end function mymax
end module mymod
program omp_examples
!CHECK-LABEL: MainProgram scope: OMP_EXAMPLES
use mymod
implicit none
integer, parameter :: n = 100
integer :: i
type(tt) :: values(n), big, small
!$omp declare reduction(max:tt:omp_out = mymax(omp_out, omp_in)) initializer(omp_priv%r = 0)
!$omp declare reduction(min:tt:omp_out%r = min(omp_out%r, omp_in%r)) initializer(omp_priv%r = 1)
!CHECK: min, ELEMENTAL, INTRINSIC, PURE (Function): ProcEntity
!CHECK: mymax (Function): Use from mymax in mymod
!CHECK: op.max: UserReductionDetails TYPE(tt)
!CHECK: op.min: UserReductionDetails TYPE(tt)
big%r = 0
!$omp parallel do reduction(max:big)
!CHECK: big (OmpReduction, OmpExplicit): HostAssoc
!CHECK: max, INTRINSIC: ProcEntity
do i = 1, n
big = mymax(values(i), big)
end do
small%r = 1
!$omp parallel do reduction(min:small)
!CHECK: small (OmpReduction, OmpExplicit): HostAssoc
do i = 1, n
small%r = min(values(i)%r, small%r)
end do
print *, "small=", small%r, " big=", big%r
end program omp_examples