|
| 1 | +! RUN: %python %S/test_errors.py %s %flang_fc1 |
| 2 | +! Every other Fortran compiler (but one) interprets the names of parent |
| 3 | +! components like this when the names of their types are the product of |
| 4 | +! USE association with renaming. |
| 5 | + |
| 6 | +module m1 |
| 7 | + type originalName |
| 8 | + integer m |
| 9 | + end type |
| 10 | +end |
| 11 | + |
| 12 | +module m2 |
| 13 | + use m1, newName => originalName |
| 14 | + type, extends(newName) :: extended |
| 15 | + integer n |
| 16 | + end type |
| 17 | + type, extends(newName) :: extended2 |
| 18 | + integer originalName ! ok |
| 19 | + end type |
| 20 | + contains |
| 21 | + subroutine s1 |
| 22 | + type(extended) x |
| 23 | + type(extended2) x2 |
| 24 | + print *, x%newName%m ! ok |
| 25 | + !ERROR: Component 'originalname' not found in derived type 'extended' |
| 26 | + print *, x%originalName |
| 27 | + print *, extended(newName=newName(m=1),n=2) ! ok |
| 28 | + !ERROR: Structure constructor lacks a value for component 'm' |
| 29 | + !ERROR: Keyword 'originalname=' does not name a component of derived type 'extended' |
| 30 | + !ERROR: Keyword 'm=' may not appear in a reference to a procedure with an implicit interface |
| 31 | + print *, extended(originalName=originalName(m=1),n=2) |
| 32 | + !ERROR: Value in structure constructor of type 'REAL(4)' is incompatible with component 'newname' of type 'newname' |
| 33 | + !ERROR: Keyword 'm=' may not appear in a reference to a procedure with an implicit interface |
| 34 | + print *, extended(newName=originalName(m=1),n=2) |
| 35 | + !ERROR: Structure constructor lacks a value for component 'm' |
| 36 | + !ERROR: Keyword 'originalname=' does not name a component of derived type 'extended' |
| 37 | + print *, extended(originalName=newName(m=1),n=2) |
| 38 | + print *, x2%newName%m ! ok |
| 39 | + print *, x2%originalName ! ok |
| 40 | + print *, extended2(newName=newName(m=1),originalName=2) ! ok |
| 41 | + end |
| 42 | +end |
| 43 | + |
| 44 | +module m3 |
| 45 | + use m2 |
| 46 | + contains |
| 47 | + ! Same as above, but not in the same module as the derived |
| 48 | + ! types' definitions. |
| 49 | + subroutine s2 |
| 50 | + type(extended) x |
| 51 | + type(extended2) x2 |
| 52 | + print *, x%newName%m ! ok |
| 53 | + !ERROR: Component 'originalname' not found in derived type 'extended' |
| 54 | + print *, x%originalName |
| 55 | + print *, extended(newName=newName(m=1),n=2) ! ok |
| 56 | + !ERROR: Structure constructor lacks a value for component 'm' |
| 57 | + !ERROR: Keyword 'originalname=' does not name a component of derived type 'extended' |
| 58 | + !ERROR: Keyword 'm=' may not appear in a reference to a procedure with an implicit interface |
| 59 | + print *, extended(originalName=originalName(m=1),n=2) |
| 60 | + !ERROR: Value in structure constructor of type 'REAL(4)' is incompatible with component 'newname' of type 'newname' |
| 61 | + !ERROR: Keyword 'm=' may not appear in a reference to a procedure with an implicit interface |
| 62 | + print *, extended(newName=originalName(m=1),n=2) |
| 63 | + !ERROR: Structure constructor lacks a value for component 'm' |
| 64 | + !ERROR: Keyword 'originalname=' does not name a component of derived type 'extended' |
| 65 | + print *, extended(originalName=newName(m=1),n=2) |
| 66 | + print *, x2%newName%m ! ok |
| 67 | + print *, x2%originalName ! ok |
| 68 | + print *, extended2(newName=newName(m=1),originalName=2) ! ok |
| 69 | + end |
| 70 | +end |
0 commit comments