Skip to content

Commit 75abd17

Browse files
committed
add a test for resolution
1 parent ece1e45 commit 75abd17

File tree

2 files changed

+66
-1
lines changed

2 files changed

+66
-1
lines changed

flang/lib/Semantics/check-declarations.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -968,7 +968,8 @@ void CheckHelper::CheckObjectEntity(
968968
if (details.init()) {
969969
messages_.Say(
970970
"Cray pointee '%s' may not be initialized"_err_en_US, symbol.name());
971-
} else if (symbol.attrs().test(Attr::SAVE)) {
971+
}
972+
if (symbol.attrs().test(Attr::SAVE)) {
972973
messages_.Say(
973974
"Cray pointee '%s' may not have the SAVE attribute"_err_en_US,
974975
symbol.name());

flang/test/Semantics/resolve125.f90

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
! RUN: %flang_fc1 -fdebug-dump-symbols %s 2>&1 | FileCheck %s
2+
3+
!CHECK: Module scope: m1
4+
!CHECK: i, PUBLIC size={{[0-9]+}} offset={{[0-9]+}}: ObjectEntity type: REAL({{[0-9]+}}) init:{{.+}}
5+
!CHECK: init, PUBLIC (Subroutine): Subprogram ()
6+
!CHECK: o, PUBLIC (CrayPointee) size={{[0-9]+}} offset={{[0-9]+}}: ObjectEntity type: REAL({{[0-9]+}})
7+
!CHECK: ptr, PUBLIC (CrayPointer) size={{[0-9]+}} offset={{[0-9]+}}: ObjectEntity type: INTEGER({{[0-9]+}})
8+
module m1
9+
implicit none
10+
real:: o
11+
real:: i = 42.0
12+
pointer (ptr, o)
13+
contains
14+
!CHECK: Subprogram scope: init
15+
subroutine init
16+
implicit none
17+
ptr=loc(i)
18+
print *, "init : o= ", o
19+
end subroutine init
20+
end module m1
21+
22+
!CHECK: Module scope: m2
23+
!CHECK: i, PUBLIC: Use from i in m1
24+
!CHECK: i2, PUBLIC size={{[0-9]+}} offset={{[0-9]+}}: ObjectEntity type: REAL({{[0-9]+}}) init:{{.+}}
25+
!CHECK: init, PUBLIC (Subroutine): Use from init in m1
26+
!CHECK: o, PUBLIC (CrayPointee): Use from o in m1
27+
!CHECK: ptr, PUBLIC (CrayPointer): Use from ptr in m1
28+
!CHECK: reset, PUBLIC (Subroutine): Subprogram ()
29+
module m2
30+
use m1
31+
implicit none
32+
real:: i2 = 777.0
33+
contains
34+
!CHECK: Subprogram scope: reset
35+
!CHECK: o2 (CrayPointee) size={{[0-9]+}} offset={{[0-9]+}}: ObjectEntity type: REAL({{[0-9]+}})
36+
!CHECK: ptr (CrayPointer) size={{[0-9]+}} offset={{[0-9]+}}: ObjectEntity type: INTEGER({{[0-9]+}})
37+
subroutine reset
38+
real::o2
39+
pointer (ptr, o2)
40+
ptr=loc(i2)
41+
print *, "reset : o= ", o, " o2 = ", o2
42+
o2 = 666.0
43+
end subroutine reset
44+
end module m2
45+
46+
!CHECK: MainProgram scope: main
47+
!CHECK: i: Use from i in m2
48+
!CHECK: i2: Use from i2 in m2
49+
!CHECK: init (Subroutine): Use from init in m2
50+
!CHECK: o (CrayPointee): Use from o in m2
51+
!CHECK: ptr (CrayPointer): Use from ptr in m2
52+
!CHECK: reset (Subroutine): Use from reset in m2
53+
program main
54+
use m2
55+
implicit none
56+
call init
57+
call reset
58+
write(6,*) "main : o = ", o
59+
if (o == 42.0) then
60+
print *, "pass"
61+
else
62+
print *, "fail"
63+
end if
64+
end program main

0 commit comments

Comments
 (0)