Debian Codegraph @

flang/test/Lower/HLFIR/common-block-bindc-conflicts.f90

raw
1 ! Test the mixing BIND(C) and non BIND(C) common blocks.
2
3 ! RUN: %flang_fc1 -emit-llvm %s -o - 2>&1 | FileCheck %s --check-prefix=UNDERSCORING
4 ! RUN: %flang_fc1 -emit-llvm -fno-underscoring %s -o - 2>&1 | FileCheck %s --check-prefix=NO-UNDERSCORING
5
6 ! Scenario 1: Fortran symbols collide, but not the object file names, emit different
7 ! globals for each common
8 subroutine bindc_common_with_same_fortran_name()
9 real :: x
10 common /com1/ x
11 bind(c, name="not_com1") :: /com1/
12 print *, x
13 end subroutine
14
15 subroutine bindc_common_with_same_fortran_name_2()
16 real :: x(2), y(2)
17 common /com1/ x
18 print *, x
19 end subroutine
20
21 ! Scenario 2: object file names of common block may collide (depending on
22 ! underscoring option). Merge common block into a single global symbol.
23 subroutine bindc_common_colliding_with_normal_common()
24 real :: x, y
25 common /com3/ x
26 common /com4/ y
27 bind(c, name="some_common_") :: /com3/
28 bind(c, name="__BLNK__") :: /com4/
29 print *, x, y
30 end subroutine
31 subroutine bindc_common_colliding_with_normal_common_2()
32 real :: x(2), y(2)
33 common /some_common/ x
34 common // y
35 print *, x, y
36 end subroutine
37
38 ! UNDERSCORING: @__BLNK__ = common global [8 x i8] zeroinitializer
39 ! UNDERSCORING: @com1_ = common global [8 x i8] zeroinitializer
40 ! UNDERSCORING: @not_com1 = common global [4 x i8] zeroinitializer
41 ! UNDERSCORING: @some_common_ = common global [8 x i8] zeroinitializer
42
43 ! NO-UNDERSCORING: @__BLNK__ = common global [8 x i8] zeroinitializer
44 ! NO-UNDERSCORING: @com1 = common global [8 x i8] zeroinitializer
45 ! NO-UNDERSCORING: @not_com1 = common global [4 x i8] zeroinitializer
46 ! NO-UNDERSCORING: @some_common = common global [8 x i8] zeroinitializer
47 ! NO-UNDERSCORING: @some_common_ = common global [4 x i8] zeroinitializer