Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions flang/lib/Semantics/resolve-names.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7294,17 +7294,20 @@ bool DeclarationVisitor::OkToAddComponent(
std::optional<parser::MessageFixedText> msg;
std::optional<common::UsageWarning> warning;
if (context().HasError(*prev)) { // don't pile on
} else if (extends) {
msg = "Type cannot be extended as it has a component named"
" '%s'"_err_en_US;
} else if (CheckAccessibleSymbol(currScope(), *prev)) {
// inaccessible component -- redeclaration is ok
if (context().ShouldWarn(
common::UsageWarning::RedeclaredInaccessibleComponent)) {
if (extends) {
// The parent type has a component of same name, but it remains
// extensible outside its module since that component is PRIVATE.
} else if (context().ShouldWarn(
common::UsageWarning::RedeclaredInaccessibleComponent)) {
msg =
"Component '%s' is inaccessibly declared in or as a parent of this derived type"_warn_en_US;
warning = common::UsageWarning::RedeclaredInaccessibleComponent;
}
} else if (extends) {
msg =
"Type cannot be extended as it has a component named '%s'"_err_en_US;
} else if (prev->test(Symbol::Flag::ParentComp)) {
msg =
"'%s' is a parent type of this type and so cannot be a component"_err_en_US;
Expand Down
5 changes: 5 additions & 0 deletions flang/test/Semantics/resolve34.f90
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ module m4
type, extends(t1) :: t2
end type
end
module m4a
use m4
type, extends(t1) :: t3 ! ok, inaccessible component
end type
end

module m5
type :: t1
Expand Down