[flang-commits] [PATCH] D146577: [flang] Fix check for PRIVATE override of PUBLIC t.b.p.
Peter Klausler via Phabricator via flang-commits
flang-commits at lists.llvm.org
Tue Mar 21 15:08:07 PDT 2023
klausler created this revision.
klausler added a reviewer: PeteSteinfeld.
klausler added a project: Flang.
Herald added subscribers: sunshaoce, jdoerfert.
Herald added a project: All.
klausler requested review of this revision.
A PRIVATE procedure binding in a derived type extension may not
be an override of a PUBLIC procedure binding. Declaration checking
for this case was working only in the presence of an explicit
PUBLIC accessibility attribute, when it should be checking for the
absence of a PRIVATE accessibility attribute.
https://reviews.llvm.org/D146577
Files:
flang/lib/Semantics/check-declarations.cpp
flang/test/Semantics/bindings01.f90
Index: flang/test/Semantics/bindings01.f90
===================================================================
--- flang/test/Semantics/bindings01.f90
+++ flang/test/Semantics/bindings01.f90
@@ -275,6 +275,24 @@
end subroutine
end module
+module m11
+ type t1
+ contains
+ procedure, nopass :: tbp => t1p
+ end type
+ type, extends(t1) :: t2
+ contains
+ private
+ !ERROR: A PRIVATE procedure may not override a PUBLIC procedure
+ procedure, nopass :: tbp => t2p
+ end type
+ contains
+ subroutine t1p
+ end
+ subroutine t2p
+ end
+end
+
program test
use m1
type,extends(t) :: t2
Index: flang/lib/Semantics/check-declarations.cpp
===================================================================
--- flang/lib/Semantics/check-declarations.cpp
+++ flang/lib/Semantics/check-declarations.cpp
@@ -1948,7 +1948,7 @@
if (FindModuleContaining(dtScope) ==
FindModuleContaining(overridden->owner())) {
// types declared in same madule
- if (overridden->attrs().test(Attr::PUBLIC)) {
+ if (!overridden->attrs().test(Attr::PRIVATE)) {
SayWithDeclaration(*overridden,
"A PRIVATE procedure may not override a PUBLIC procedure"_err_en_US);
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D146577.507147.patch
Type: text/x-patch
Size: 1260 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20230321/324c636c/attachment-0001.bin>
More information about the flang-commits
mailing list