Issue 127425
Summary [Flang] Incorrect compilation message when the first argument of CRAY POINTER is undefined and used in any intrinsic function
Labels flang:frontend
Assignees
Reporter ohno-fj
    ```
Version of flang : 21.0.0(d2047242e6d0f0deb7634ff22ab164354c520c79)/AArch64
```

The attached program is not correct.  
When the first argument of `CRAY POINTER` is undefined and used in `any` intrinsic function, a compilation error is pointed out incorrectly.  
Flang says the left and right operands are different in extent.  
Flang should output compilation message similar to Gfortran and ifx.  
As a test, when the definition statement in the second line is enabled, the compilation and execution of this program terminates normally.

The following are the test program, Flang, Gfortran and ifx compilation/execution result.

snggf361_2.f90:
```fortran
program main
! integer*8 j1,j2,j3,j4,j5
  pointer (j1,ja)
  pointer (j2,jb)
  if (any((/j1,j2,j3,j4,j5/)/=(/1,2,3,4,5/))) print *,'fail'
end program main
```

```
$ flang snggf361_2.f90
error: Semantic errors in snggf361_2.f90
./snggf361_2.f90:5:7: error: Dimension 1 of left operand has extent 2, but right operand has extent 5
    if (any((/j1,j2,j3,j4,j5/)/=(/1,2,3,4,5/))) print *,'fail'
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
./snggf361_2.f90:5:11: error: Dimension 1 of left operand has extent 2, but right operand has extent 5
 if (any((/j1,j2,j3,j4,j5/)/=(/1,2,3,4,5/))) print *,'fail'
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
./snggf361_2.f90:5:19: error: Values in array constructor must have the same declared type when no explicit type appears
    if (any((/j1,j2,j3,j4,j5/)/=(/1,2,3,4,5/))) print *,'fail'
 ^^
$
```

```
$ gfortran snggf361_2.f90 -fcray-pointer
snggf361_2.f90:5:18:

    5 |   if (any((/j1,j2,j3,j4,j5/)/=(/1,2,3,4,5/))) print *,'fail'
      | 1
Error: Element in INTEGER(8) array constructor at (1) is INTEGER(4)
$
```

```
$ ifx snggf361_2.f90
snggf361_2.f90(5): error #8209: If type specification is omitted, each element in an array-constructor must have the same type and kind type parameters.   [J3]
  if (any((/j1,j2,j3,j4,j5/)/=(/1,2,3,4,5/))) print *,'fail'
------------------^
snggf361_2.f90(5): error #8209: If type specification is omitted, each element in an array-constructor must have the same type and kind type parameters.   [J4]
  if (any((/j1,j2,j3,j4,j5/)/=(/1,2,3,4,5/))) print *,'fail'
---------------------^
snggf361_2.f90(5): error #8209: If type specification is omitted, each element in an array-constructor must have the same type and kind type parameters.   [J5]
  if (any((/j1,j2,j3,j4,j5/)/=(/1,2,3,4,5/))) print *,'fail'
------------------------^
compilation aborted for snggf361_2.f90 (code 1)
$
```

_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to