xref: /llvm-project/flang/test/Semantics/declarations02.f90 (revision 055df491ed1c179eb0d6a4c686b183b787de9943)
1! RUN: %python %S/test_errors.py %s %flang_fc1 -pedantic
2
3module m
4  !ERROR: 'x1' may not have both the BIND(C) and PARAMETER attributes
5  integer, parameter, bind(c, name="a") :: x1 = 1
6  !ERROR: 'x2' may not have both the BIND(C) and PARAMETER attributes
7  integer, bind(c), parameter :: x2 = 1
8
9  !ERROR: 'x3' may not have both the BIND(C) and PARAMETER attributes
10  integer, parameter :: x3 = 1
11  bind(c) :: x3
12
13  !ERROR: 'x4' may not have both the ALLOCATABLE and PARAMETER attributes
14  !ERROR: 'x4' may not have both the ASYNCHRONOUS and PARAMETER attributes
15  !ERROR: 'x4' may not have both the SAVE and PARAMETER attributes
16  !ERROR: 'x4' may not have both the TARGET and PARAMETER attributes
17  !ERROR: 'x4' may not have both the VOLATILE and PARAMETER attributes
18  !ERROR: The entity 'x4' with an explicit SAVE attribute must be a variable, procedure pointer, or COMMON block
19  !ERROR: An entity may not have the ASYNCHRONOUS attribute unless it is a variable
20  integer, parameter :: x4 = 1
21  allocatable x4
22  asynchronous x4
23  save x4
24  target x4
25  volatile x4
26
27  type :: my_type1
28    integer :: x4
29  end type
30  type, bind(c) :: my_type2
31    integer :: x5
32  end type
33
34  !ERROR: 't1' may not have both the BIND(C) and PARAMETER attributes
35  !WARNING: The derived type of an interoperable object should be BIND(C)
36  type(my_type1), bind(c), parameter :: t1 = my_type1(1)
37  !ERROR: 't2' may not have both the BIND(C) and PARAMETER attributes
38  type(my_type2), bind(c), parameter :: t2 = my_type2(1)
39
40  type(my_type2), parameter :: t3 = my_type2(1) ! no error
41  !ERROR: 't4' may not have both the BIND(C) and PARAMETER attributes
42  !WARNING: The derived type of an interoperable object should be BIND(C)
43  type(my_type1), parameter :: t4 = my_type1(1)
44  !ERROR: 't5' may not have both the BIND(C) and PARAMETER attributes
45  type(my_type2), parameter :: t5 = my_type2(1)
46  bind(c) :: t4, t5
47
48end
49