<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/127425>127425</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [Flang] Incorrect compilation message when the first argument of CRAY POINTER is undefined and used in any intrinsic function
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            flang:frontend
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          ohno-fj
      </td>
    </tr>
</table>

<pre>
    ```
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)
$
```

</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJzcV81y2zYQfhrosmMNCP5JBx0Y28qkh7aTZtLpqQOBSxIuCHAAMLHevrMkZUt2nPTSOqmGQ5vAYn8-fLvAyhB0axF3LH_D8puVHGPn_M511l01d6uDq487VvDl4dVH9EE7C66BxkjbAksrEMmarzkTm1rwrBSZwKLmDa_xUBZp1jRCyENSZGmeqVxwVW6Z2DKxryqvuiJjvDq3wHj1oUOQMUrVYQ2Dd62XPegA1kVQzntUcQ3AePV7hxZih9BoHyJI34492kjesYJfv6_-gF9_effzh9v3rOCkYbQ1NtpiDdLWMAasQVuSlfY4idjotQ1aQTNaFbWzTFyDBOX6QRtJA4DeO0_KBqdtxBrcGEHbxTFznF3bT-gEeQyTgwabONn0uu0iuAG9tHUA6RFq3TToyW9tAe8j2niho3OjmawMY7zwpMcQZIsQdK-N9BAdvG2cj17ayZZu7mdFVQAJEUOkaD6fQJug0JOmEGXEfnGB5gIqZ2sw2iKFilYeDNa0nGbPnSBDeI9qjAsvYkfYLLs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