| 1 |
! { dg-do compile } |
| 2 |
! { dg-options "-std=f2008" } |
| 3 |
|
| 4 |
! Test for errors with implied-shape declarations. |
| 5 |
|
| 6 |
! Contributed by Daniel Kraft, [email protected]. |
| 7 |
|
| 8 |
PROGRAM main |
| 9 |
IMPLICIT NONE |
| 10 |
|
| 11 |
INTEGER :: n |
| 12 |
INTEGER, PARAMETER :: mat(2, 2) = RESHAPE ((/ 1, 2, 3, 4 /), (/ 2, 2 /)) |
| 13 |
|
| 14 |
! Malformed declaration. |
| 15 |
INTEGER, PARAMETER :: arr1(*, *, 5) = mat ! { dg-error "Bad array specification for implied-shape array" } |
| 16 |
|
| 17 |
! Rank mismatch in initialization. |
| 18 |
INTEGER, PARAMETER :: arr2(*, *) = (/ 1, 2, 3, 4 /) ! { dg-error "Incompatible ranks" } |
| 19 |
|
| 20 |
! Non-PARAMETER implied-shape, with and without initializer. |
| 21 |
INTEGER :: arr3(*, *) ! { dg-error "Non-PARAMETER" } |
| 22 |
INTEGER :: arr4(*, *) = mat ! { dg-error "Non-PARAMETER" } |
| 23 |
|
| 24 |
! Missing initializer. |
| 25 |
INTEGER, PARAMETER :: arr5(*) ! { dg-error "is missing an initializer" } |
| 26 |
|
| 27 |
! Initialization from scalar. |
| 28 |
INTEGER, PARAMETER :: arr6(*) = 0 ! { dg-error "with scalar" } |
| 29 |
|
| 30 |
! Automatic bounds. |
| 31 |
n = 2 |
| 32 |
BLOCK |
| 33 |
INTEGER, PARAMETER :: arr7(n:*) = (/ 2, 3, 4 /) ! { dg-error "Non-constant lower bound" } |
| 34 |
END BLOCK |
| 35 |
END PROGRAM main |