const auto &firstStmt{std::get<parser::Statement<FIRST>>(a.t)};
if (const parser::CharBlock * firstName{GetStmtName(firstStmt)}) {
if (*firstName != *name) {
- context_
- .Say(*name,
- parser::MessageFormattedText{
- "%s name mismatch"_err_en_US, constructTag})
+ context_.Say(*name, "%s name mismatch"_err_en_US, constructTag)
.Attach(*firstName, "should be"_en_US);
}
} else {
- context_
- .Say(*name,
- parser::MessageFormattedText{
- "%s name not allowed"_err_en_US, constructTag})
+ context_.Say(*name, "%s name not allowed"_err_en_US, constructTag)
.Attach(firstStmt.source, "in unnamed %s"_en_US, constructTag);
}
}
// C1502
void Post(const parser::InterfaceBlock &interfaceBlock) {
- auto &interfaceStmt{
- std::get<parser::Statement<parser::InterfaceStmt>>(interfaceBlock.t)};
- if (const auto *optionalGenericSpecPointer{
- std::get_if<std::optional<parser::GenericSpec>>(
- &interfaceStmt.statement.u)}) {
- if (*optionalGenericSpecPointer) {
- if (const auto *namePointer{
- std::get_if<parser::Name>(&(*optionalGenericSpecPointer)->u)}) {
- auto &optionalGenericSpec{
- std::get<parser::Statement<parser::EndInterfaceStmt>>(
- interfaceBlock.t)
- .statement.v};
- if (optionalGenericSpec) {
- if (const auto *otherPointer{
- std::get_if<parser::Name>(&optionalGenericSpec->u)}) {
- if (namePointer->source != otherPointer->source) {
- context_
- .Say(currentPosition_,
- parser::MessageFormattedText{
- "INTERFACE generic-name (%s) mismatch"_err_en_US,
- namePointer->source})
- .Attach(interfaceStmt.source, "mismatched INTERFACE"_en_US);
- }
- }
+ if (const auto &endGenericSpec{
+ std::get<parser::Statement<parser::EndInterfaceStmt>>(
+ interfaceBlock.t)
+ .statement.v}) {
+ const auto &interfaceStmt{
+ std::get<parser::Statement<parser::InterfaceStmt>>(interfaceBlock.t)};
+ if (std::holds_alternative<parser::Abstract>(interfaceStmt.statement.u)) {
+ context_
+ .Say(endGenericSpec->source,
+ "END INTERFACE generic name (%s) may not appear for ABSTRACT INTERFACE"_err_en_US,
+ endGenericSpec->source)
+ .Attach(
+ interfaceStmt.source, "corresponding ABSTRACT INTERFACE"_en_US);
+ } else if (const auto &genericSpec{
+ std::get<std::optional<parser::GenericSpec>>(
+ interfaceStmt.statement.u)}) {
+ bool ok{genericSpec->source == endGenericSpec->source};
+ if (!ok) {
+ // Accept variant spellings of .LT. &c.
+ const auto *endOp{
+ std::get_if<parser::DefinedOperator>(&endGenericSpec->u)};
+ const auto *op{std::get_if<parser::DefinedOperator>(&genericSpec->u)};
+ if (endOp && op) {
+ const auto *endIntrin{
+ std::get_if<parser::DefinedOperator::IntrinsicOperator>(
+ &endOp->u)};
+ const auto *intrin{
+ std::get_if<parser::DefinedOperator::IntrinsicOperator>(
+ &op->u)};
+ ok = endIntrin && intrin && *endIntrin == *intrin;
}
}
+ if (!ok) {
+ context_
+ .Say(endGenericSpec->source,
+ "END INTERFACE generic name (%s) does not match generic INTERFACE (%s)"_err_en_US,
+ endGenericSpec->source, genericSpec->source)
+ .Attach(genericSpec->source, "corresponding INTERFACE"_en_US);
+ }
+ } else {
+ context_
+ .Say(endGenericSpec->source,
+ "END INTERFACE generic name (%s) may not appear for non-generic INTERFACE"_err_en_US,
+ endGenericSpec->source)
+ .Attach(interfaceStmt.source, "corresponding INTERFACE"_en_US);
}
}
}
}
} else {
context_.Say(*endName,
- parser::MessageFormattedText{
- "END PROGRAM has name without PROGRAM statement"_err_en_US});
+ "END PROGRAM has name without PROGRAM statement"_err_en_US);
}
}
}
if (endName) {
if (*constructName != *endName) {
context_
- .Say(*endName,
- parser::MessageFormattedText{
- "%s construct name mismatch"_err_en_US, constructTag})
+ .Say(*endName, "%s construct name mismatch"_err_en_US,
+ constructTag)
.Attach(*constructName, "should be"_en_US);
}
} else {
context_
.Say(endStmt.source,
- parser::MessageFormattedText{
- "%s construct name required but missing"_err_en_US,
- constructTag})
+ "%s construct name required but missing"_err_en_US,
+ constructTag)
.Attach(*constructName, "should be"_en_US);
}
} else if (endName) {
context_
- .Say(*endName,
- parser::MessageFormattedText{
- "%s construct name unexpected"_err_en_US, constructTag})
+ .Say(*endName, "%s construct name unexpected"_err_en_US, constructTag)
.Attach(
constructStmt.source, "unnamed %s statement"_en_US, constructTag);
}
const auto iter{std::find(constructNames_.crbegin(),
constructNames_.crend(), constructName.ToString())};
if (iter == constructNames_.crend()) {
- context_.Say(constructName,
- parser::MessageFormattedText{
- "%s construct-name is not in scope"_err_en_US, stmtString});
+ context_.Say(constructName, "%s construct-name is not in scope"_err_en_US,
+ stmtString);
}
}
// 6.2.5, paragraph 2
void CheckLabelInRange(parser::Label label) {
if (label < 1 || label > 99999) {
- context_.Say(currentPosition_,
- parser::MessageFormattedText{
- "Label '%u' is out of range"_err_en_US, SayLabel(label)});
+ context_.Say(currentPosition_, "Label '%u' is out of range"_err_en_US,
+ SayLabel(label));
}
}
LabeledStatementInfoTuplePOD{scope, currentPosition_,
labeledStmtClassificationSet, isExecutableConstructEndStmt})};
if (!pair.second) {
- context_.Say(currentPosition_,
- parser::MessageFormattedText{
- "Label '%u' is not distinct"_err_en_US, SayLabel(label)});
+ context_.Say(currentPosition_, "Label '%u' is not distinct"_err_en_US,
+ SayLabel(label));
}
}
std::vector<UnitAnalysis> programUnits_;
SemanticsContext &context_;
- parser::CharBlock currentPosition_{nullptr};
+ parser::CharBlock currentPosition_;
ProxyForScope currentScope_;
std::vector<std::string> constructNames_;
};
auto doTarget{GetLabel(labels, label)};
if (!HasScope(doTarget.proxyForScope)) {
// C1133
- context.Say(position,
- parser::MessageFormattedText{
- "Label '%u' cannot be found"_err_en_US, SayLabel(label)});
+ context.Say(
+ position, "Label '%u' cannot be found"_err_en_US, SayLabel(label));
} else if (doTarget.parserCharBlock.begin() < position.begin()) {
// R1119
context.Say(position,
- parser::MessageFormattedText{
- "Label '%u' doesn't lexically follow DO stmt"_err_en_US,
- SayLabel(label)});
+ "Label '%u' doesn't lexically follow DO stmt"_err_en_US,
+ SayLabel(label));
} else if ((InInclusiveScope(scopes, scope, doTarget.proxyForScope) &&
doTarget.labeledStmtClassificationSet.test(
common::LanguageFeature::OldLabelDoEndStatements)) {
context
.Say(position,
- parser::MessageFormattedText{
- "A DO loop should terminate with an END DO or CONTINUE"_en_US})
+ "A DO loop should terminate with an END DO or CONTINUE"_en_US)
.Attach(doTarget.parserCharBlock,
"DO loop currently ends at statement:"_en_US);
}
} else if (!InInclusiveScope(scopes, scope, doTarget.proxyForScope)) {
- context.Say(position,
- parser::MessageFormattedText{
- "Label '%u' is not in DO loop scope"_err_en_US, SayLabel(label)});
+ context.Say(position, "Label '%u' is not in DO loop scope"_err_en_US,
+ SayLabel(label));
} else if (!doTarget.labeledStmtClassificationSet.test(
TargetStatementEnum::Do)) {
context.Say(doTarget.parserCharBlock,
- parser::MessageFormattedText{
- "A DO loop should terminate with an END DO or CONTINUE"_err_en_US});
+ "A DO loop should terminate with an END DO or CONTINUE"_err_en_US);
} else {
loopBodies.emplace_back(SkipLabel(position), doTarget.parserCharBlock);
}
const auto &position{stmt.parserCharBlock};
auto target{GetLabel(labels, label)};
if (!HasScope(target.proxyForScope)) {
- context.Say(position,
- parser::MessageFormattedText{
- "Label '%u' was not found"_err_en_US, SayLabel(label)});
+ context.Say(
+ position, "Label '%u' was not found"_err_en_US, SayLabel(label));
} else if (!InInclusiveScope(scopes, scope, target.proxyForScope)) {
// Clause 11.1.2.1 prohibits transfer of control to the interior of a
// block from outside the block, but this does not apply to formats.
TargetStatementEnum::Format)) {
continue;
}
- context.Say(position,
- parser::MessageFormattedText{
- "Label '%u' is not in scope"_en_US, SayLabel(label)});
+ context.Say(
+ position, "Label '%u' is not in scope"_en_US, SayLabel(label));
}
}
}
TargetStatementEnum::CompatibleBranch)) { // error
context
.Say(branchTarget.parserCharBlock,
- parser::MessageFormattedText{
- "Label '%u' is not a branch target"_err_en_US,
- SayLabel(label)})
- .Attach(stmt.parserCharBlock,
- parser::MessageFormattedText{
- "Control flow use of '%u'"_en_US, SayLabel(label)});
+ "Label '%u' is not a branch target"_err_en_US, SayLabel(label))
+ .Attach(stmt.parserCharBlock, "Control flow use of '%u'"_en_US,
+ SayLabel(label));
} else if (!branchTarget.labeledStmtClassificationSet.test(
TargetStatementEnum::Branch)) { // warning
context
.Say(branchTarget.parserCharBlock,
- parser::MessageFormattedText{
- "Label '%u' is not a branch target"_en_US, SayLabel(label)})
- .Attach(stmt.parserCharBlock,
- parser::MessageFormattedText{
- "Control flow use of '%u'"_en_US, SayLabel(label)});
+ "Label '%u' is not a branch target"_en_US, SayLabel(label))
+ .Attach(stmt.parserCharBlock, "Control flow use of '%u'"_en_US,
+ SayLabel(label));
}
}
}
if (!ioTarget.labeledStmtClassificationSet.test(
TargetStatementEnum::Format)) {
context
- .Say(ioTarget.parserCharBlock,
- parser::MessageFormattedText{
- "'%u' not a FORMAT"_err_en_US, SayLabel(label)})
- .Attach(stmt.parserCharBlock,
- parser::MessageFormattedText{
- "data transfer use of '%u'"_en_US, SayLabel(label)});
+ .Say(ioTarget.parserCharBlock, "'%u' not a FORMAT"_err_en_US,
+ SayLabel(label))
+ .Attach(stmt.parserCharBlock, "data transfer use of '%u'"_en_US,
+ SayLabel(label));
}
}
}