xref: /llvm-project/flang/lib/Semantics/check-if-stmt.cpp (revision b98ad941a40c96c841bceb171725c925500fce6c)
1*64ab3302SCarolineConcatto //===-- lib/Semantics/check-if-stmt.cpp -----------------------------------===//
2*64ab3302SCarolineConcatto //
3*64ab3302SCarolineConcatto // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4*64ab3302SCarolineConcatto // See https://llvm.org/LICENSE.txt for license information.
5*64ab3302SCarolineConcatto // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6*64ab3302SCarolineConcatto //
7*64ab3302SCarolineConcatto //===----------------------------------------------------------------------===//
8*64ab3302SCarolineConcatto 
9*64ab3302SCarolineConcatto #include "check-if-stmt.h"
10*64ab3302SCarolineConcatto #include "flang/Parser/message.h"
11*64ab3302SCarolineConcatto #include "flang/Parser/parse-tree.h"
12*64ab3302SCarolineConcatto #include "flang/Semantics/tools.h"
13*64ab3302SCarolineConcatto 
14*64ab3302SCarolineConcatto namespace Fortran::semantics {
15*64ab3302SCarolineConcatto 
Leave(const parser::IfStmt & ifStmt)16*64ab3302SCarolineConcatto void IfStmtChecker::Leave(const parser::IfStmt &ifStmt) {
17*64ab3302SCarolineConcatto   // C1143 Check that the action stmt is not an if stmt
18*64ab3302SCarolineConcatto   const auto &body{
19*64ab3302SCarolineConcatto       std::get<parser::UnlabeledStatement<parser::ActionStmt>>(ifStmt.t)};
20*64ab3302SCarolineConcatto   if (std::holds_alternative<common::Indirection<parser::IfStmt>>(
21*64ab3302SCarolineConcatto           body.statement.u)) {
22*64ab3302SCarolineConcatto     context_.Say(
23*64ab3302SCarolineConcatto         body.source, "IF statement is not allowed in IF statement"_err_en_US);
24*64ab3302SCarolineConcatto   }
25*64ab3302SCarolineConcatto }
26*64ab3302SCarolineConcatto 
27*64ab3302SCarolineConcatto } // namespace Fortran::semantics
28