xref: /llvm-project/flang/test/Semantics/misc-declarations.f90 (revision b288b412edbe1a9e6f2cf88672a214f29082e2d3)
1! RUN: %python %S/test_errors.py %s %flang_fc1
2! Miscellaneous constraint and requirement checking on declarations:
3! - 8.5.6.2 & 8.5.6.3 constraints on coarrays
4! - 8.5.19 constraints on the VOLATILE attribute
5
6module m
7  !ERROR: 'mustbedeferred' is an ALLOCATABLE coarray and must have a deferred coshape
8  real, allocatable :: mustBeDeferred[*]  ! C827
9  !ERROR: 'mustbeexplicit' is a non-ALLOCATABLE coarray and must have an explicit coshape
10  real :: mustBeExplicit[:]  ! C828
11  type :: hasCoarray
12    real, allocatable :: coarray[:]
13  end type
14  real :: coarray[*]
15  type(hasCoarray) :: coarrayComponent
16 contains
17  !ERROR: VOLATILE attribute may not apply to an INTENT(IN) argument
18  subroutine C866(x)
19    intent(in) :: x
20    volatile :: x
21    !ERROR: VOLATILE attribute may apply only to a variable
22    volatile :: notData
23    external :: notData
24  end subroutine
25  subroutine C867
26    !ERROR: VOLATILE attribute may not apply to a coarray accessed by USE or host association
27    volatile :: coarray
28    !ERROR: VOLATILE attribute may not apply to a type with a coarray ultimate component accessed by USE or host association
29    volatile :: coarrayComponent
30  end subroutine
31  subroutine C868(coarray,coarrayComponent)
32    real :: coarray[*]
33    type(hasCoarray) :: coarrayComponent
34    block
35      !ERROR: VOLATILE attribute may not apply to a coarray accessed by USE or host association
36      volatile :: coarray
37      !ERROR: VOLATILE attribute may not apply to a type with a coarray ultimate component accessed by USE or host association
38      volatile :: coarrayComponent
39    end block
40  end subroutine
41  subroutine C839(x)
42    !ERROR: Coarray 'x' may not be an assumed-rank array
43    real, intent(in) :: x(..)[*]
44  end
45end module
46