File tree Expand file tree Collapse file tree 4 files changed +46
-5
lines changed Expand file tree Collapse file tree 4 files changed +46
-5
lines changed Original file line number Diff line number Diff line change @@ -53,7 +53,8 @@ const Symbol *FindPointerComponent(const Symbol &);
53
53
const Symbol *FindInterface (const Symbol &);
54
54
const Symbol *FindSubprogram (const Symbol &);
55
55
const Symbol *FindFunctionResult (const Symbol &);
56
- const Symbol *FindOverriddenBinding (const Symbol &);
56
+ const Symbol *FindOverriddenBinding (
57
+ const Symbol &, bool &isInaccessibleDeferred);
57
58
const Symbol *FindGlobal (const Symbol &);
58
59
59
60
const DeclTypeSpec *FindParentTypeSpec (const DerivedTypeSpec &);
Original file line number Diff line number Diff line change @@ -2346,7 +2346,14 @@ void CheckHelper::CheckProcBinding(
2346
2346
" Intrinsic procedure '%s' is not a specific intrinsic permitted for use in the definition of binding '%s'" _err_en_US,
2347
2347
binding.symbol ().name (), symbol.name ());
2348
2348
}
2349
- if (const Symbol *overridden{FindOverriddenBinding (symbol)}) {
2349
+ bool isInaccessibleDeferred{false };
2350
+ if (const Symbol *
2351
+ overridden{FindOverriddenBinding (symbol, isInaccessibleDeferred)}) {
2352
+ if (isInaccessibleDeferred) {
2353
+ SayWithDeclaration (*overridden,
2354
+ " Override of PRIVATE DEFERRED '%s' must appear in its module" _err_en_US,
2355
+ symbol.name ());
2356
+ }
2350
2357
if (overridden->attrs ().test (Attr::NON_OVERRIDABLE)) {
2351
2358
SayWithDeclaration (*overridden,
2352
2359
" Override of NON_OVERRIDABLE '%s' is not permitted" _err_en_US,
Original file line number Diff line number Diff line change @@ -528,7 +528,9 @@ const Symbol *FindSubprogram(const Symbol &symbol) {
528
528
symbol.details ());
529
529
}
530
530
531
- const Symbol *FindOverriddenBinding (const Symbol &symbol) {
531
+ const Symbol *FindOverriddenBinding (
532
+ const Symbol &symbol, bool &isInaccessibleDeferred) {
533
+ isInaccessibleDeferred = false ;
532
534
if (symbol.has <ProcBindingDetails>()) {
533
535
if (const DeclTypeSpec * parentType{FindParentTypeSpec (symbol.owner ())}) {
534
536
if (const DerivedTypeSpec * parentDerived{parentType->AsDerived ()}) {
@@ -537,8 +539,11 @@ const Symbol *FindOverriddenBinding(const Symbol &symbol) {
537
539
overridden{parentScope->FindComponent (symbol.name ())}) {
538
540
// 7.5.7.3 p1: only accessible bindings are overridden
539
541
if (!overridden->attrs ().test (Attr::PRIVATE) ||
540
- (FindModuleContaining (overridden->owner ()) ==
541
- FindModuleContaining (symbol.owner ()))) {
542
+ FindModuleContaining (overridden->owner ()) ==
543
+ FindModuleContaining (symbol.owner ())) {
544
+ return overridden;
545
+ } else if (overridden->attrs ().test (Attr::DEFERRED)) {
546
+ isInaccessibleDeferred = true ;
542
547
return overridden;
543
548
}
544
549
}
Original file line number Diff line number Diff line change
1
+ ! RUN: %python %S/test_errors.py %s %flang_fc1
2
+ ! Deferred TBPs must be overridden, but when they are private, those
3
+ ! overrides must appear in the same module.
4
+ module m1
5
+ type, abstract :: absBase
6
+ contains
7
+ procedure (deferredInterface), deferred, private :: deferredTbp
8
+ end type
9
+ abstract interface
10
+ subroutine deferredInterface (x )
11
+ import absBase
12
+ class(absBase), intent (in ) :: x
13
+ end
14
+ end interface
15
+ end
16
+
17
+ module m2
18
+ use m1
19
+ type, extends(absBase) :: ext
20
+ contains
21
+ ! ERROR: Override of PRIVATE DEFERRED 'deferredtbp' must appear in its module
22
+ procedure :: deferredTbp = > implTbp
23
+ end type
24
+ contains
25
+ subroutine implTbp (x )
26
+ class(ext), intent (in ) :: x
27
+ end
28
+ end
You can’t perform that action at this time.
0 commit comments