xref: /llvm-project/flang/test/Semantics/resolve81.f90 (revision ab7930bd9f088c4fcdfd438b5207a4052c9669b8)
1! RUN: %python %S/test_errors.py %s %flang_fc1
2! C801 The same attr-spec shall not appear more than once in a given
3! type-declaration-stmt.
4!
5! R801 type-declaration-stmt ->
6!        declaration-type-spec [[, attr-spec]... ::] entity-decl-list
7!  attr-spec values are:
8!    PUBLIC, PRIVATE, ALLOCATABLE, ASYNCHRONOUS, CODIMENSION, CONTIGUOUS,
9!    DIMENSION (array-spec), EXTERNAL, INTENT (intent-spec), INTRINSIC,
10!    BIND(C), OPTIONAL, PARAMETER, POINTER, PROTECTED, SAVE, TARGET, VALUE,
11!    VOLATILE
12module m
13
14  !WARNING: Attribute 'PUBLIC' cannot be used more than once
15  real, public, allocatable, public :: publicVar
16  !WARNING: Attribute 'PRIVATE' cannot be used more than once
17  real, private, allocatable, private :: privateVar
18  !WARNING: Attribute 'ALLOCATABLE' cannot be used more than once
19  real, allocatable, allocatable :: allocVar
20  !WARNING: Attribute 'ASYNCHRONOUS' cannot be used more than once
21  real, asynchronous, public, asynchronous :: asynchVar
22  !ERROR: Attribute 'CODIMENSION' cannot be used more than once
23  real, codimension[*], codimension[*] :: codimensionVar
24  !WARNING: Attribute 'CONTIGUOUS' cannot be used more than once
25  real, contiguous, pointer, contiguous :: contigVar(:)
26  !ERROR: Attribute 'DIMENSION' cannot be used more than once
27  real, dimension(5), dimension(5) :: arrayVar
28  !WARNING: Attribute 'EXTERNAL' cannot be used more than once
29  real, external, external :: externFunc
30  !WARNING: Attribute 'INTRINSIC' cannot be used more than once
31  !ERROR: 'cos' may not have both the BIND(C) and INTRINSIC attributes
32  !ERROR: An interface name with the BIND attribute must appear if the BIND attribute appears in a procedure declaration
33  real, intrinsic, bind(c), intrinsic :: cos
34  !WARNING: Attribute 'BIND(C)' cannot be used more than once
35  integer, bind(c), volatile, bind(c) :: bindVar
36  !WARNING: Attribute 'PARAMETER' cannot be used more than once
37  real, parameter, parameter :: realConst = 4.3
38  !WARNING: Attribute 'POINTER' cannot be used more than once
39  real, pointer, pointer :: realPtr
40  !WARNING: Attribute 'PROTECTED' cannot be used more than once
41  real, protected, protected :: realProt
42  !WARNING: Attribute 'SAVE' cannot be used more than once
43  real, save, save :: saveVar
44  !WARNING: Attribute 'TARGET' cannot be used more than once
45  real, target, target :: targetVar
46  !WARNING: Attribute 'VOLATILE' cannot be used more than once
47  real, volatile, volatile :: volatileVar
48
49contains
50    subroutine testTypeDecl(arg1, arg2, arg3, arg4, arg5, arg6)
51      !WARNING: Attribute 'INTENT(IN)' cannot be used more than once
52      real, intent(in), intent(in) :: arg1
53      !WARNING: Attribute 'INTENT(OUT)' cannot be used more than once
54      real, intent(out), intent(out) :: arg2
55      !WARNING: Attribute 'INTENT(INOUT)' cannot be used more than once
56      real, intent(inout), intent(inout) :: arg3
57      !WARNING: Attribute 'OPTIONAL' cannot be used more than once
58      integer, optional, intent(in), optional :: arg4
59      !WARNING: Attribute 'VALUE' cannot be used more than once
60      integer, value, intent(in), value :: arg5
61      !ERROR: Attributes 'INTENT(IN)' and 'INTENT(INOUT)' conflict with each other
62      integer, intent(in), pointer, intent(inout) :: arg6
63
64      arg2 =3.5
65    end subroutine testTypeDecl
66end module m
67