2018-02-07 01:46:29 +01:00
|
|
|
#ifndef FORTRAN_ATTR_H_
|
|
|
|
#define FORTRAN_ATTR_H_
|
|
|
|
|
2018-04-06 01:49:48 +02:00
|
|
|
#include "enum-set.h"
|
2018-04-12 21:23:20 +02:00
|
|
|
#include "../parser/idioms.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.
|
2018-03-23 22:31:14 +01:00
|
|
|
ENUM_CLASS(Attr, ABSTRACT, ALLOCATABLE, ASYNCHRONOUS, BIND_C, CONTIGUOUS,
|
|
|
|
DEFERRED, ELEMENTAL, EXTERNAL, IMPURE, INTENT_IN, INTENT_OUT, 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-04-06 19:34:59 +02:00
|
|
|
class Attrs : public EnumSet<Attr, Attr_enumSize> {
|
2018-04-06 01:49:48 +02:00
|
|
|
private:
|
2018-04-06 19:34:59 +02:00
|
|
|
using enumSetType = EnumSet<Attr, Attr_enumSize>;
|
2018-02-15 00:07:59 +01:00
|
|
|
public:
|
2018-04-06 01:49:48 +02:00
|
|
|
using enumSetType::enumSetType;
|
|
|
|
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
|
|
|
|
|
|
|
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
|