[lldb] Add ability to hide the root name of a value
[llvm-project.git] / flang / lib / Semantics / check-namelist.cpp
blob630840ab5d92d880fb2334be452adfcc64e50918
1 //===-- lib/Semantics/check-namelist.cpp ----------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
9 #include "check-namelist.h"
11 namespace Fortran::semantics {
13 void NamelistChecker::Leave(const parser::NamelistStmt &nmlStmt) {
14 for (const auto &x : nmlStmt.v) {
15 if (const auto *nml{std::get<parser::Name>(x.t).symbol}) {
16 for (const auto &nmlObjName : std::get<std::list<parser::Name>>(x.t)) {
17 const auto *nmlObjSymbol{nmlObjName.symbol};
18 if (nmlObjSymbol && nmlObjSymbol->has<ObjectEntityDetails>()) {
19 const auto *symDetails{
20 std::get_if<ObjectEntityDetails>(&nmlObjSymbol->details())};
21 if (symDetails && symDetails->IsAssumedSize()) { // C8104
22 context_.Say(nmlObjName.source,
23 "A namelist group object '%s' must not be"
24 " assumed-size"_err_en_US,
25 nmlObjSymbol->name());
27 if (nml->attrs().test(Attr::PUBLIC) &&
28 nmlObjSymbol->attrs().test(Attr::PRIVATE)) { // C8105
29 context_.Say(nmlObjName.source,
30 "A PRIVATE namelist group object '%s' must not be in a "
31 "PUBLIC namelist"_err_en_US,
32 nmlObjSymbol->name());
40 } // namespace Fortran::semantics