| Peter Klausler | 5a0382c | 2024-03-26 09:40:48 -0700 | [diff] [blame] | 1 | ! RUN: %python %S/test_errors.py %s %flang_fc1 -pedantic |
| 2 | ! Structure constructors with bad pointer targets |
| 3 | module m |
| 4 | real, target, save :: x |
| 5 | type t |
| 6 | real, pointer :: rp => x |
| 7 | procedure(f), pointer, nopass :: pp => f |
| 8 | end type |
| 9 | contains |
| 10 | real function f() |
| 11 | f = 0. |
| 12 | end |
| 13 | subroutine test(da, dp) |
| 14 | real, target :: y, da |
| 15 | procedure(f) dp |
| 16 | procedure(f), pointer :: lpp |
| 17 | external ext |
| 18 | type(t) :: a1 = t() ! ok |
| 19 | type(t) :: a2 = t(rp=x) ! ok |
| 20 | type(t) :: a3 = t(pp=f) ! ok |
| 21 | type(t) :: a4 = t(pp=ext) ! ok |
| 22 | !ERROR: Must be a constant value |
| 23 | type(t) :: a5 = t(rp=y) |
| 24 | !ERROR: Must be a constant value |
| 25 | type(t) :: a6 = t(rp=da) |
| 26 | !ERROR: Must be a constant value |
| 27 | type(t) :: a7 = t(pp=lpp) |
| 28 | !ERROR: Must be a constant value |
| 29 | type(t) :: a8 = t(pp=internal) |
| 30 | !ERROR: Must be a constant value |
| 31 | type(t) :: a9 = t(pp=dp) |
| 32 | contains |
| 33 | real function internal() |
| 34 | internal = 666. |
| 35 | end |
| 36 | end |
| 37 | end |