xref: /llvm-project/flang/test/Semantics/declarations03.f90 (revision 961a138237947daa5ccabfc87dbfbad8b47146e4)
1dafd3cf8SPeixin-Qiao! RUN: %python %S/test_errors.py %s %flang_fc1
2dafd3cf8SPeixin-Qiao! test bind(c) name conflict
3dafd3cf8SPeixin-Qiao
4dafd3cf8SPeixin-Qiaomodule m
5dafd3cf8SPeixin-Qiao
6dafd3cf8SPeixin-Qiao  integer :: x, y, z, w, i, j, k
7dafd3cf8SPeixin-Qiao
83077d614SPeter Klausler  !ERROR: Two entities have the same global name 'aa'
9dafd3cf8SPeixin-Qiao  common /blk1/ x, /blk2/ y
10dafd3cf8SPeixin-Qiao  bind(c, name="aa") :: /blk1/, /blk2/
11dafd3cf8SPeixin-Qiao
12dafd3cf8SPeixin-Qiao  integer :: t
133077d614SPeter Klausler  !ERROR: Two entities have the same global name 'bb'
14dafd3cf8SPeixin-Qiao  common /blk3/ z
15dafd3cf8SPeixin-Qiao  bind(c, name="bb") :: /blk3/, t
16dafd3cf8SPeixin-Qiao
17dafd3cf8SPeixin-Qiao  integer :: t2
183077d614SPeter Klausler  !ERROR: Two entities have the same global name 'cc'
19dafd3cf8SPeixin-Qiao  common /blk4/ w
20dafd3cf8SPeixin-Qiao  bind(c, name="cc") :: t2, /blk4/
21dafd3cf8SPeixin-Qiao
22c3def59dSPeter Klausler  !ERROR: The entity 'blk5' has multiple BIND names ('dd' and 'ee')
23dafd3cf8SPeixin-Qiao  common /blk5/ i
24dafd3cf8SPeixin-Qiao  bind(c, name="dd") :: /blk5/
25dafd3cf8SPeixin-Qiao  bind(c, name="ee") :: /blk5/
26dafd3cf8SPeixin-Qiao
273077d614SPeter Klausler  !ERROR: Two entities have the same global name 'ff'
28dafd3cf8SPeixin-Qiao  common /blk6/ j, /blk7/ k
29dafd3cf8SPeixin-Qiao  bind(c, name="ff") :: /blk6/
30dafd3cf8SPeixin-Qiao  bind(c, name="ff") :: /blk7/
31dafd3cf8SPeixin-Qiao
32c3def59dSPeter Klausler  !ERROR: The entity 's1' has multiple BIND names ('gg' and 'hh')
33dafd3cf8SPeixin-Qiao  integer :: s1
34dafd3cf8SPeixin-Qiao  bind(c, name="gg") :: s1
35cff7fad1SPeter Klausler  !ERROR: BIND_C attribute was already specified on 's1'
36dafd3cf8SPeixin-Qiao  bind(c, name="hh") :: s1
37dafd3cf8SPeixin-Qiao
383077d614SPeter Klausler  !ERROR: Two entities have the same global name 'ii'
39dafd3cf8SPeixin-Qiao  integer :: s2, s3
40dafd3cf8SPeixin-Qiao  bind(c, name="ii") :: s2
41dafd3cf8SPeixin-Qiao  bind(c, name="ii") :: s3
42dafd3cf8SPeixin-Qiao
43c3def59dSPeter Klausler  !ERROR: The entity 's4' has multiple BIND names ('ss1' and 'jj')
44dafd3cf8SPeixin-Qiao  integer, bind(c, name="ss1") :: s4
45cff7fad1SPeter Klausler  !ERROR: BIND_C attribute was already specified on 's4'
46dafd3cf8SPeixin-Qiao  bind(c, name="jj") :: s4
47dafd3cf8SPeixin-Qiao
48c3def59dSPeter Klausler  !ERROR: The entity 's5' has multiple BIND names ('kk' and 'ss2')
49dafd3cf8SPeixin-Qiao  bind(c, name="kk") :: s5
50cff7fad1SPeter Klausler  !ERROR: BIND_C attribute was already specified on 's5'
51dafd3cf8SPeixin-Qiao  integer, bind(c, name="ss2") :: s5
52dafd3cf8SPeixin-Qiao
53*961a1382SPeter Klausler  integer, bind(c, name="s6explicit") :: s6
54*961a1382SPeter Klausler  dimension s6(10) ! caused spurious error
55*961a1382SPeter Klausler
56dafd3cf8SPeixin-Qiaoend
5760e35994SPeixinQiao
5860e35994SPeixinQiaosubroutine common1()
5960e35994SPeixinQiao  real :: x
6060e35994SPeixinQiao  common /com/ x
6160e35994SPeixinQiao  bind(c, name='xcom') /com/ ! no error
6260e35994SPeixinQiaoend subroutine
6360e35994SPeixinQiao
6460e35994SPeixinQiaosubroutine common2()
6560e35994SPeixinQiao  real :: x
6660e35994SPeixinQiao  common /com/ x
6760e35994SPeixinQiao  bind(c, name='xcom') /com/ ! no error
6860e35994SPeixinQiaoend subroutine
6960e35994SPeixinQiao
7060e35994SPeixinQiaomodule a
7160e35994SPeixinQiao  integer, bind(c, name="int") :: i
7260e35994SPeixinQiaoend module
7360e35994SPeixinQiao
7460e35994SPeixinQiaomodule b
753077d614SPeter Klausler  !ERROR: Two entities have the same global name 'int'
7660e35994SPeixinQiao  integer, bind(c, name="int") :: i
7760e35994SPeixinQiaoend module
78c3def59dSPeter Klausler
79c3def59dSPeter Klauslermodule c
80c3def59dSPeter Klausler  bind(c, name = "AAA") a
81c3def59dSPeter Klausler  integer aaa ! ensure no bogus error about multiple binding names
82c3def59dSPeter Klauslerend module
83