forked from OSchip/llvm-project
[flang] Incorperate review comments
Original-commit: flang-compiler/f18@33ff57e320 Reviewed-on: https://github.com/flang-compiler/f18/pull/196 Tree-same-pre-rewrite: false
This commit is contained in:
parent
30c7c99d54
commit
1f0b29916d
|
@ -39,15 +39,12 @@ public:
|
|||
}
|
||||
// C1136
|
||||
void Post(const parser::ReturnStmt &) {
|
||||
messages_.Say(charBlock_,
|
||||
parser::MessageFormattedText{
|
||||
"RETURN not allowed in DO CONCURRENT"_err_en_US});
|
||||
messages_.Say(charBlock_, "RETURN not allowed in DO CONCURRENT"_err_en_US);
|
||||
}
|
||||
// C1137
|
||||
void NoImageControl() {
|
||||
messages_.Say(charBlock_,
|
||||
parser::MessageFormattedText{
|
||||
"image control statement not allowed in DO CONCURRENT"_err_en_US});
|
||||
"image control statement not allowed in DO CONCURRENT"_err_en_US);
|
||||
}
|
||||
void Post(const parser::SyncAllStmt &) { NoImageControl(); }
|
||||
void Post(const parser::SyncImagesStmt &) { NoImageControl(); }
|
||||
|
@ -66,64 +63,54 @@ public:
|
|||
void Post(const parser::AllocateStmt &) {
|
||||
if (anyObjectIsCoarray()) {
|
||||
messages_.Say(charBlock_,
|
||||
parser::MessageFormattedText{
|
||||
"ALLOCATE coarray not allowed in DO CONCURRENT"_err_en_US});
|
||||
"ALLOCATE coarray not allowed in DO CONCURRENT"_err_en_US);
|
||||
}
|
||||
}
|
||||
void Post(const parser::DeallocateStmt &) {
|
||||
if (anyObjectIsCoarray()) {
|
||||
messages_.Say(charBlock_,
|
||||
parser::MessageFormattedText{
|
||||
"DEALLOCATE coarray not allowed in DO CONCURRENT"_err_en_US});
|
||||
"DEALLOCATE coarray not allowed in DO CONCURRENT"_err_en_US);
|
||||
}
|
||||
// C1140: deallocation of polymorphic objects
|
||||
if (anyObjectIsPolymorphic()) {
|
||||
messages_.Say(charBlock_,
|
||||
parser::MessageFormattedText{
|
||||
"DEALLOCATE polymorphic object(s)"
|
||||
" not allowed in DO CONCURRENT"_err_en_US});
|
||||
"DEALLOCATE polymorphic object(s) not allowed"
|
||||
" in DO CONCURRENT"_err_en_US);
|
||||
}
|
||||
}
|
||||
template<typename T> void Post(const parser::Statement<T> &) {
|
||||
if (EndTDeallocatesCoarray()) {
|
||||
messages_.Say(charBlock_,
|
||||
parser::MessageFormattedText{
|
||||
"implicit deallocation of coarray not allowed"
|
||||
" in DO CONCURRENT"_err_en_US});
|
||||
"implicit deallocation of coarray not allowed"
|
||||
" in DO CONCURRENT"_err_en_US);
|
||||
}
|
||||
}
|
||||
// C1141: cannot call ieee_get_flag, ieee_[gs]et_halting_mode
|
||||
void Post(const parser::ProcedureDesignator &procedureDesignator) {
|
||||
if (auto *name{std::get_if<parser::Name>(&procedureDesignator.u)}) {
|
||||
// C1137: call move_alloc with coarray arguments
|
||||
if (parser::ToUpperCaseLetters(name->ToString()) == "MOVE_ALLOC"s) {
|
||||
if (name->ToString() == "move_alloc"s) {
|
||||
if (anyObjectIsCoarray()) {
|
||||
messages_.Say(charBlock_,
|
||||
parser::MessageFormattedText{
|
||||
"call to MOVE_ALLOC intrinsic in DO CONCURRENT with coarray"
|
||||
" argument(s) not allowed"_err_en_US});
|
||||
"call to MOVE_ALLOC intrinsic in DO CONCURRENT with coarray"
|
||||
" argument(s) not allowed"_err_en_US);
|
||||
}
|
||||
}
|
||||
// C1139: call to impure procedure
|
||||
if (name->symbol && !isPure(name->symbol->attrs())) {
|
||||
messages_.Say(charBlock_,
|
||||
parser::MessageFormattedText{"call to impure subroutine in DO"
|
||||
" CONCURRENT not allowed"_err_en_US});
|
||||
"call to impure subroutine in DO CONCURRENT not allowed"_err_en_US);
|
||||
}
|
||||
if (name->symbol && fromScope(*name->symbol, "IEEE_EXCEPTIONS"s)) {
|
||||
auto upperName{parser::ToUpperCaseLetters(name->ToString())};
|
||||
if (upperName == "IEEE_GET_FLAG"s) {
|
||||
if (name->symbol && fromScope(*name->symbol, "ieee_exceptions"s)) {
|
||||
if (name->ToString() == "ieee_get_flag"s) {
|
||||
messages_.Say(charBlock_,
|
||||
parser::MessageFormattedText{
|
||||
"IEEE_GET_FLAG not allowed in DO CONCURRENT"_err_en_US});
|
||||
} else if (upperName == "IEEE_SET_HALTING_MODE"s) {
|
||||
"IEEE_GET_FLAG not allowed in DO CONCURRENT"_err_en_US);
|
||||
} else if (name->ToString() == "ieee_set_halting_mode"s) {
|
||||
messages_.Say(charBlock_,
|
||||
parser::MessageFormattedText{"IEEE_SET_HALTING_MODE not allowed"
|
||||
" in DO CONCURRENT"_err_en_US});
|
||||
} else if (upperName == "IEEE_GET_HALTING_MODE"s) {
|
||||
"IEEE_SET_HALTING_MODE not allowed in DO CONCURRENT"_err_en_US);
|
||||
} else if (name->ToString() == "ieee_get_halting_mode"s) {
|
||||
messages_.Say(charBlock_,
|
||||
parser::MessageFormattedText{"IEEE_GET_HALTING_MODE not allowed"
|
||||
" in DO CONCURRENT"_err_en_US});
|
||||
"IEEE_GET_HALTING_MODE not allowed in DO CONCURRENT"_err_en_US);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -132,8 +119,7 @@ public:
|
|||
.v.thing.component};
|
||||
if (component.symbol && !isPure(component.symbol->attrs())) {
|
||||
messages_.Say(charBlock_,
|
||||
parser::MessageFormattedText{"call to impure subroutine in DO"
|
||||
" CONCURRENT not allowed"_err_en_US});
|
||||
"call to impure subroutine in DO CONCURRENT not allowed"_err_en_US);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -145,8 +131,7 @@ public:
|
|||
if (std::get<parser::IoControlSpec::CharExpr::Kind>(charExpr->t) ==
|
||||
parser::IoControlSpec::CharExpr::Kind::Advance) {
|
||||
messages_.Say(charBlock_,
|
||||
parser::MessageFormattedText{
|
||||
"ADVANCE specifier not allowed in DO CONCURRENT"_err_en_US});
|
||||
"ADVANCE specifier not allowed in DO CONCURRENT"_err_en_US);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -156,13 +141,12 @@ private:
|
|||
bool anyObjectIsPolymorphic() { return false; } // placeholder
|
||||
bool EndTDeallocatesCoarray() { return false; } // placeholder
|
||||
bool isPure(Attrs &attrs) {
|
||||
return attrs.HasAny({Attr::PURE}) ||
|
||||
(attrs.HasAny({Attr::ELEMENTAL}) && !attrs.HasAny({Attr::IMPURE}));
|
||||
return attrs.test(Attr::PURE) ||
|
||||
(attrs.test(Attr::ELEMENTAL) && !attrs.test(Attr::IMPURE));
|
||||
}
|
||||
bool fromScope(const Symbol &symbol, const std::string &moduleName) {
|
||||
if (symbol.scope() && symbol.scope()->IsModule()) {
|
||||
if (parser::ToUpperCaseLetters(
|
||||
symbol.scope()->symbol()->name().ToString()) == moduleName) {
|
||||
if (symbol.scope()->symbol()->name().ToString() == moduleName) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -175,9 +159,10 @@ private:
|
|||
};
|
||||
|
||||
class DoConcurrentLabelEnforce {
|
||||
public:
|
||||
DoConcurrentLabelEnforce(
|
||||
parser::Messages &messages, std::set<parser::Label> &&labels)
|
||||
: messages_{messages}, labels_{labels} {}
|
||||
: messages_{messages}, labels_{labels} {}
|
||||
template<typename T> bool Pre(const T &) { return true; }
|
||||
template<typename T> bool Pre(const parser::Statement<T> &statement) {
|
||||
charBlock_ = statement.source;
|
||||
|
@ -213,9 +198,8 @@ class DoConcurrentLabelEnforce {
|
|||
void Post(const parser::EorLabel &eorLabel) { checkLabelUse(eorLabel.v); }
|
||||
void checkLabelUse(const parser::Label &labelUsed) {
|
||||
if (labels_.find(labelUsed) == labels_.end()) {
|
||||
messages_.Say(charBlock_,
|
||||
parser::MessageFormattedText{
|
||||
"control flow escapes from DO CONCURRENT"_err_en_US});
|
||||
messages_.Say(
|
||||
charBlock_, "control flow escapes from DO CONCURRENT"_err_en_US);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue