PR inline-asm/84742
[official-gcc.git] / gcc / testsuite / gfortran.dg / implied_shape_3.f08
blob6cf13bb401334dd69a5c1fb836ebfe4e11bac664
1 ! { dg-do compile }
2 ! { dg-options "-std=f2008" }
4 ! Test for errors with implied-shape declarations.
6 ! Contributed by Daniel Kraft, d@domob.eu.
8 PROGRAM main
9   IMPLICIT NONE
11   INTEGER :: n
12   INTEGER, PARAMETER :: mat(2, 2) = RESHAPE ((/ 1, 2, 3, 4 /), (/ 2, 2 /))
14   ! Malformed declaration.
15   INTEGER, PARAMETER :: arr1(*, *, 5) = mat ! { dg-error "Bad array specification for implied-shape array" }
17   ! Rank mismatch in initialization.
18   INTEGER, PARAMETER :: arr2(*, *) = (/ 1, 2, 3, 4 /) ! { dg-error "Incompatible ranks" }
20   ! Non-PARAMETER implied-shape, with and without initializer.
21   INTEGER :: arr3(*, *) ! { dg-error "Non-PARAMETER" }
22   INTEGER :: arr4(*, *) = mat ! { dg-error "Non-PARAMETER" }
24   ! Missing initializer.
25   INTEGER, PARAMETER :: arr5(*) ! { dg-error "is missing an initializer" }
27   ! Initialization from scalar.
28   INTEGER, PARAMETER :: arr6(*) = 0 ! { dg-error "with scalar" }
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