2018-02-07 01:46:29 +01:00
|
|
|
#ifndef FORTRAN_ATTR_H_
|
|
|
|
#define FORTRAN_ATTR_H_
|
|
|
|
|
2018-02-15 00:07:59 +01:00
|
|
|
#include <cinttypes>
|
2018-02-07 01:46:29 +01:00
|
|
|
#include <iostream>
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
namespace Fortran {
|
2018-02-08 00:54:07 +01:00
|
|
|
namespace semantics {
|
2018-02-07 01:46:29 +01:00
|
|
|
|
|
|
|
// All available attributes.
|
|
|
|
enum class Attr {
|
|
|
|
ABSTRACT,
|
|
|
|
ALLOCATABLE,
|
|
|
|
ASYNCHRONOUS,
|
|
|
|
BIND_C,
|
|
|
|
CONTIGUOUS,
|
|
|
|
EXTERNAL,
|
|
|
|
INTENT_IN,
|
|
|
|
INTENT_OUT,
|
|
|
|
INTRINSIC,
|
2018-02-15 00:07:59 +01:00
|
|
|
NOPASS,
|
2018-02-07 01:46:29 +01:00
|
|
|
OPTIONAL,
|
|
|
|
PARAMETER,
|
2018-02-15 00:07:59 +01:00
|
|
|
PASS,
|
2018-02-07 01:46:29 +01:00
|
|
|
POINTER,
|
|
|
|
PRIVATE,
|
|
|
|
PROTECTED,
|
|
|
|
PUBLIC,
|
|
|
|
SAVE,
|
|
|
|
TARGET,
|
|
|
|
VALUE,
|
|
|
|
VOLATILE,
|
|
|
|
};
|
|
|
|
|
2018-02-15 00:07:59 +01:00
|
|
|
// Set of attributes
|
|
|
|
class Attrs {
|
|
|
|
public:
|
|
|
|
Attrs() : bits_{0} {}
|
|
|
|
Attrs(std::initializer_list<Attr> attrs);
|
|
|
|
bool empty() const { return bits_ == 0; }
|
|
|
|
Attrs &set(Attr attr);
|
|
|
|
Attrs &add(const Attrs &attrs);
|
|
|
|
bool has(Attr attr) const;
|
|
|
|
bool hasAny(const Attrs &attrs) const;
|
|
|
|
bool hasAll(const Attrs &attrs) const;
|
|
|
|
// Internal error if any of these attributes are not in allowed.
|
|
|
|
void checkValid(const Attrs &allowed) const;
|
|
|
|
|
|
|
|
private:
|
|
|
|
std::uint64_t bits_;
|
|
|
|
friend std::ostream &operator<<(std::ostream &, const Attrs &);
|
|
|
|
};
|
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-02-08 00:54:07 +01:00
|
|
|
} // namespace semantics
|
2018-02-07 01:46:29 +01:00
|
|
|
} // namespace Fortran
|
|
|
|
|
|
|
|
#endif
|