File tree Expand file tree Collapse file tree 2 files changed +44
-3
lines changed Expand file tree Collapse file tree 2 files changed +44
-3
lines changed Original file line number Diff line number Diff line change @@ -358,10 +358,14 @@ bool IsInitialProcedureTarget(const semantics::Symbol &symbol) {
358
358
const auto &ultimate{symbol.GetUltimate ()};
359
359
return common::visit (
360
360
common::visitors{
361
- [](const semantics::SubprogramDetails &subp) {
362
- return !subp.isDummy ();
361
+ [&](const semantics::SubprogramDetails &subp) {
362
+ return !subp.isDummy () && !subp.stmtFunction () &&
363
+ symbol.owner ().kind () != semantics::Scope::Kind::MainProgram &&
364
+ symbol.owner ().kind () != semantics::Scope::Kind::Subprogram;
365
+ },
366
+ [](const semantics::SubprogramNameDetails &x) {
367
+ return x.kind () != semantics::SubprogramKind::Internal;
363
368
},
364
- [](const semantics::SubprogramNameDetails &) { return true ; },
365
369
[&](const semantics::ProcEntityDetails &proc) {
366
370
return !semantics::IsPointer (ultimate) && !proc.isDummy ();
367
371
},
Original file line number Diff line number Diff line change
1
+ ! RUN: %python %S/test_errors.py %s %flang_fc1 -pedantic
2
+ ! Structure constructors with bad pointer targets
3
+ module m
4
+ real , target , save :: x
5
+ type t
6
+ real , pointer :: rp = > x
7
+ procedure (f), pointer , nopass :: pp = > f
8
+ end type
9
+ contains
10
+ real function f ()
11
+ f = 0 .
12
+ end
13
+ subroutine test (da , dp )
14
+ real , target :: y, da
15
+ procedure (f) dp
16
+ procedure (f), pointer :: lpp
17
+ external ext
18
+ type (t) :: a1 = t() ! ok
19
+ type (t) :: a2 = t(rp= x) ! ok
20
+ type (t) :: a3 = t(pp= f) ! ok
21
+ type (t) :: a4 = t(pp= ext) ! ok
22
+ ! ERROR: Must be a constant value
23
+ type (t) :: a5 = t(rp= y)
24
+ ! ERROR: Must be a constant value
25
+ type (t) :: a6 = t(rp= da)
26
+ ! ERROR: Must be a constant value
27
+ type (t) :: a7 = t(pp= lpp)
28
+ ! ERROR: Must be a constant value
29
+ type (t) :: a8 = t(pp= internal)
30
+ ! ERROR: Must be a constant value
31
+ type (t) :: a9 = t(pp= dp)
32
+ contains
33
+ real function internal ()
34
+ internal = 666 .
35
+ end
36
+ end
37
+ end
You can’t perform that action at this time.
0 commit comments