namespace Fortran::semantics {
-template<class T> void suppress_unused_variable_warning(const T &) {}
-
void IfStmtChecker::Leave(const parser::IfStmt &ifStmt) {
// R1139 Check for a scalar logical expression
auto &expr{std::get<parser::ScalarLogicalExpr>(ifStmt.t).thing.thing.value()};
// C1143 Check that the action stmt is not an if stmt
const auto &body{
std::get<parser::UnlabeledStatement<parser::ActionStmt>>(ifStmt.t)};
- const auto &actionStmt{body.statement};
- if (auto *actionIfStmt{
- std::get_if<common::Indirection<parser::IfStmt>>(&actionStmt.u)}) {
- suppress_unused_variable_warning(*actionIfStmt);
+ if (std::holds_alternative<common::Indirection<parser::IfStmt>>(
+ body.statement.u)) {
context_.messages().Say(
body.source, "IF statement is not allowed in IF statement"_err_en_US);
}