2018-05-01 21:50:34 +02:00
|
|
|
// Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
//
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
|
2018-05-01 23:07:52 +02:00
|
|
|
#ifndef FORTRAN_SEMANTICS_ATTR_H_
|
|
|
|
#define FORTRAN_SEMANTICS_ATTR_H_
|
2018-02-07 01:46:29 +01:00
|
|
|
|
2018-06-14 22:43:02 +02:00
|
|
|
#include "../common/enum-set.h"
|
2018-06-18 20:03:43 +02:00
|
|
|
#include "../common/idioms.h"
|
2018-02-15 00:07:59 +01:00
|
|
|
#include <cinttypes>
|
2018-02-07 01:46:29 +01:00
|
|
|
#include <string>
|
|
|
|
|
2018-05-02 22:48:12 +02:00
|
|
|
namespace Fortran::semantics {
|
2018-02-07 01:46:29 +01:00
|
|
|
|
|
|
|
// All available attributes.
|
2018-03-23 22:31:14 +01:00
|
|
|
ENUM_CLASS(Attr, ABSTRACT, ALLOCATABLE, ASYNCHRONOUS, BIND_C, CONTIGUOUS,
|
2018-07-12 19:14:58 +02:00
|
|
|
DEFERRED, ELEMENTAL, EXTERNAL, IMPURE, INTENT_IN, INTENT_INOUT, INTENT_OUT,
|
2018-07-12 02:45:13 +02:00
|
|
|
INTRINSIC, MODULE, NON_OVERRIDABLE, NON_RECURSIVE, NOPASS, OPTIONAL,
|
|
|
|
PARAMETER, PASS, POINTER, PRIVATE, PROTECTED, PUBLIC, PURE, RECURSIVE, SAVE,
|
|
|
|
TARGET, VALUE, VOLATILE)
|
2018-02-07 01:46:29 +01:00
|
|
|
|
2018-02-15 00:07:59 +01:00
|
|
|
// Set of attributes
|
2018-06-14 22:43:02 +02:00
|
|
|
class Attrs : public common::EnumSet<Attr, Attr_enumSize> {
|
2018-04-06 01:49:48 +02:00
|
|
|
private:
|
2018-06-14 22:43:02 +02:00
|
|
|
using enumSetType = common::EnumSet<Attr, Attr_enumSize>;
|
2018-05-02 23:06:02 +02:00
|
|
|
|
2018-02-15 00:07:59 +01:00
|
|
|
public:
|
2018-04-06 01:49:48 +02:00
|
|
|
using enumSetType::enumSetType;
|
2018-05-02 23:06:02 +02:00
|
|
|
constexpr bool HasAny(const Attrs &x) const { return !(*this & x).none(); }
|
|
|
|
constexpr bool HasAll(const Attrs &x) const { return (~*this & x).none(); }
|
2018-02-15 00:07:59 +01:00
|
|
|
// Internal error if any of these attributes are not in allowed.
|
2018-02-15 17:27:19 +01:00
|
|
|
void CheckValid(const Attrs &allowed) const;
|
2018-02-15 00:07:59 +01:00
|
|
|
|
|
|
|
private:
|
|
|
|
friend std::ostream &operator<<(std::ostream &, const Attrs &);
|
|
|
|
};
|
2018-02-07 01:46:29 +01:00
|
|
|
|
2018-07-17 01:23:18 +02:00
|
|
|
// Return string representation of attr that matches Fortran source.
|
|
|
|
std::string AttrToString(Attr attr);
|
|
|
|
|
2018-02-07 01:46:29 +01:00
|
|
|
std::ostream &operator<<(std::ostream &o, Attr attr);
|
|
|
|
std::ostream &operator<<(std::ostream &o, const Attrs &attrs);
|
2018-10-25 14:55:23 +02:00
|
|
|
}
|
2018-05-01 23:07:52 +02:00
|
|
|
#endif // FORTRAN_SEMANTICS_ATTR_H_
|