File tree Expand file tree Collapse file tree 3 files changed +56
-1
lines changed Expand file tree Collapse file tree 3 files changed +56
-1
lines changed Original file line number Diff line number Diff line change @@ -464,9 +464,13 @@ struct ExtractCoindexedObjectHelper {
464
464
}
465
465
};
466
466
467
+ static inline std::optional<CoarrayRef> ExtractCoarrayRef (const DataRef &x) {
468
+ return ExtractCoindexedObjectHelper{}(x);
469
+ }
470
+
467
471
template <typename A> std::optional<CoarrayRef> ExtractCoarrayRef (const A &x) {
468
472
if (auto dataRef{ExtractDataRef (x, true )}) {
469
- return ExtractCoindexedObjectHelper{} (*dataRef);
473
+ return ExtractCoarrayRef (*dataRef);
470
474
} else {
471
475
return ExtractCoindexedObjectHelper{}(x);
472
476
}
Original file line number Diff line number Diff line change @@ -2530,6 +2530,15 @@ auto ExpressionAnalyzer::AnalyzeProcedureComponentRef(
2530
2530
return CalleeAndArguments{
2531
2531
ProcedureDesignator{*resolution}, std::move (arguments)};
2532
2532
} else if (dataRef.has_value ()) {
2533
+ if (ExtractCoarrayRef (*dataRef)) {
2534
+ if (IsProcedurePointer (*sym)) {
2535
+ Say (sc.component .source ,
2536
+ " Base of procedure component reference may not be coindexed" _err_en_US);
2537
+ } else {
2538
+ Say (sc.component .source ,
2539
+ " A procedure binding may not be coindexed unless it can be resolved at compilation time" _err_en_US);
2540
+ }
2541
+ }
2533
2542
if (sym->attrs ().test (semantics::Attr::NOPASS)) {
2534
2543
const auto *dtSpec{GetDerivedTypeSpec (dtExpr->GetType ())};
2535
2544
if (dtSpec && dtSpec->scope ()) {
Original file line number Diff line number Diff line change @@ -293,6 +293,48 @@ subroutine t2p
293
293
end
294
294
end
295
295
296
+ module m12
297
+ type t
298
+ procedure (sub), pointer , nopass :: pp
299
+ contains
300
+ procedure , non_overridable, nopass :: tbp1 = > sub
301
+ procedure , nopass :: tbp2 = > sub
302
+ generic :: gen1 = > tbp1
303
+ generic :: gen2 = > tbp2
304
+ end type
305
+ contains
306
+ subroutine sub
307
+ end
308
+ subroutine test (x , y )
309
+ class(t) :: x[* ]
310
+ type (t) :: y[* ]
311
+ call x% pp ! ok
312
+ call y% pp ! ok
313
+ ! ERROR: Base of procedure component reference may not be coindexed
314
+ call x[1 ]% pp
315
+ ! ERROR: Base of procedure component reference may not be coindexed
316
+ call y[1 ]% pp
317
+ call x% tbp1 ! ok
318
+ call y% tbp1 ! ok
319
+ call x[1 ]% tbp1 ! ok
320
+ call y[1 ]% tbp1 ! ok
321
+ call x% tbp2 ! ok
322
+ call y% tbp2 ! ok
323
+ ! ERROR: A procedure binding may not be coindexed unless it can be resolved at compilation time
324
+ call x[1 ]% tbp2
325
+ call y[1 ]% tbp2 ! ok
326
+ call x% gen1 ! ok
327
+ call y% gen1 ! ok
328
+ call x[1 ]% gen1 ! ok
329
+ call y[1 ]% gen1 ! ok
330
+ call x% gen2 ! ok
331
+ call y% gen2 ! ok
332
+ ! ERROR: A procedure binding may not be coindexed unless it can be resolved at compilation time
333
+ call x[1 ]% gen2
334
+ call y[1 ]% gen2 ! ok
335
+ end
336
+ end
337
+
296
338
program test
297
339
use m1
298
340
type,extends(t) :: t2
You can’t perform that action at this time.
0 commit comments