1 //===-- lib/Semantics/attr.cpp --------------------------------------------===//
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
7 //===----------------------------------------------------------------------===//
9 #include "flang/Semantics/attr.h"
10 #include "flang/Common/idioms.h"
11 #include "llvm/Support/raw_ostream.h"
14 namespace Fortran::semantics
{
16 void Attrs::CheckValid(const Attrs
&allowed
) const {
17 if (!allowed
.HasAll(*this)) {
18 common::die("invalid attribute");
22 std::string
AttrToString(Attr attr
) {
28 case Attr::INTENT_INOUT
:
29 return "INTENT(INOUT)";
30 case Attr::INTENT_OUT
:
33 return std::string
{EnumToString(attr
)};
37 llvm::raw_ostream
&operator<<(llvm::raw_ostream
&o
, Attr attr
) {
38 return o
<< AttrToString(attr
);
41 llvm::raw_ostream
&operator<<(llvm::raw_ostream
&o
, const Attrs
&attrs
) {
42 std::size_t n
{attrs
.count()};
44 for (std::size_t j
{0}; seen
< n
; ++j
) {
45 Attr attr
{static_cast<Attr
>(j
)};
46 if (attrs
.test(attr
)) {
56 } // namespace Fortran::semantics