forked from OSchip/llvm-project
[flang] Fix a couple bugs with SELECT TYPE(p) from regression tests
Original-commit: flang-compiler/f18@7539a01ecd Reviewed-on: https://github.com/flang-compiler/f18/pull/508 Tree-same-pre-rewrite: false
This commit is contained in:
parent
cfcebc54e2
commit
40b1cc9b62
|
@ -4097,8 +4097,15 @@ void ConstructVisitor::Post(const parser::SelectTypeStmt &x) {
|
|||
MakePlaceholder(*name, MiscDetails::Kind::SelectTypeAssociateName);
|
||||
association_.name = &*name;
|
||||
} else {
|
||||
const Symbol *whole{UnwrapWholeSymbolDataRef(association_.selector.expr)};
|
||||
if (!whole || !whole->has<ObjectEntityDetails>()) {
|
||||
if (const Symbol *
|
||||
whole{UnwrapWholeSymbolDataRef(association_.selector.expr)}) {
|
||||
ConvertToObjectEntity(const_cast<Symbol &>(*whole));
|
||||
if (!IsVariableName(*whole)) {
|
||||
Say(association_.selector.source, // C901
|
||||
"Selector is not a variable"_err_en_US);
|
||||
association_ = {};
|
||||
}
|
||||
} else {
|
||||
Say(association_.selector.source, // C1157
|
||||
"Selector is not a named variable: 'associate-name =>' is required"_err_en_US);
|
||||
association_ = {};
|
||||
|
@ -4141,21 +4148,26 @@ void ConstructVisitor::CheckRef(const std::optional<parser::Name> &x) {
|
|||
|
||||
// Make a symbol representing an associating entity from association_.
|
||||
Symbol *ConstructVisitor::MakeAssocEntity() {
|
||||
if (!association_.name) {
|
||||
return nullptr;
|
||||
}
|
||||
auto &symbol{MakeSymbol(*association_.name, UnknownDetails{})};
|
||||
if (symbol.has<AssocEntityDetails>() && symbol.owner() == currScope()) {
|
||||
Say(*association_.name, // C1104
|
||||
"The associate name '%s' is already used in this associate statement"_err_en_US);
|
||||
Symbol *symbol{nullptr};
|
||||
if (association_.name) {
|
||||
symbol = &MakeSymbol(*association_.name, UnknownDetails{});
|
||||
if (symbol->has<AssocEntityDetails>() && symbol->owner() == currScope()) {
|
||||
Say(*association_.name, // C1104
|
||||
"The associate name '%s' is already used in this associate statement"_err_en_US);
|
||||
return nullptr;
|
||||
}
|
||||
} else if (const Symbol *
|
||||
whole{UnwrapWholeSymbolDataRef(association_.selector.expr)}) {
|
||||
symbol = &MakeSymbol(whole->name());
|
||||
} else {
|
||||
return nullptr;
|
||||
}
|
||||
if (auto &expr{association_.selector.expr}) {
|
||||
symbol.set_details(AssocEntityDetails{common::Clone(*expr)});
|
||||
symbol->set_details(AssocEntityDetails{common::Clone(*expr)});
|
||||
} else {
|
||||
symbol.set_details(AssocEntityDetails{});
|
||||
symbol->set_details(AssocEntityDetails{});
|
||||
}
|
||||
return &symbol;
|
||||
return symbol;
|
||||
}
|
||||
|
||||
// Set the type of symbol based on the current association selector.
|
||||
|
|
Loading…
Reference in New Issue