[flang] Changes in SaveStmt message for Common Block name specifier

Original-commit: flang-compiler/f18@2e63705f5c
Reviewed-on: https://github.com/flang-compiler/f18/pull/584
Tree-same-pre-rewrite: false
This commit is contained in:
Caroline Concatto 2019-07-23 10:29:53 +01:00
parent 6975bc3dd4
commit 23b0337598
2 changed files with 14 additions and 12 deletions

View file

@ -3615,7 +3615,7 @@ void DeclarationVisitor::Post(const parser::CommonBlockObject &x) {
bool DeclarationVisitor::Pre(const parser::EquivalenceStmt &x) { bool DeclarationVisitor::Pre(const parser::EquivalenceStmt &x) {
// save equivalence sets to be processed after specification part // save equivalence sets to be processed after specification part
CheckNotInBlock("EQUIVALENCE"); CheckNotInBlock("EQUIVALENCE"); // C1107
for (const std::list<parser::EquivalenceObject> &set : x.v) { for (const std::list<parser::EquivalenceObject> &set : x.v) {
equivalenceSets_.push_back(&set); equivalenceSets_.push_back(&set);
} }
@ -3656,12 +3656,8 @@ bool DeclarationVisitor::Pre(const parser::SaveStmt &x) {
auto kind{std::get<parser::SavedEntity::Kind>(y.t)}; auto kind{std::get<parser::SavedEntity::Kind>(y.t)};
const auto &name{std::get<parser::Name>(y.t)}; const auto &name{std::get<parser::Name>(y.t)};
if (kind == parser::SavedEntity::Kind::Common) { if (kind == parser::SavedEntity::Kind::Common) {
if (currScope().kind() == Scope::Kind::Block) { MakeCommonBlockSymbol(name);
CheckNotInBlock("COMMON BLOCK NAME"); // C1107 AddSaveName(saveInfo_.commons, name.source);
} else {
MakeCommonBlockSymbol(name);
AddSaveName(saveInfo_.commons, name.source);
}
} else { } else {
HandleAttributeStmt(Attr::SAVE, name); HandleAttributeStmt(Attr::SAVE, name);
} }
@ -3689,10 +3685,16 @@ void DeclarationVisitor::CheckSaveStmts() {
for (const SourceName &name : saveInfo_.commons) { for (const SourceName &name : saveInfo_.commons) {
if (auto *symbol{currScope().FindCommonBlock(name)}) { if (auto *symbol{currScope().FindCommonBlock(name)}) {
auto &objects{symbol->get<CommonBlockDetails>().objects()}; auto &objects{symbol->get<CommonBlockDetails>().objects()};
if (objects.empty() && currScope().kind() != Scope::Kind::Block) { if (objects.empty()) {
Say(name, if (currScope().kind() != Scope::Kind::Block) {
"'%s' appears as a COMMON block in a SAVE statement but not in" Say(name,
" a COMMON statement"_err_en_US); "'%s' appears as a COMMON block in a SAVE statement but not in"
" a COMMON statement"_err_en_US);
} else { // C1108
Say(name,
"'%s' specifier is not allowed in a BLOCK Construct."
" It is a Common Block Name"_err_en_US);
}
} else { } else {
for (Symbol *object : symbol->get<CommonBlockDetails>().objects()) { for (Symbol *object : symbol->get<CommonBlockDetails>().objects()) {
SetSaveAttr(*object); SetSaveAttr(*object);

View file

@ -22,7 +22,7 @@ program main
!ERROR: 'argmnt1' appears as a COMMON block in a SAVE statement but not in a COMMON statement !ERROR: 'argmnt1' appears as a COMMON block in a SAVE statement but not in a COMMON statement
save /argmnt1/ save /argmnt1/
block block
!ERROR: COMMON BLOCK NAME statement is not allowed in a BLOCK construct !ERROR: 'argmnt2' specifier is not allowed in a BLOCK Construct. It is a Common Block Name
save /argmnt2/ save /argmnt2/
end block end block
end program end program