forked from OSchip/llvm-project
[flang] Reformat with latest clang-format and .clang-format
Original-commit: flang-compiler/f18@9fe84f45d7 Reviewed-on: https://github.com/flang-compiler/f18/pull/1094
This commit is contained in:
parent
10b1addcef
commit
1f8790050b
|
@ -61,5 +61,5 @@ private:
|
|||
LanguageFeatures warn_;
|
||||
bool warnAll_{false};
|
||||
};
|
||||
}
|
||||
} // namespace Fortran::common
|
||||
#endif // FORTRAN_COMMON_FORTRAN_FEATURES_H_
|
||||
|
|
|
@ -68,5 +68,5 @@ enum class RoundingMode : std::uint8_t {
|
|||
|
||||
// Fortran arrays may have up to 15 dimensions (See Fortran 2018 section 5.4.6).
|
||||
static constexpr int maxRank{15};
|
||||
}
|
||||
} // namespace Fortran::common
|
||||
#endif // FORTRAN_COMMON_FORTRAN_H_
|
||||
|
|
|
@ -83,5 +83,5 @@ template<typename UINT> inline constexpr int TrailingZeroBitCount(UINT x) {
|
|||
return BitPopulationCount(static_cast<UINT>(x ^ (x - 1))) - !!x;
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace Fortran::common
|
||||
#endif // FORTRAN_COMMON_BIT_POPULATION_COUNT_H_
|
||||
|
|
|
@ -143,5 +143,5 @@ public:
|
|||
private:
|
||||
Word bits_{0};
|
||||
};
|
||||
}
|
||||
} // namespace Fortran::common
|
||||
#endif // FORTRAN_COMMON_CONSTEXPR_BITSET_H_
|
||||
|
|
|
@ -57,5 +57,5 @@ private:
|
|||
int defaultCharacterKind_{1};
|
||||
int defaultLogicalKind_{defaultIntegerKind_};
|
||||
};
|
||||
}
|
||||
} // namespace Fortran::common
|
||||
#endif // FORTRAN_COMMON_DEFAULT_KINDS_H_
|
||||
|
|
|
@ -212,7 +212,7 @@ public:
|
|||
private:
|
||||
bitsetType bitset_{};
|
||||
};
|
||||
}
|
||||
} // namespace Fortran::common
|
||||
|
||||
template <typename ENUM, std::size_t values>
|
||||
struct std::hash<Fortran::common::EnumSet<ENUM, values>> {
|
||||
|
|
|
@ -51,8 +51,8 @@ public:
|
|||
using Reporter = std::function<bool(const FormatMessage &)>;
|
||||
FormatValidator(const CHAR *format, size_t length, Reporter reporter,
|
||||
IoStmtKind stmt = IoStmtKind::None)
|
||||
: format_{format}, end_{format + length}, reporter_{reporter}, stmt_{stmt},
|
||||
cursor_{format - 1} {
|
||||
: format_{format}, end_{format + length}, reporter_{reporter},
|
||||
stmt_{stmt}, cursor_{format - 1} {
|
||||
CHECK(format);
|
||||
}
|
||||
|
||||
|
@ -241,72 +241,154 @@ template<typename CHAR> void FormatValidator<CHAR>::NextToken() {
|
|||
}
|
||||
break;
|
||||
}
|
||||
case 'A': token_.set_kind(TokenKind::A); break;
|
||||
case 'A':
|
||||
token_.set_kind(TokenKind::A);
|
||||
break;
|
||||
case 'B':
|
||||
switch (LookAheadChar()) {
|
||||
case 'N': Advance(TokenKind::BN); break;
|
||||
case 'Z': Advance(TokenKind::BZ); break;
|
||||
default: token_.set_kind(TokenKind::B); break;
|
||||
case 'N':
|
||||
Advance(TokenKind::BN);
|
||||
break;
|
||||
case 'Z':
|
||||
Advance(TokenKind::BZ);
|
||||
break;
|
||||
default:
|
||||
token_.set_kind(TokenKind::B);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 'D':
|
||||
switch (LookAheadChar()) {
|
||||
case 'C': Advance(TokenKind::DC); break;
|
||||
case 'P': Advance(TokenKind::DP); break;
|
||||
case 'T': Advance(TokenKind::DT); break;
|
||||
default: token_.set_kind(TokenKind::D); break;
|
||||
case 'C':
|
||||
Advance(TokenKind::DC);
|
||||
break;
|
||||
case 'P':
|
||||
Advance(TokenKind::DP);
|
||||
break;
|
||||
case 'T':
|
||||
Advance(TokenKind::DT);
|
||||
break;
|
||||
default:
|
||||
token_.set_kind(TokenKind::D);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 'E':
|
||||
switch (LookAheadChar()) {
|
||||
case 'N': Advance(TokenKind::EN); break;
|
||||
case 'S': Advance(TokenKind::ES); break;
|
||||
case 'X': Advance(TokenKind::EX); break;
|
||||
default: token_.set_kind(TokenKind::E); break;
|
||||
case 'N':
|
||||
Advance(TokenKind::EN);
|
||||
break;
|
||||
case 'S':
|
||||
Advance(TokenKind::ES);
|
||||
break;
|
||||
case 'X':
|
||||
Advance(TokenKind::EX);
|
||||
break;
|
||||
default:
|
||||
token_.set_kind(TokenKind::E);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 'F': token_.set_kind(TokenKind::F); break;
|
||||
case 'G': token_.set_kind(TokenKind::G); break;
|
||||
case 'I': token_.set_kind(TokenKind::I); break;
|
||||
case 'L': token_.set_kind(TokenKind::L); break;
|
||||
case 'O': token_.set_kind(TokenKind::O); break;
|
||||
case 'P': token_.set_kind(TokenKind::P); break;
|
||||
case 'F':
|
||||
token_.set_kind(TokenKind::F);
|
||||
break;
|
||||
case 'G':
|
||||
token_.set_kind(TokenKind::G);
|
||||
break;
|
||||
case 'I':
|
||||
token_.set_kind(TokenKind::I);
|
||||
break;
|
||||
case 'L':
|
||||
token_.set_kind(TokenKind::L);
|
||||
break;
|
||||
case 'O':
|
||||
token_.set_kind(TokenKind::O);
|
||||
break;
|
||||
case 'P':
|
||||
token_.set_kind(TokenKind::P);
|
||||
break;
|
||||
case 'R':
|
||||
switch (LookAheadChar()) {
|
||||
case 'C': Advance(TokenKind::RC); break;
|
||||
case 'D': Advance(TokenKind::RD); break;
|
||||
case 'N': Advance(TokenKind::RN); break;
|
||||
case 'P': Advance(TokenKind::RP); break;
|
||||
case 'U': Advance(TokenKind::RU); break;
|
||||
case 'Z': Advance(TokenKind::RZ); break;
|
||||
default: token_.set_kind(TokenKind::None); break;
|
||||
case 'C':
|
||||
Advance(TokenKind::RC);
|
||||
break;
|
||||
case 'D':
|
||||
Advance(TokenKind::RD);
|
||||
break;
|
||||
case 'N':
|
||||
Advance(TokenKind::RN);
|
||||
break;
|
||||
case 'P':
|
||||
Advance(TokenKind::RP);
|
||||
break;
|
||||
case 'U':
|
||||
Advance(TokenKind::RU);
|
||||
break;
|
||||
case 'Z':
|
||||
Advance(TokenKind::RZ);
|
||||
break;
|
||||
default:
|
||||
token_.set_kind(TokenKind::None);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 'S':
|
||||
switch (LookAheadChar()) {
|
||||
case 'P': Advance(TokenKind::SP); break;
|
||||
case 'S': Advance(TokenKind::SS); break;
|
||||
default: token_.set_kind(TokenKind::S); break;
|
||||
case 'P':
|
||||
Advance(TokenKind::SP);
|
||||
break;
|
||||
case 'S':
|
||||
Advance(TokenKind::SS);
|
||||
break;
|
||||
default:
|
||||
token_.set_kind(TokenKind::S);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 'T':
|
||||
switch (LookAheadChar()) {
|
||||
case 'L': Advance(TokenKind::TL); break;
|
||||
case 'R': Advance(TokenKind::TR); break;
|
||||
default: token_.set_kind(TokenKind::T); break;
|
||||
case 'L':
|
||||
Advance(TokenKind::TL);
|
||||
break;
|
||||
case 'R':
|
||||
Advance(TokenKind::TR);
|
||||
break;
|
||||
default:
|
||||
token_.set_kind(TokenKind::T);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 'X': token_.set_kind(TokenKind::X); break;
|
||||
case 'Z': token_.set_kind(TokenKind::Z); break;
|
||||
case 'X':
|
||||
token_.set_kind(TokenKind::X);
|
||||
break;
|
||||
case 'Z':
|
||||
token_.set_kind(TokenKind::Z);
|
||||
break;
|
||||
case '-':
|
||||
case '+': token_.set_kind(TokenKind::Sign); break;
|
||||
case '/': token_.set_kind(TokenKind::Slash); break;
|
||||
case '(': token_.set_kind(TokenKind::LParen); break;
|
||||
case ')': token_.set_kind(TokenKind::RParen); break;
|
||||
case '.': token_.set_kind(TokenKind::Point); break;
|
||||
case ':': token_.set_kind(TokenKind::Colon); break;
|
||||
case '\\': token_.set_kind(TokenKind::Backslash); break;
|
||||
case '$': token_.set_kind(TokenKind::Dollar); break;
|
||||
case '+':
|
||||
token_.set_kind(TokenKind::Sign);
|
||||
break;
|
||||
case '/':
|
||||
token_.set_kind(TokenKind::Slash);
|
||||
break;
|
||||
case '(':
|
||||
token_.set_kind(TokenKind::LParen);
|
||||
break;
|
||||
case ')':
|
||||
token_.set_kind(TokenKind::RParen);
|
||||
break;
|
||||
case '.':
|
||||
token_.set_kind(TokenKind::Point);
|
||||
break;
|
||||
case ':':
|
||||
token_.set_kind(TokenKind::Colon);
|
||||
break;
|
||||
case '\\':
|
||||
token_.set_kind(TokenKind::Backslash);
|
||||
break;
|
||||
case '$':
|
||||
token_.set_kind(TokenKind::Dollar);
|
||||
break;
|
||||
case '*':
|
||||
token_.set_kind(LookAheadChar() == '(' ? TokenKind::Star : TokenKind::None);
|
||||
break;
|
||||
|
@ -616,7 +698,9 @@ template<typename CHAR> bool FormatValidator<CHAR>::Check() {
|
|||
case TokenKind::ES:
|
||||
case TokenKind::EX:
|
||||
case TokenKind::F:
|
||||
case TokenKind::G: commaRequired = false; break;
|
||||
case TokenKind::G:
|
||||
commaRequired = false;
|
||||
break;
|
||||
default:;
|
||||
}
|
||||
cursor_ = saveCursor;
|
||||
|
@ -718,7 +802,9 @@ template<typename CHAR> bool FormatValidator<CHAR>::Check() {
|
|||
break;
|
||||
}
|
||||
[[fallthrough]];
|
||||
default: ReportError("Unexpected '%s' in format expression"); NextToken();
|
||||
default:
|
||||
ReportError("Unexpected '%s' in format expression");
|
||||
NextToken();
|
||||
}
|
||||
|
||||
// Process comma separator and exit an incomplete format.
|
||||
|
@ -755,5 +841,5 @@ template<typename CHAR> bool FormatValidator<CHAR>::Check() {
|
|||
return formatHasErrors_; // error reporter (message threshold) exit
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace Fortran::common
|
||||
#endif // FORTRAN_COMMON_FORMAT_H_
|
||||
|
|
|
@ -38,7 +38,7 @@ template<typename A>
|
|||
struct is_trivially_copy_constructible<list<A>> : false_type {};
|
||||
template <typename A>
|
||||
struct is_trivially_copy_constructible<optional<list<A>>> : false_type {};
|
||||
}
|
||||
} // namespace std
|
||||
#endif
|
||||
|
||||
// enable "this is a std::string"s with the 's' suffix
|
||||
|
@ -162,5 +162,5 @@ template<typename A> A Clone(const A &x) { return x; }
|
|||
template <typename A, typename... B>
|
||||
using IfNoLvalue = std::enable_if_t<(... && !std::is_lvalue_reference_v<B>), A>;
|
||||
template <typename... RVREF> using NoLvalue = IfNoLvalue<void, RVREF...>;
|
||||
}
|
||||
} // namespace Fortran::common
|
||||
#endif // FORTRAN_COMMON_IDIOMS_H_
|
||||
|
|
|
@ -133,7 +133,7 @@ template<typename A> class Deleter {
|
|||
public:
|
||||
void operator()(A *) const;
|
||||
};
|
||||
}
|
||||
} // namespace Fortran::common
|
||||
#define DEFINE_DELETER(A) \
|
||||
template <> void Fortran::common::Deleter<A>::operator()(A *p) const { \
|
||||
delete p; \
|
||||
|
|
|
@ -111,5 +111,5 @@ private:
|
|||
A start_;
|
||||
std::size_t size_{0};
|
||||
};
|
||||
}
|
||||
} // namespace Fortran::common
|
||||
#endif // FORTRAN_COMMON_INTERVAL_H_
|
||||
|
|
|
@ -40,7 +40,7 @@ static constexpr std::uint8_t mapping[64]{63, 0, 58, 1, 59, 47, 53, 2, 60, 39,
|
|||
48, 27, 54, 33, 42, 3, 61, 51, 37, 40, 49, 18, 28, 20, 55, 30, 34, 11, 43,
|
||||
14, 22, 4, 62, 57, 46, 52, 38, 26, 32, 41, 50, 36, 17, 19, 29, 10, 13, 21,
|
||||
56, 45, 25, 31, 35, 16, 9, 12, 44, 24, 15, 8, 23, 7, 6, 5};
|
||||
}
|
||||
} // namespace
|
||||
|
||||
inline constexpr int LeadingZeroBitCount(std::uint64_t x) {
|
||||
if (x == 0) {
|
||||
|
@ -92,5 +92,5 @@ inline constexpr int LeadingZeroBitCount(std::uint8_t x) {
|
|||
template <typename A> inline constexpr int BitsNeededFor(A x) {
|
||||
return 8 * sizeof x - LeadingZeroBitCount(x);
|
||||
}
|
||||
}
|
||||
} // namespace Fortran::common
|
||||
#endif // FORTRAN_COMMON_LEADING_ZERO_BIT_COUNT_H_
|
||||
|
|
|
@ -20,14 +20,22 @@ namespace Fortran::common {
|
|||
// Total representation size in bits for each type
|
||||
static constexpr int BitsForBinaryPrecision(int binaryPrecision) {
|
||||
switch (binaryPrecision) {
|
||||
case 8: return 16; // IEEE single (truncated): 1+8+7
|
||||
case 11: return 16; // IEEE half precision: 1+5+10
|
||||
case 24: return 32; // IEEE single precision: 1+8+23
|
||||
case 53: return 64; // IEEE double precision: 1+11+52
|
||||
case 64: return 80; // x87 extended precision: 1+15+64
|
||||
case 106: return 128; // "double-double": 2*(1+11+52)
|
||||
case 113: return 128; // IEEE quad precision: 1+15+112
|
||||
default: return -1;
|
||||
case 8:
|
||||
return 16; // IEEE single (truncated): 1+8+7
|
||||
case 11:
|
||||
return 16; // IEEE half precision: 1+5+10
|
||||
case 24:
|
||||
return 32; // IEEE single precision: 1+8+23
|
||||
case 53:
|
||||
return 64; // IEEE double precision: 1+11+52
|
||||
case 64:
|
||||
return 80; // x87 extended precision: 1+15+64
|
||||
case 106:
|
||||
return 128; // "double-double": 2*(1+11+52)
|
||||
case 113:
|
||||
return 128; // IEEE quad precision: 1+15+112
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -37,14 +45,22 @@ static constexpr int BitsForBinaryPrecision(int binaryPrecision) {
|
|||
// exactly with FORMAT(E0.22981).
|
||||
static constexpr int MaxDecimalConversionDigits(int binaryPrecision) {
|
||||
switch (binaryPrecision) {
|
||||
case 8: return 93;
|
||||
case 11: return 17;
|
||||
case 24: return 105;
|
||||
case 53: return 751;
|
||||
case 64: return 11495;
|
||||
case 106: return 2 * 751;
|
||||
case 113: return 11530;
|
||||
default: return -1;
|
||||
case 8:
|
||||
return 93;
|
||||
case 11:
|
||||
return 17;
|
||||
case 24:
|
||||
return 105;
|
||||
case 53:
|
||||
return 751;
|
||||
case 64:
|
||||
return 11495;
|
||||
case 106:
|
||||
return 2 * 751;
|
||||
case 113:
|
||||
return 11530;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -82,5 +98,5 @@ public:
|
|||
static_assert(exponentBits <= 15);
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace Fortran::common
|
||||
#endif // FORTRAN_COMMON_REAL_H_
|
||||
|
|
|
@ -72,5 +72,5 @@ private:
|
|||
|
||||
type *p_{nullptr};
|
||||
};
|
||||
}
|
||||
} // namespace Fortran::common
|
||||
#endif // FORTRAN_COMMON_REFERENCE_COUNTED_H_
|
||||
|
|
|
@ -35,8 +35,8 @@ public:
|
|||
// creation of a temporary copy in cases like:
|
||||
// Reference<type> ref;
|
||||
// const Type &x{ref}; // creates ref to temp copy!
|
||||
operator std::conditional_t<std::is_const_v<type>, type &, void>() const
|
||||
noexcept {
|
||||
operator std::conditional_t<std::is_const_v<type>, type &, void>()
|
||||
const noexcept {
|
||||
if constexpr (std::is_const_v<type>) {
|
||||
return *p_;
|
||||
}
|
||||
|
@ -59,5 +59,5 @@ private:
|
|||
type *p_; // never null
|
||||
};
|
||||
template <typename A> Reference(A &) -> Reference<A>;
|
||||
}
|
||||
} // namespace Fortran::common
|
||||
#endif
|
||||
|
|
|
@ -42,5 +42,5 @@ common::IfNoLvalue<Restorer<A>, B> ScopedSet(A &to, const B &from) {
|
|||
to = from;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
} // namespace Fortran::common
|
||||
#endif // FORTRAN_COMMON_RESTORER_H_
|
||||
|
|
|
@ -319,5 +319,5 @@ common::IfNoLvalue<typename VISITOR::Result, VISITOR> SearchTypes(
|
|||
return SearchTypesHelper<0, VISITOR>(
|
||||
std::move(visitor), std::move(defaultResult));
|
||||
}
|
||||
}
|
||||
} // namespace Fortran::common
|
||||
#endif // FORTRAN_COMMON_TEMPLATE_H_
|
||||
|
|
|
@ -270,5 +270,5 @@ template<int BITS> struct HostUnsignedIntTypeHelper {
|
|||
template <int BITS>
|
||||
using HostUnsignedIntType = typename HostUnsignedIntTypeHelper<BITS>::type;
|
||||
|
||||
}
|
||||
} // namespace Fortran::common
|
||||
#endif
|
||||
|
|
|
@ -73,5 +73,5 @@ inline constexpr UINT DivideUnsignedBy(UINT n) {
|
|||
return recip.Divide(n);
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace Fortran::common
|
||||
#endif
|
||||
|
|
|
@ -153,5 +153,5 @@ template<typename A, typename B> std::optional<A> UnwrapCopy(const B &x) {
|
|||
return std::nullopt;
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace Fortran::common
|
||||
#endif // FORTRAN_COMMON_UNWRAP_H_
|
||||
|
|
|
@ -92,5 +92,5 @@ struct BinaryFloatingPointNumber
|
|||
|
||||
RawType raw{0};
|
||||
};
|
||||
}
|
||||
} // namespace Fortran::decimal
|
||||
#endif
|
||||
|
|
|
@ -33,11 +33,11 @@ class Symbol;
|
|||
namespace Fortran::evaluate {
|
||||
class Component;
|
||||
class IntrinsicProcTable;
|
||||
}
|
||||
} // namespace Fortran::evaluate
|
||||
namespace Fortran::evaluate::characteristics {
|
||||
struct DummyArgument;
|
||||
struct Procedure;
|
||||
}
|
||||
} // namespace Fortran::evaluate::characteristics
|
||||
|
||||
extern template class Fortran::common::Indirection<Fortran::evaluate::Component,
|
||||
true>;
|
||||
|
@ -223,5 +223,5 @@ public:
|
|||
};
|
||||
|
||||
FOR_EACH_SPECIFIC_TYPE(extern template class FunctionRef, )
|
||||
}
|
||||
} // namespace Fortran::evaluate
|
||||
#endif // FORTRAN_EVALUATE_CALL_H_
|
||||
|
|
|
@ -301,5 +301,5 @@ private:
|
|||
Procedure() {}
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace Fortran::evaluate::characteristics
|
||||
#endif // FORTRAN_EVALUATE_CHARACTERISTICS_H_
|
||||
|
|
|
@ -65,5 +65,5 @@ bool IsSimplyContiguous(const A &, const IntrinsicProcTable &);
|
|||
extern template bool IsSimplyContiguous(
|
||||
const Expr<SomeType> &, const IntrinsicProcTable &);
|
||||
|
||||
}
|
||||
} // namespace Fortran::evaluate
|
||||
#endif
|
||||
|
|
|
@ -35,7 +35,8 @@ using common::RelationalOperator;
|
|||
ENUM_CLASS(Ordering, Less, Equal, Greater)
|
||||
ENUM_CLASS(Relation, Less, Equal, Greater, Unordered)
|
||||
|
||||
template<typename A> static constexpr Ordering Compare(const A &x, const A &y) {
|
||||
template <typename A>
|
||||
static constexpr Ordering Compare(const A &x, const A &y) {
|
||||
if (x < y) {
|
||||
return Ordering::Less;
|
||||
} else if (x > y) {
|
||||
|
@ -92,10 +93,14 @@ static constexpr bool Satisfies(RelationalOperator op, Ordering order) {
|
|||
|
||||
static constexpr bool Satisfies(RelationalOperator op, Relation relation) {
|
||||
switch (relation) {
|
||||
case Relation::Less: return Satisfies(op, Ordering::Less);
|
||||
case Relation::Equal: return Satisfies(op, Ordering::Equal);
|
||||
case Relation::Greater: return Satisfies(op, Ordering::Greater);
|
||||
case Relation::Unordered: return false;
|
||||
case Relation::Less:
|
||||
return Satisfies(op, Ordering::Less);
|
||||
case Relation::Equal:
|
||||
return Satisfies(op, Ordering::Equal);
|
||||
case Relation::Greater:
|
||||
return Satisfies(op, Ordering::Greater);
|
||||
case Relation::Unordered:
|
||||
return false;
|
||||
}
|
||||
return false; // silence g++ warning
|
||||
}
|
||||
|
@ -263,5 +268,5 @@ private:
|
|||
};
|
||||
|
||||
void RealFlagWarnings(FoldingContext &, const RealFlags &, const char *op);
|
||||
}
|
||||
} // namespace Fortran::evaluate
|
||||
#endif // FORTRAN_EVALUATE_COMMON_H_
|
||||
|
|
|
@ -101,5 +101,5 @@ extern template class Complex<Real<Integer<32>, 24>>;
|
|||
extern template class Complex<Real<Integer<64>, 53>>;
|
||||
extern template class Complex<Real<Integer<80>, 64>>;
|
||||
extern template class Complex<Real<Integer<128>, 113>>;
|
||||
}
|
||||
} // namespace Fortran::evaluate::value
|
||||
#endif // FORTRAN_EVALUATE_COMPLEX_H_
|
||||
|
|
|
@ -231,5 +231,5 @@ FOR_EACH_INTRINSIC_KIND(extern template class Constant, )
|
|||
FOR_EACH_LENGTHLESS_INTRINSIC_KIND(template class ConstantBase, ) \
|
||||
template class ConstantBase<SomeDerived, StructureConstructorValues>; \
|
||||
FOR_EACH_INTRINSIC_KIND(template class Constant, )
|
||||
}
|
||||
} // namespace Fortran::evaluate
|
||||
#endif // FORTRAN_EVALUATE_CONSTANT_H_
|
||||
|
|
|
@ -355,8 +355,9 @@ struct Concat
|
|||
|
||||
template <int KIND>
|
||||
struct LogicalOperation
|
||||
: public Operation<LogicalOperation<KIND>, Type<TypeCategory::Logical, KIND>,
|
||||
Type<TypeCategory::Logical, KIND>, Type<TypeCategory::Logical, KIND>> {
|
||||
: public Operation<LogicalOperation<KIND>,
|
||||
Type<TypeCategory::Logical, KIND>, Type<TypeCategory::Logical, KIND>,
|
||||
Type<TypeCategory::Logical, KIND>> {
|
||||
using Result = Type<TypeCategory::Logical, KIND>;
|
||||
using Operand = Result;
|
||||
using Base = Operation<LogicalOperation, Result, Operand, Operand>;
|
||||
|
@ -867,5 +868,5 @@ FOR_EACH_INTRINSIC_KIND(extern template class ArrayConstructor, )
|
|||
FOR_EACH_TYPE_AND_KIND(template class ExpressionBase, ) \
|
||||
FOR_EACH_INTRINSIC_KIND(template class ArrayConstructorValues, ) \
|
||||
FOR_EACH_INTRINSIC_KIND(template class ArrayConstructor, )
|
||||
}
|
||||
} // namespace Fortran::evaluate
|
||||
#endif // FORTRAN_EVALUATE_EXPRESSION_H_
|
||||
|
|
|
@ -96,5 +96,5 @@ std::optional<std::int64_t> ToInt64(const std::optional<A> &x) {
|
|||
return std::nullopt;
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace Fortran::evaluate
|
||||
#endif // FORTRAN_EVALUATE_FOLD_H_
|
||||
|
|
|
@ -32,7 +32,8 @@ auto operator<<(llvm::raw_ostream &o, const A &x) -> decltype(x.AsFortran(o)) {
|
|||
}
|
||||
|
||||
template <typename A>
|
||||
auto operator<<(llvm::raw_ostream &o, const A &x) -> decltype(o << x.AsFortran()) {
|
||||
auto operator<<(llvm::raw_ostream &o, const A &x)
|
||||
-> decltype(o << x.AsFortran()) {
|
||||
return o << x.AsFortran();
|
||||
}
|
||||
|
||||
|
@ -53,5 +54,5 @@ auto operator<<(llvm::raw_ostream &o, const std::optional<A> &x)
|
|||
}
|
||||
return o;
|
||||
}
|
||||
}
|
||||
} // namespace Fortran::evaluate
|
||||
#endif // FORTRAN_EVALUATE_FORMATTING_H_
|
||||
|
|
|
@ -104,5 +104,5 @@ private:
|
|||
std::multimap<std::string, const HostRuntimeIntrinsicProcedure> procedures_;
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace Fortran::evaluate
|
||||
#endif // FORTRAN_EVALUATE_INTRINSICS_LIBRARY_H_
|
||||
|
|
|
@ -84,5 +84,5 @@ public:
|
|||
private:
|
||||
Implementation *impl_{nullptr}; // owning pointer
|
||||
};
|
||||
}
|
||||
} // namespace Fortran::evaluate
|
||||
#endif // FORTRAN_EVALUATE_INTRINSICS_H_
|
||||
|
|
|
@ -312,7 +312,8 @@ public:
|
|||
|
||||
// Emits a character representation for an equivalent Fortran constant
|
||||
// or parenthesized constant expression that produces this value.
|
||||
llvm::raw_ostream &AsFortran(llvm::raw_ostream &, int kind, bool minimal = false) const;
|
||||
llvm::raw_ostream &AsFortran(
|
||||
llvm::raw_ostream &, int kind, bool minimal = false) const;
|
||||
|
||||
private:
|
||||
using Significand = Integer<significandBits>; // no implicit bit
|
||||
|
@ -371,5 +372,5 @@ extern template class Real<Integer<64>, 53>; // IEEE double
|
|||
extern template class Real<Integer<80>, 64>; // 80387 extended precision
|
||||
extern template class Real<Integer<128>, 113>; // IEEE quad
|
||||
// N.B. No "double-double" support.
|
||||
}
|
||||
} // namespace Fortran::evaluate::value
|
||||
#endif // FORTRAN_EVALUATE_REAL_H_
|
||||
|
|
|
@ -81,10 +81,17 @@ public:
|
|||
case common::RoundingMode::TiesToEven:
|
||||
round = guard_ && (round_ | sticky_ | isOdd);
|
||||
break;
|
||||
case common::RoundingMode::ToZero: break;
|
||||
case common::RoundingMode::Down: round = isNegative && !empty(); break;
|
||||
case common::RoundingMode::Up: round = !isNegative && !empty(); break;
|
||||
case common::RoundingMode::TiesAwayFromZero: round = guard_; break;
|
||||
case common::RoundingMode::ToZero:
|
||||
break;
|
||||
case common::RoundingMode::Down:
|
||||
round = isNegative && !empty();
|
||||
break;
|
||||
case common::RoundingMode::Up:
|
||||
round = !isNegative && !empty();
|
||||
break;
|
||||
case common::RoundingMode::TiesAwayFromZero:
|
||||
round = guard_;
|
||||
break;
|
||||
}
|
||||
return round;
|
||||
}
|
||||
|
@ -94,5 +101,5 @@ private:
|
|||
bool round_{false}; // 0.25 * ulp
|
||||
bool sticky_{false}; // true if any lesser-valued bit would be set
|
||||
};
|
||||
}
|
||||
} // namespace Fortran::evaluate::value
|
||||
#endif // FORTRAN_EVALUATE_ROUNDING_BITS_H_
|
||||
|
|
|
@ -53,7 +53,8 @@ std::optional<ConstantSubscripts> AsConstantExtents(
|
|||
|
||||
inline int GetRank(const Shape &s) { return static_cast<int>(s.size()); }
|
||||
|
||||
template<typename A> std::optional<Shape> GetShape(FoldingContext &, const A &);
|
||||
template <typename A>
|
||||
std::optional<Shape> GetShape(FoldingContext &, const A &);
|
||||
|
||||
// The dimension argument to these inquiries is zero-based,
|
||||
// unlike the DIM= arguments to many intrinsics.
|
||||
|
@ -187,5 +188,5 @@ bool CheckConformance(parser::ContextualMessages &, const Shape &left,
|
|||
const Shape &right, const char *leftIs = "left operand",
|
||||
const char *rightIs = "right operand");
|
||||
|
||||
}
|
||||
} // namespace Fortran::evaluate
|
||||
#endif // FORTRAN_EVALUATE_SHAPE_H_
|
||||
|
|
|
@ -78,5 +78,5 @@ private:
|
|||
int itemBytes_{1};
|
||||
std::vector<std::uint8_t> data_;
|
||||
};
|
||||
}
|
||||
} // namespace Fortran::evaluate
|
||||
#endif // FORTRAN_EVALUATE_STATIC_DATA_H_
|
||||
|
|
|
@ -73,7 +73,8 @@ public:
|
|||
return visitor_.Default();
|
||||
}
|
||||
}
|
||||
template<typename... A> Result operator()(const std::variant<A...> &u) const {
|
||||
template <typename... A>
|
||||
Result operator()(const std::variant<A...> &u) const {
|
||||
return std::visit(visitor_, u);
|
||||
}
|
||||
template <typename A> Result operator()(const std::vector<A> &x) const {
|
||||
|
@ -280,7 +281,8 @@ struct AnyTraverse : public Base {
|
|||
}
|
||||
};
|
||||
|
||||
template<typename Visitor, typename Set, typename Base = Traverse<Visitor, Set>>
|
||||
template <typename Visitor, typename Set,
|
||||
typename Base = Traverse<Visitor, Set>>
|
||||
struct SetTraverse : public Base {
|
||||
SetTraverse(Visitor &v) : Base{v} {}
|
||||
using Base::operator();
|
||||
|
@ -298,5 +300,5 @@ struct SetTraverse : public Base {
|
|||
}
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace Fortran::evaluate
|
||||
#endif
|
||||
|
|
|
@ -37,7 +37,7 @@ class DerivedTypeSpec;
|
|||
class ParamValue;
|
||||
class Symbol;
|
||||
bool IsDescriptor(const Symbol &);
|
||||
}
|
||||
} // namespace Fortran::semantics
|
||||
|
||||
namespace Fortran::evaluate {
|
||||
|
||||
|
@ -65,10 +65,12 @@ static constexpr bool IsValidKindOfIntrinsicType(
|
|||
case TypeCategory::Complex:
|
||||
return kind == 2 || kind == 3 || kind == 4 || kind == 8 || kind == 10 ||
|
||||
kind == 16;
|
||||
case TypeCategory::Character: return kind == 1 || kind == 2 || kind == 4;
|
||||
case TypeCategory::Character:
|
||||
return kind == 1 || kind == 2 || kind == 4;
|
||||
case TypeCategory::Logical:
|
||||
return kind == 1 || kind == 2 || kind == 4 || kind == 8;
|
||||
default: return false;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -511,5 +513,5 @@ bool IsKindTypeParameter(const semantics::Symbol &);
|
|||
#define FOR_EACH_TYPE_AND_KIND(PREFIX, SUFFIX) \
|
||||
FOR_EACH_INTRINSIC_KIND(PREFIX, SUFFIX) \
|
||||
FOR_EACH_CATEGORY_TYPE(PREFIX, SUFFIX)
|
||||
}
|
||||
} // namespace Fortran::evaluate
|
||||
#endif // FORTRAN_EVALUATE_TYPE_H_
|
||||
|
|
|
@ -443,5 +443,5 @@ private:
|
|||
EXPAND_FOR_EACH_INTEGER_KIND( \
|
||||
TEMPLATE_INSTANTIATION, template class TypeParamInquiry, ) \
|
||||
FOR_EACH_SPECIFIC_TYPE(template class Designator, )
|
||||
}
|
||||
} // namespace Fortran::evaluate
|
||||
#endif // FORTRAN_EVALUATE_VARIABLE_H_
|
||||
|
|
|
@ -114,7 +114,7 @@ template<typename T> struct FlexibleArray : T {
|
|||
operator T *() { return this; }
|
||||
operator const T *() const { return this; }
|
||||
};
|
||||
}
|
||||
} // namespace cfi_internal
|
||||
#endif
|
||||
|
||||
/* 18.5.3 generic data descriptor */
|
||||
|
@ -145,7 +145,7 @@ template<int r> struct CdescStorage : public CFI_cdesc_t {
|
|||
};
|
||||
template <> struct CdescStorage<1> : public CFI_cdesc_t {};
|
||||
template <> struct CdescStorage<0> : public CFI_cdesc_t {};
|
||||
}
|
||||
} // namespace cfi_internal
|
||||
#define CFI_CDESC_T(rank) cfi_internal::CdescStorage<rank>
|
||||
#else
|
||||
#define CFI_CDESC_T(rank) \
|
||||
|
|
|
@ -140,7 +140,7 @@ inline bool operator>(const char *left, const CharBlock &right) {
|
|||
|
||||
llvm::raw_ostream &operator<<(llvm::raw_ostream &os, const CharBlock &x);
|
||||
|
||||
}
|
||||
} // namespace Fortran::parser
|
||||
|
||||
// Specializations to enable std::unordered_map<CharBlock, ...> &c.
|
||||
template <> struct std::hash<Fortran::parser::CharBlock> {
|
||||
|
|
|
@ -24,8 +24,8 @@ class CharBuffer {
|
|||
public:
|
||||
CharBuffer() {}
|
||||
CharBuffer(CharBuffer &&that)
|
||||
: blocks_(std::move(that.blocks_)), last_{that.last_}, bytes_{that.bytes_},
|
||||
lastBlockEmpty_{that.lastBlockEmpty_} {
|
||||
: blocks_(std::move(that.blocks_)), last_{that.last_},
|
||||
bytes_{that.bytes_}, lastBlockEmpty_{that.lastBlockEmpty_} {
|
||||
that.clear();
|
||||
}
|
||||
CharBuffer &operator=(CharBuffer &&that) {
|
||||
|
@ -73,5 +73,5 @@ private:
|
|||
std::size_t bytes_{0};
|
||||
bool lastBlockEmpty_{false};
|
||||
};
|
||||
}
|
||||
} // namespace Fortran::parser
|
||||
#endif // FORTRAN_PARSER_CHAR_BUFFER_H_
|
||||
|
|
|
@ -75,5 +75,5 @@ private:
|
|||
constexpr SetOfChars(std::uint64_t b) : bits_{b} {}
|
||||
std::uint64_t bits_{0};
|
||||
};
|
||||
}
|
||||
} // namespace Fortran::parser
|
||||
#endif // FORTRAN_PARSER_CHAR_SET_H_
|
||||
|
|
|
@ -103,33 +103,51 @@ inline constexpr char HexadecimalDigitValue(char ch) {
|
|||
|
||||
inline constexpr std::optional<char> BackslashEscapeValue(char ch) {
|
||||
switch (ch) {
|
||||
case 'a': return std::nullopt; // '\a'; PGF90 doesn't know \a
|
||||
case 'b': return '\b';
|
||||
case 'f': return '\f';
|
||||
case 'n': return '\n';
|
||||
case 'r': return '\r';
|
||||
case 't': return '\t';
|
||||
case 'v': return '\v';
|
||||
case 'a':
|
||||
return std::nullopt; // '\a'; PGF90 doesn't know \a
|
||||
case 'b':
|
||||
return '\b';
|
||||
case 'f':
|
||||
return '\f';
|
||||
case 'n':
|
||||
return '\n';
|
||||
case 'r':
|
||||
return '\r';
|
||||
case 't':
|
||||
return '\t';
|
||||
case 'v':
|
||||
return '\v';
|
||||
case '"':
|
||||
case '\'':
|
||||
case '\\': return ch;
|
||||
default: return std::nullopt;
|
||||
case '\\':
|
||||
return ch;
|
||||
default:
|
||||
return std::nullopt;
|
||||
}
|
||||
}
|
||||
|
||||
inline constexpr std::optional<char> BackslashEscapeChar(char ch) {
|
||||
switch (ch) {
|
||||
case '\a': return std::nullopt; // 'a'; PGF90 doesn't know \a
|
||||
case '\b': return 'b';
|
||||
case '\f': return 'f';
|
||||
case '\n': return 'n';
|
||||
case '\r': return 'r';
|
||||
case '\t': return 't';
|
||||
case '\v': return 'v';
|
||||
case '\a':
|
||||
return std::nullopt; // 'a'; PGF90 doesn't know \a
|
||||
case '\b':
|
||||
return 'b';
|
||||
case '\f':
|
||||
return 'f';
|
||||
case '\n':
|
||||
return 'n';
|
||||
case '\r':
|
||||
return 'r';
|
||||
case '\t':
|
||||
return 't';
|
||||
case '\v':
|
||||
return 'v';
|
||||
case '"':
|
||||
case '\'':
|
||||
case '\\': return ch;
|
||||
default: return std::nullopt;
|
||||
case '\\':
|
||||
return ch;
|
||||
default:
|
||||
return std::nullopt;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -235,5 +253,5 @@ extern template std::u16string DecodeString<std::u16string, Encoding::UTF_8>(
|
|||
const std::string &, bool);
|
||||
extern template std::u32string DecodeString<std::u32string, Encoding::UTF_8>(
|
||||
const std::string &, bool);
|
||||
}
|
||||
} // namespace Fortran::parser
|
||||
#endif // FORTRAN_PARSER_CHARACTERS_H_
|
||||
|
|
|
@ -35,8 +35,8 @@ struct HasSource<T, decltype((void)T::source, 0)> : std::true_type {};
|
|||
|
||||
class ParseTreeDumper {
|
||||
public:
|
||||
explicit ParseTreeDumper(
|
||||
llvm::raw_ostream &out, const AnalyzedObjectsAsFortran *asFortran = nullptr)
|
||||
explicit ParseTreeDumper(llvm::raw_ostream &out,
|
||||
const AnalyzedObjectsAsFortran *asFortran = nullptr)
|
||||
: out_(out), asFortran_{asFortran} {}
|
||||
|
||||
static constexpr const char *GetNodeName(const char *) { return "char *"; }
|
||||
|
@ -716,7 +716,9 @@ public:
|
|||
template <typename T> bool Pre(const UnlabeledStatement<T> &) { return true; }
|
||||
template <typename T> void Post(const UnlabeledStatement<T> &) {}
|
||||
|
||||
template<typename T> bool Pre(const common::Indirection<T> &) { return true; }
|
||||
template <typename T> bool Pre(const common::Indirection<T> &) {
|
||||
return true;
|
||||
}
|
||||
template <typename T> void Post(const common::Indirection<T> &) {}
|
||||
|
||||
template <typename A> bool Pre(const Scalar<A> &) {
|
||||
|
@ -842,5 +844,5 @@ void DumpTree(llvm::raw_ostream &out, const T &x,
|
|||
Walk(x, dumper);
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace Fortran::parser
|
||||
#endif // FORTRAN_PARSER_DUMP_PARSE_TREE_H_
|
||||
|
|
|
@ -141,5 +141,5 @@ struct FormatSpecification {
|
|||
: items(std::move(is)), unlimitedItems(std::move(us)) {}
|
||||
std::list<FormatItem> items, unlimitedItems;
|
||||
};
|
||||
}
|
||||
} // namespace Fortran::format
|
||||
#endif // FORTRAN_PARSER_FORMAT_SPECIFICATION_H_
|
||||
|
|
|
@ -80,5 +80,5 @@ inline constexpr auto instrumented(
|
|||
const MessageFixedText &tag, const PA &parser) {
|
||||
return InstrumentedParser{tag, parser};
|
||||
}
|
||||
}
|
||||
} // namespace Fortran::parser
|
||||
#endif // FORTRAN_PARSER_INSTRUMENTED_PARSER_H_
|
||||
|
|
|
@ -57,7 +57,7 @@ constexpr MessageFixedText operator""_err_en_US(
|
|||
const char str[], std::size_t n) {
|
||||
return MessageFixedText{str, n, true /* fatal */};
|
||||
}
|
||||
}
|
||||
} // namespace literals
|
||||
|
||||
// The construction of a MessageFormattedText uses a MessageFixedText
|
||||
// as a vsnprintf() formatting string that is applied to the
|
||||
|
@ -185,8 +185,8 @@ public:
|
|||
bool IsFatal() const;
|
||||
std::string ToString() const;
|
||||
std::optional<ProvenanceRange> GetProvenanceRange(const CookedSource &) const;
|
||||
void Emit(
|
||||
llvm::raw_ostream &, const CookedSource &, bool echoSourceLine = true) const;
|
||||
void Emit(llvm::raw_ostream &, const CookedSource &,
|
||||
bool echoSourceLine = true) const;
|
||||
|
||||
// If this Message or any of its attachments locates itself via a CharBlock
|
||||
// within a particular CookedSource, replace its location with the
|
||||
|
@ -312,5 +312,5 @@ private:
|
|||
CharBlock at_;
|
||||
Messages *messages_{nullptr};
|
||||
};
|
||||
}
|
||||
} // namespace Fortran::parser
|
||||
#endif // FORTRAN_PARSER_MESSAGE_H_
|
||||
|
|
|
@ -138,7 +138,8 @@ public:
|
|||
messages_.Say(range, std::forward<A>(args)...).SetContext(context_.get());
|
||||
}
|
||||
}
|
||||
template<typename... A> void Say(const MessageFixedText &text, A &&... args) {
|
||||
template <typename... A>
|
||||
void Say(const MessageFixedText &text, A &&... args) {
|
||||
Say(p_, text, std::forward<A>(args)...);
|
||||
}
|
||||
template <typename... A>
|
||||
|
@ -228,5 +229,5 @@ private:
|
|||
// reflected in the copy and move constructors defined at the top of this
|
||||
// class definition!
|
||||
};
|
||||
}
|
||||
} // namespace Fortran::parser
|
||||
#endif // FORTRAN_PARSER_PARSE_STATE_H_
|
||||
|
|
|
@ -121,7 +121,8 @@ void ForEachInTuple(T &tuple, Func func) {
|
|||
ForEachInTuple<I + 1>(tuple, func);
|
||||
}
|
||||
}
|
||||
template<typename M, typename... A> void Walk(std::tuple<A...> &x, M &mutator) {
|
||||
template <typename M, typename... A>
|
||||
void Walk(std::tuple<A...> &x, M &mutator) {
|
||||
if (sizeof...(A) > 0) {
|
||||
if (mutator.Pre(x)) {
|
||||
ForEachInTuple(x, [&](auto &y) { Walk(y, mutator); });
|
||||
|
@ -373,7 +374,8 @@ template<typename M> void Walk(DeclarationTypeSpec::Class &x, M &mutator) {
|
|||
mutator.Post(x);
|
||||
}
|
||||
}
|
||||
template<typename V> void Walk(const DeclarationTypeSpec::Type &x, V &visitor) {
|
||||
template <typename V>
|
||||
void Walk(const DeclarationTypeSpec::Type &x, V &visitor) {
|
||||
if (visitor.Pre(x)) {
|
||||
Walk(x.derived, visitor);
|
||||
visitor.Post(x);
|
||||
|
@ -584,7 +586,8 @@ template<typename M> void Walk(RealLiteralConstant &x, M &mutator) {
|
|||
mutator.Post(x);
|
||||
}
|
||||
}
|
||||
template<typename V> void Walk(const RealLiteralConstant::Real &x, V &visitor) {
|
||||
template <typename V>
|
||||
void Walk(const RealLiteralConstant::Real &x, V &visitor) {
|
||||
if (visitor.Pre(x)) {
|
||||
Walk(x.source, visitor);
|
||||
visitor.Post(x);
|
||||
|
@ -712,7 +715,8 @@ void Walk(const format::DerivedTypeDataEditDesc &x, V &visitor) {
|
|||
visitor.Post(x);
|
||||
}
|
||||
}
|
||||
template<typename M> void Walk(format::DerivedTypeDataEditDesc &x, M &mutator) {
|
||||
template <typename M>
|
||||
void Walk(format::DerivedTypeDataEditDesc &x, M &mutator) {
|
||||
if (mutator.Pre(x)) {
|
||||
Walk(x.type, mutator);
|
||||
Walk(x.parameters, mutator);
|
||||
|
@ -815,5 +819,5 @@ void Walk(OmpLinearClause::WithoutModifier &x, M &mutator) {
|
|||
mutator.Post(x);
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace Fortran::parser
|
||||
#endif // FORTRAN_PARSER_PARSE_TREE_VISITOR_H_
|
||||
|
|
|
@ -58,7 +58,7 @@ namespace Fortran::semantics {
|
|||
class Symbol;
|
||||
class DeclTypeSpec;
|
||||
class DerivedTypeSpec;
|
||||
}
|
||||
} // namespace Fortran::semantics
|
||||
|
||||
// Expressions in the parse tree have owning pointers that can be set to
|
||||
// type-checked generic expression representations by semantic analysis.
|
||||
|
@ -66,7 +66,7 @@ namespace Fortran::evaluate {
|
|||
struct GenericExprWrapper; // forward definition, wraps Expr<SomeType>
|
||||
struct GenericAssignmentWrapper; // forward definition, represent assignment
|
||||
class ProcedureRef; // forward definition, represents a CALL statement
|
||||
}
|
||||
} // namespace Fortran::evaluate
|
||||
|
||||
// Most non-template classes in this file use these default definitions
|
||||
// for their move constructor and move assignment operator=, and disable
|
||||
|
@ -1624,8 +1624,7 @@ struct Expr {
|
|||
using IntrinsicUnary::IntrinsicUnary;
|
||||
};
|
||||
|
||||
WRAPPER_CLASS(
|
||||
PercentLoc, common::Indirection<Variable>); // %LOC(v) extension
|
||||
WRAPPER_CLASS(PercentLoc, common::Indirection<Variable>); // %LOC(v) extension
|
||||
|
||||
struct DefinedUnary {
|
||||
TUPLE_CLASS_BOILERPLATE(DefinedUnary);
|
||||
|
@ -3787,5 +3786,5 @@ struct OpenMPConstruct {
|
|||
OpenMPCriticalConstruct>
|
||||
u;
|
||||
};
|
||||
}
|
||||
} // namespace Fortran::parser
|
||||
#endif // FORTRAN_PARSER_PARSE_TREE_H_
|
||||
|
|
|
@ -56,8 +56,8 @@ public:
|
|||
void Parse(llvm::raw_ostream &debugOutput);
|
||||
void ClearLog();
|
||||
|
||||
void EmitMessage(llvm::raw_ostream &o, const char *at, const std::string &message,
|
||||
bool echoSourceLine = false) const {
|
||||
void EmitMessage(llvm::raw_ostream &o, const char *at,
|
||||
const std::string &message, bool echoSourceLine = false) const {
|
||||
cooked_.allSources().EmitMessage(
|
||||
o, cooked_.GetProvenanceRange(CharBlock(at)), message, echoSourceLine);
|
||||
}
|
||||
|
@ -73,5 +73,5 @@ private:
|
|||
std::optional<Program> parseTree_;
|
||||
ParsingLog log_;
|
||||
};
|
||||
}
|
||||
} // namespace Fortran::parser
|
||||
#endif // FORTRAN_PARSER_PARSING_H_
|
||||
|
|
|
@ -268,5 +268,5 @@ private:
|
|||
OffsetToProvenanceMappings provenanceMap_;
|
||||
ProvenanceRangeToOffsetMappings invertedMap_;
|
||||
};
|
||||
}
|
||||
} // namespace Fortran::parser
|
||||
#endif // FORTRAN_PARSER_PROVENANCE_H_
|
||||
|
|
|
@ -15,11 +15,11 @@
|
|||
// - A Unicode byte order mark is recognized if present.
|
||||
|
||||
#include "characters.h"
|
||||
#include "llvm/Support/MemoryBuffer.h"
|
||||
#include <cstddef>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
#include "llvm/Support/MemoryBuffer.h"
|
||||
|
||||
namespace llvm {
|
||||
class raw_ostream;
|
||||
|
@ -43,7 +43,9 @@ public:
|
|||
explicit SourceFile(Encoding e) : encoding_{e} {}
|
||||
~SourceFile();
|
||||
std::string path() const { return path_; }
|
||||
llvm::ArrayRef<char> content() const { return buf_->getBuffer().slice(bom_end_, buf_end_ - bom_end_); }
|
||||
llvm::ArrayRef<char> content() const {
|
||||
return buf_->getBuffer().slice(bom_end_, buf_end_ - bom_end_);
|
||||
}
|
||||
std::size_t bytes() const { return content().size(); }
|
||||
std::size_t lines() const { return lineStart_.size(); }
|
||||
Encoding encoding() const { return encoding_; }
|
||||
|
@ -68,5 +70,5 @@ private:
|
|||
std::size_t buf_end_;
|
||||
Encoding encoding_;
|
||||
};
|
||||
}
|
||||
} // namespace Fortran::parser
|
||||
#endif // FORTRAN_PARSER_SOURCE_H_
|
||||
|
|
|
@ -87,5 +87,5 @@ template<typename A, typename B> A *Unwrap(B &x) {
|
|||
const CoindexedNamedObject *GetCoindexedNamedObject(const AllocateObject &);
|
||||
const CoindexedNamedObject *GetCoindexedNamedObject(const DataRef &);
|
||||
|
||||
}
|
||||
} // namespace Fortran::parser
|
||||
#endif // FORTRAN_PARSER_TOOLS_H_
|
||||
|
|
|
@ -22,7 +22,7 @@ namespace Fortran::evaluate {
|
|||
struct GenericExprWrapper;
|
||||
struct GenericAssignmentWrapper;
|
||||
class ProcedureRef;
|
||||
}
|
||||
} // namespace Fortran::evaluate
|
||||
|
||||
namespace Fortran::parser {
|
||||
|
||||
|
@ -48,6 +48,6 @@ void Unparse(llvm::raw_ostream &out, const Program &program,
|
|||
Encoding encoding = Encoding::UTF_8, bool capitalizeKeywords = true,
|
||||
bool backslashEscapes = true, preStatementType *preStatement = nullptr,
|
||||
AnalyzedObjectsAsFortran * = nullptr);
|
||||
}
|
||||
} // namespace Fortran::parser
|
||||
|
||||
#endif
|
||||
|
|
|
@ -139,5 +139,5 @@ struct StructureComponents {
|
|||
using resultType = DataComponentDefStmt;
|
||||
static std::optional<DataComponentDefStmt> Parse(ParseState &);
|
||||
};
|
||||
}
|
||||
} // namespace Fortran::parser
|
||||
#endif // FORTRAN_PARSER_USER_STATE_H_
|
||||
|
|
|
@ -50,5 +50,5 @@ std::string AttrToString(Attr attr);
|
|||
|
||||
llvm::raw_ostream &operator<<(llvm::raw_ostream &o, Attr attr);
|
||||
llvm::raw_ostream &operator<<(llvm::raw_ostream &o, const Attrs &attrs);
|
||||
}
|
||||
} // namespace Fortran::semantics
|
||||
#endif // FORTRAN_SEMANTICS_ATTR_H_
|
||||
|
|
|
@ -65,7 +65,7 @@ template<typename A> CharBlock FindSourceLocation(const A &x) {
|
|||
Walk(x, visitor);
|
||||
return visitor.source;
|
||||
}
|
||||
}
|
||||
} // namespace Fortran::parser
|
||||
|
||||
using namespace Fortran::parser::literals;
|
||||
|
||||
|
|
|
@ -39,7 +39,8 @@ class SemanticsContext;
|
|||
struct EquivalenceObject {
|
||||
EquivalenceObject(Symbol &symbol, std::vector<ConstantSubscript> subscripts,
|
||||
std::optional<ConstantSubscript> substringStart)
|
||||
: symbol{symbol}, subscripts{subscripts}, substringStart{substringStart} {}
|
||||
: symbol{symbol}, subscripts{subscripts}, substringStart{substringStart} {
|
||||
}
|
||||
bool operator==(const EquivalenceObject &) const;
|
||||
bool operator<(const EquivalenceObject &) const;
|
||||
std::string AsFortran() const;
|
||||
|
@ -240,5 +241,5 @@ private:
|
|||
|
||||
friend llvm::raw_ostream &operator<<(llvm::raw_ostream &, const Scope &);
|
||||
};
|
||||
}
|
||||
} // namespace Fortran::semantics
|
||||
#endif // FORTRAN_SEMANTICS_SCOPE_H_
|
||||
|
|
|
@ -43,7 +43,7 @@ struct SelectRankConstruct;
|
|||
struct SelectTypeConstruct;
|
||||
struct Variable;
|
||||
struct WhereConstruct;
|
||||
}
|
||||
} // namespace Fortran::parser
|
||||
|
||||
namespace Fortran::semantics {
|
||||
|
||||
|
@ -228,5 +228,5 @@ struct BaseChecker {
|
|||
template <typename N> void Enter(const N &) {}
|
||||
template <typename N> void Leave(const N &) {}
|
||||
};
|
||||
}
|
||||
} // namespace Fortran::semantics
|
||||
#endif
|
||||
|
|
|
@ -398,7 +398,9 @@ struct GenericKind {
|
|||
u;
|
||||
|
||||
private:
|
||||
template<typename T> bool Has() const { return std::holds_alternative<T>(u); }
|
||||
template <typename T> bool Has() const {
|
||||
return std::holds_alternative<T>(u);
|
||||
}
|
||||
bool Is(OtherKind) const;
|
||||
};
|
||||
|
||||
|
@ -582,12 +584,12 @@ public:
|
|||
bool IsSubprogram() const;
|
||||
bool IsFromModFile() const;
|
||||
bool HasExplicitInterface() const {
|
||||
return std::visit(
|
||||
common::visitors{
|
||||
return std::visit(common::visitors{
|
||||
[](const SubprogramDetails &) { return true; },
|
||||
[](const SubprogramNameDetails &) { return true; },
|
||||
[&](const ProcEntityDetails &x) {
|
||||
return attrs_.test(Attr::INTRINSIC) || x.HasExplicitInterface();
|
||||
return attrs_.test(Attr::INTRINSIC) ||
|
||||
x.HasExplicitInterface();
|
||||
},
|
||||
[](const ProcBindingDetails &x) {
|
||||
return x.symbol().HasExplicitInterface();
|
||||
|
@ -733,5 +735,5 @@ inline bool ProcEntityDetails::HasExplicitInterface() const {
|
|||
inline bool operator<(SymbolRef x, SymbolRef y) { return *x < *y; }
|
||||
using SymbolSet = std::set<SymbolRef>;
|
||||
|
||||
}
|
||||
} // namespace Fortran::semantics
|
||||
#endif // FORTRAN_SEMANTICS_SYMBOL_H_
|
||||
|
|
|
@ -496,8 +496,8 @@ public:
|
|||
LabelEnforce(SemanticsContext &context, std::set<parser::Label> &&labels,
|
||||
parser::CharBlock constructSourcePosition, const char *construct)
|
||||
: context_{context}, labels_{labels},
|
||||
constructSourcePosition_{constructSourcePosition}, construct_{construct} {
|
||||
}
|
||||
constructSourcePosition_{constructSourcePosition}, construct_{
|
||||
construct} {}
|
||||
template <typename T> bool Pre(const T &) { return true; }
|
||||
template <typename T> bool Pre(const parser::Statement<T> &statement) {
|
||||
currentStatementSourcePosition_ = statement.source;
|
||||
|
@ -529,5 +529,5 @@ private:
|
|||
parser::CharBlock stmtLocation, parser::MessageFormattedText &&message,
|
||||
parser::CharBlock constructLocation);
|
||||
};
|
||||
}
|
||||
} // namespace Fortran::semantics
|
||||
#endif // FORTRAN_SEMANTICS_TOOLS_H_
|
||||
|
|
|
@ -130,7 +130,8 @@ protected:
|
|||
private:
|
||||
TypeCategory category_;
|
||||
KindExpr kind_;
|
||||
friend llvm::raw_ostream &operator<<(llvm::raw_ostream &os, const IntrinsicTypeSpec &x);
|
||||
friend llvm::raw_ostream &operator<<(
|
||||
llvm::raw_ostream &os, const IntrinsicTypeSpec &x);
|
||||
};
|
||||
|
||||
class NumericTypeSpec : public IntrinsicTypeSpec {
|
||||
|
@ -157,7 +158,8 @@ public:
|
|||
|
||||
private:
|
||||
ParamValue length_;
|
||||
friend llvm::raw_ostream &operator<<(llvm::raw_ostream &os, const CharacterTypeSpec &x);
|
||||
friend llvm::raw_ostream &operator<<(
|
||||
llvm::raw_ostream &os, const CharacterTypeSpec &x);
|
||||
};
|
||||
|
||||
class ShapeSpec {
|
||||
|
@ -293,7 +295,8 @@ private:
|
|||
bool instantiated_{false};
|
||||
RawParameters rawParameters_;
|
||||
ParameterMapType parameters_;
|
||||
friend llvm::raw_ostream &operator<<(llvm::raw_ostream &, const DerivedTypeSpec &);
|
||||
friend llvm::raw_ostream &operator<<(
|
||||
llvm::raw_ostream &, const DerivedTypeSpec &);
|
||||
};
|
||||
|
||||
class DeclTypeSpec {
|
||||
|
@ -351,18 +354,24 @@ public:
|
|||
IntrinsicTypeSpec *AsIntrinsic();
|
||||
const IntrinsicTypeSpec *AsIntrinsic() const {
|
||||
switch (category_) {
|
||||
case Numeric: return &std::get<NumericTypeSpec>(typeSpec_);
|
||||
case Logical: return &std::get<LogicalTypeSpec>(typeSpec_);
|
||||
case Character: return &std::get<CharacterTypeSpec>(typeSpec_);
|
||||
default: return nullptr;
|
||||
case Numeric:
|
||||
return &std::get<NumericTypeSpec>(typeSpec_);
|
||||
case Logical:
|
||||
return &std::get<LogicalTypeSpec>(typeSpec_);
|
||||
case Character:
|
||||
return &std::get<CharacterTypeSpec>(typeSpec_);
|
||||
default:
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
const DerivedTypeSpec *AsDerived() const {
|
||||
switch (category_) {
|
||||
case TypeDerived:
|
||||
case ClassDerived: return &std::get<DerivedTypeSpec>(typeSpec_);
|
||||
default: return nullptr;
|
||||
case ClassDerived:
|
||||
return &std::get<DerivedTypeSpec>(typeSpec_);
|
||||
default:
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -390,5 +399,5 @@ private:
|
|||
const Symbol *symbol_{nullptr};
|
||||
const DeclTypeSpec *type_{nullptr};
|
||||
};
|
||||
}
|
||||
} // namespace Fortran::semantics
|
||||
#endif // FORTRAN_SEMANTICS_TYPE_H_
|
||||
|
|
|
@ -22,15 +22,22 @@ std::vector<const char *> LanguageFeatureControl::GetNames(
|
|||
if (IsEnabled(LanguageFeature::LogicalAbbreviations)) {
|
||||
switch (opr) {
|
||||
SWITCH_COVERS_ALL_CASES
|
||||
case LogicalOperator::And: result.push_back(".a."); break;
|
||||
case LogicalOperator::Or: result.push_back(".o."); break;
|
||||
case LogicalOperator::Not: result.push_back(".n."); break;
|
||||
case LogicalOperator::And:
|
||||
result.push_back(".a.");
|
||||
break;
|
||||
case LogicalOperator::Or:
|
||||
result.push_back(".o.");
|
||||
break;
|
||||
case LogicalOperator::Not:
|
||||
result.push_back(".n.");
|
||||
break;
|
||||
case LogicalOperator::Neqv:
|
||||
if (IsEnabled(LanguageFeature::XOROperator)) {
|
||||
result.push_back(".x.");
|
||||
}
|
||||
break;
|
||||
case LogicalOperator::Eqv: break;
|
||||
case LogicalOperator::Eqv:
|
||||
break;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
@ -40,11 +47,16 @@ std::vector<const char *> LanguageFeatureControl::GetNames(
|
|||
RelationalOperator opr) const {
|
||||
switch (opr) {
|
||||
SWITCH_COVERS_ALL_CASES
|
||||
case RelationalOperator::LT: return {".lt.", "<"};
|
||||
case RelationalOperator::LE: return {".le.", "<="};
|
||||
case RelationalOperator::EQ: return {".eq.", "=="};
|
||||
case RelationalOperator::GE: return {".ge.", ">="};
|
||||
case RelationalOperator::GT: return {".gt.", ">"};
|
||||
case RelationalOperator::LT:
|
||||
return {".lt.", "<"};
|
||||
case RelationalOperator::LE:
|
||||
return {".le.", "<="};
|
||||
case RelationalOperator::EQ:
|
||||
return {".eq.", "=="};
|
||||
case RelationalOperator::GE:
|
||||
return {".ge.", ">="};
|
||||
case RelationalOperator::GT:
|
||||
return {".gt.", ">"};
|
||||
case RelationalOperator::NE:
|
||||
if (IsEnabled(LanguageFeature::AlternativeNE)) {
|
||||
return {".ne.", "/=", "<>"};
|
||||
|
@ -54,4 +66,4 @@ std::vector<const char *> LanguageFeatureControl::GetNames(
|
|||
}
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace Fortran::common
|
||||
|
|
|
@ -13,35 +13,51 @@ namespace Fortran::common {
|
|||
const char *AsFortran(NumericOperator opr) {
|
||||
switch (opr) {
|
||||
SWITCH_COVERS_ALL_CASES
|
||||
case NumericOperator::Power: return "**";
|
||||
case NumericOperator::Multiply: return "*";
|
||||
case NumericOperator::Divide: return "/";
|
||||
case NumericOperator::Add: return "+";
|
||||
case NumericOperator::Subtract: return "-";
|
||||
case NumericOperator::Power:
|
||||
return "**";
|
||||
case NumericOperator::Multiply:
|
||||
return "*";
|
||||
case NumericOperator::Divide:
|
||||
return "/";
|
||||
case NumericOperator::Add:
|
||||
return "+";
|
||||
case NumericOperator::Subtract:
|
||||
return "-";
|
||||
}
|
||||
}
|
||||
|
||||
const char *AsFortran(LogicalOperator opr) {
|
||||
switch (opr) {
|
||||
SWITCH_COVERS_ALL_CASES
|
||||
case LogicalOperator::And: return ".and.";
|
||||
case LogicalOperator::Or: return ".or.";
|
||||
case LogicalOperator::Eqv: return ".eqv.";
|
||||
case LogicalOperator::Neqv: return ".neqv.";
|
||||
case LogicalOperator::Not: return ".not.";
|
||||
case LogicalOperator::And:
|
||||
return ".and.";
|
||||
case LogicalOperator::Or:
|
||||
return ".or.";
|
||||
case LogicalOperator::Eqv:
|
||||
return ".eqv.";
|
||||
case LogicalOperator::Neqv:
|
||||
return ".neqv.";
|
||||
case LogicalOperator::Not:
|
||||
return ".not.";
|
||||
}
|
||||
}
|
||||
|
||||
const char *AsFortran(RelationalOperator opr) {
|
||||
switch (opr) {
|
||||
SWITCH_COVERS_ALL_CASES
|
||||
case RelationalOperator::LT: return "<";
|
||||
case RelationalOperator::LE: return "<=";
|
||||
case RelationalOperator::EQ: return "==";
|
||||
case RelationalOperator::NE: return "/=";
|
||||
case RelationalOperator::GE: return ">=";
|
||||
case RelationalOperator::GT: return ">";
|
||||
case RelationalOperator::LT:
|
||||
return "<";
|
||||
case RelationalOperator::LE:
|
||||
return "<=";
|
||||
case RelationalOperator::EQ:
|
||||
return "==";
|
||||
case RelationalOperator::NE:
|
||||
return "/=";
|
||||
case RelationalOperator::GE:
|
||||
return ">=";
|
||||
case RelationalOperator::GT:
|
||||
return ">";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace Fortran::common
|
||||
|
|
|
@ -67,12 +67,18 @@ IntrinsicTypeDefaultKinds &IntrinsicTypeDefaultKinds::set_defaultLogicalKind(
|
|||
|
||||
int IntrinsicTypeDefaultKinds::GetDefaultKind(TypeCategory category) const {
|
||||
switch (category) {
|
||||
case TypeCategory::Integer: return defaultIntegerKind_;
|
||||
case TypeCategory::Integer:
|
||||
return defaultIntegerKind_;
|
||||
case TypeCategory::Real:
|
||||
case TypeCategory::Complex: return defaultRealKind_;
|
||||
case TypeCategory::Character: return defaultCharacterKind_;
|
||||
case TypeCategory::Logical: return defaultLogicalKind_;
|
||||
default: CRASH_NO_CASE; return 0;
|
||||
}
|
||||
case TypeCategory::Complex:
|
||||
return defaultRealKind_;
|
||||
case TypeCategory::Character:
|
||||
return defaultCharacterKind_;
|
||||
case TypeCategory::Logical:
|
||||
return defaultLogicalKind_;
|
||||
default:
|
||||
CRASH_NO_CASE;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
} // namespace Fortran::common
|
||||
|
|
|
@ -40,4 +40,4 @@ std::string EnumIndexToString(int index, const char *enumNames) {
|
|||
}
|
||||
return std::string(p, q - p);
|
||||
}
|
||||
}
|
||||
} // namespace Fortran::common
|
||||
|
|
|
@ -326,5 +326,5 @@ private:
|
|||
bool isNegative_{false};
|
||||
enum FortranRounding rounding_ { RoundDefault };
|
||||
};
|
||||
}
|
||||
} // namespace Fortran::decimal
|
||||
#endif
|
||||
|
|
|
@ -176,10 +176,17 @@ BigRadixFloatingPointNumber<PREC, LOG10RADIX>::ConvertToDecimal(char *buffer,
|
|||
incr = *end > '5' ||
|
||||
(*end == '5' && (p > end + 1 || ((end[-1] - '0') & 1) != 0));
|
||||
break;
|
||||
case RoundUp: incr = !isNegative_; break;
|
||||
case RoundDown: incr = isNegative_; break;
|
||||
case RoundToZero: break;
|
||||
case RoundCompatible: incr = *end >= '5'; break;
|
||||
case RoundUp:
|
||||
incr = !isNegative_;
|
||||
break;
|
||||
case RoundDown:
|
||||
incr = isNegative_;
|
||||
break;
|
||||
case RoundToZero:
|
||||
break;
|
||||
case RoundCompatible:
|
||||
incr = *end >= '5';
|
||||
break;
|
||||
}
|
||||
p = end;
|
||||
if (incr) {
|
||||
|
@ -306,10 +313,17 @@ void BigRadixFloatingPointNumber<PREC,
|
|||
case RoundDefault:
|
||||
incr = LSD > radix / 2 || (LSD == radix / 2 && digit_[0] % 2 != 0);
|
||||
break;
|
||||
case RoundUp: incr = LSD > 0 && !isNegative_; break;
|
||||
case RoundDown: incr = LSD > 0 && isNegative_; break;
|
||||
case RoundToZero: break;
|
||||
case RoundCompatible: incr = LSD >= radix / 2; break;
|
||||
case RoundUp:
|
||||
incr = LSD > 0 && !isNegative_;
|
||||
break;
|
||||
case RoundDown:
|
||||
incr = LSD > 0 && isNegative_;
|
||||
break;
|
||||
case RoundToZero:
|
||||
break;
|
||||
case RoundCompatible:
|
||||
incr = LSD >= radix / 2;
|
||||
break;
|
||||
}
|
||||
for (int j{0}; (digit_[j] += incr) == radix; ++j) {
|
||||
digit_[j] = 0;
|
||||
|
@ -398,4 +412,4 @@ ConversionToDecimalResult ConvertLongDoubleToDecimal(char *buffer,
|
|||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
} // namespace Fortran::decimal
|
||||
|
|
|
@ -133,7 +133,8 @@ bool BigRadixFloatingPointNumber<PREC, LOG10RADIX>::ParseNumber(
|
|||
}
|
||||
}
|
||||
} break;
|
||||
default: break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -231,10 +232,17 @@ ConversionToBinaryResult<PREC> IntermediateFloat<PREC>::ToBinary(
|
|||
case RoundDefault:
|
||||
incr = guard > oneHalf || (guard == oneHalf && (fraction & 1));
|
||||
break;
|
||||
case RoundUp: incr = guard != 0 && !isNegative; break;
|
||||
case RoundDown: incr = guard != 0 && isNegative; break;
|
||||
case RoundToZero: break;
|
||||
case RoundCompatible: incr = guard >= oneHalf; break;
|
||||
case RoundUp:
|
||||
incr = guard != 0 && !isNegative;
|
||||
break;
|
||||
case RoundDown:
|
||||
incr = guard != 0 && isNegative;
|
||||
break;
|
||||
case RoundToZero:
|
||||
break;
|
||||
case RoundCompatible:
|
||||
incr = guard >= oneHalf;
|
||||
break;
|
||||
}
|
||||
if (incr) {
|
||||
if (fraction == mask) {
|
||||
|
@ -427,4 +435,4 @@ enum ConversionResultFlags ConvertDecimalToLongDouble(
|
|||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
} // namespace Fortran::decimal
|
||||
|
|
|
@ -65,8 +65,8 @@ void ActualArgument::Parenthesize() {
|
|||
|
||||
SpecificIntrinsic::SpecificIntrinsic(
|
||||
IntrinsicProcedure n, characteristics::Procedure &&chars)
|
||||
: name{n}, characteristics{new characteristics::Procedure{std::move(chars)}} {
|
||||
}
|
||||
: name{n}, characteristics{
|
||||
new characteristics::Procedure{std::move(chars)}} {}
|
||||
|
||||
DEFINE_DEFAULT_CONSTRUCTORS_AND_ASSIGNMENTS(SpecificIntrinsic)
|
||||
|
||||
|
@ -150,8 +150,7 @@ const Component *ProcedureDesignator::GetComponent() const {
|
|||
}
|
||||
|
||||
const Symbol *ProcedureDesignator::GetSymbol() const {
|
||||
return std::visit(
|
||||
common::visitors{
|
||||
return std::visit(common::visitors{
|
||||
[](SymbolRef symbol) { return &*symbol; },
|
||||
[](const common::CopyableIndirection<Component> &c) {
|
||||
return &c.value().GetLastSymbol();
|
||||
|
@ -213,5 +212,5 @@ int ProcedureRef::Rank() const {
|
|||
ProcedureRef::~ProcedureRef() {}
|
||||
|
||||
FOR_EACH_SPECIFIC_TYPE(template class FunctionRef, )
|
||||
}
|
||||
} // namespace Fortran::evaluate
|
||||
DEFINE_DELETER(Fortran::evaluate::ProcedureRef)
|
||||
|
|
|
@ -117,6 +117,6 @@ private:
|
|||
static constexpr CharT NewLine() { return 0x0a; }
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace Fortran::evaluate
|
||||
|
||||
#endif // FORTRAN_EVALUATE_CHARACTER_H_
|
||||
|
|
|
@ -398,8 +398,7 @@ bool DummyArgument::IsOptional() const {
|
|||
}
|
||||
|
||||
void DummyArgument::SetOptional(bool value) {
|
||||
std::visit(
|
||||
common::visitors{
|
||||
std::visit(common::visitors{
|
||||
[value](DummyDataObject &data) {
|
||||
data.attrs.set(DummyDataObject::Attr::Optional, value);
|
||||
},
|
||||
|
@ -497,7 +496,8 @@ bool FunctionResult::CanBeReturnedViaImplicitInterface() const {
|
|||
return true;
|
||||
}
|
||||
return false;
|
||||
default: return true;
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -507,8 +507,7 @@ bool FunctionResult::CanBeReturnedViaImplicitInterface() const {
|
|||
|
||||
llvm::raw_ostream &FunctionResult::Dump(llvm::raw_ostream &o) const {
|
||||
attrs.Dump(o, EnumToString);
|
||||
std::visit(
|
||||
common::visitors{
|
||||
std::visit(common::visitors{
|
||||
[&](const TypeAndShape &ts) { ts.Dump(o); },
|
||||
[&](const CopyableIndirection<Procedure> &p) {
|
||||
p.value().Dump(o << " procedure(") << ')';
|
||||
|
@ -519,7 +518,8 @@ llvm::raw_ostream &FunctionResult::Dump(llvm::raw_ostream &o) const {
|
|||
}
|
||||
|
||||
Procedure::Procedure(FunctionResult &&fr, DummyArguments &&args, Attrs a)
|
||||
: functionResult{std::move(fr)}, dummyArguments{std::move(args)}, attrs{a} {}
|
||||
: functionResult{std::move(fr)}, dummyArguments{std::move(args)}, attrs{a} {
|
||||
}
|
||||
Procedure::Procedure(DummyArguments &&args, Attrs a)
|
||||
: dummyArguments{std::move(args)}, attrs{a} {}
|
||||
Procedure::~Procedure() {}
|
||||
|
@ -1020,7 +1020,7 @@ DEFINE_DEFAULT_CONSTRUCTORS_AND_ASSIGNMENTS(DummyArgument)
|
|||
DEFINE_DEFAULT_CONSTRUCTORS_AND_ASSIGNMENTS(DummyProcedure)
|
||||
DEFINE_DEFAULT_CONSTRUCTORS_AND_ASSIGNMENTS(FunctionResult)
|
||||
DEFINE_DEFAULT_CONSTRUCTORS_AND_ASSIGNMENTS(Procedure)
|
||||
}
|
||||
} // namespace Fortran::evaluate::characteristics
|
||||
|
||||
template class Fortran::common::Indirection<
|
||||
Fortran::evaluate::characteristics::Procedure, true>;
|
||||
|
|
|
@ -110,11 +110,11 @@ struct IsInitialDataTargetHelper
|
|||
IsConstantExpr(x.stride());
|
||||
}
|
||||
bool operator()(const Subscript &x) const {
|
||||
return std::visit(
|
||||
common::visitors{
|
||||
return std::visit(common::visitors{
|
||||
[&](const Triplet &t) { return (*this)(t); },
|
||||
[&](const auto &y) {
|
||||
return y.value().Rank() == 0 && IsConstantExpr(y.value());
|
||||
return y.value().Rank() == 0 &&
|
||||
IsConstantExpr(y.value());
|
||||
},
|
||||
},
|
||||
x.u);
|
||||
|
@ -129,7 +129,9 @@ struct IsInitialDataTargetHelper
|
|||
return false;
|
||||
}
|
||||
bool operator()(const StructureConstructor &) const { return false; }
|
||||
template<typename T> bool operator()(const FunctionRef<T> &) { return false; }
|
||||
template <typename T> bool operator()(const FunctionRef<T> &) {
|
||||
return false;
|
||||
}
|
||||
template <typename D, typename R, typename... O>
|
||||
bool operator()(const Operation<D, R, O...> &) const {
|
||||
return false;
|
||||
|
@ -360,4 +362,4 @@ bool IsSimplyContiguous(const A &x, const IntrinsicProcTable &table) {
|
|||
template bool IsSimplyContiguous(
|
||||
const Expr<SomeType> &, const IntrinsicProcTable &);
|
||||
|
||||
}
|
||||
} // namespace Fortran::evaluate
|
||||
|
|
|
@ -51,4 +51,4 @@ void FoldingContext::EndImpliedDo(parser::CharBlock name) {
|
|||
impliedDos_.erase(iter);
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace Fortran::evaluate
|
||||
|
|
|
@ -103,4 +103,4 @@ template class Complex<Real<Integer<32>, 24>>;
|
|||
template class Complex<Real<Integer<64>, 53>>;
|
||||
template class Complex<Real<Integer<80>, 64>>;
|
||||
template class Complex<Real<Integer<128>, 113>>;
|
||||
}
|
||||
} // namespace Fortran::evaluate::value
|
||||
|
|
|
@ -196,7 +196,8 @@ Constant<Type<TypeCategory::Character, KIND>>::Constant(ConstantSubscript len,
|
|||
CHECK(at == static_cast<ConstantSubscript>(values_.size()));
|
||||
}
|
||||
|
||||
template<int KIND> Constant<Type<TypeCategory::Character, KIND>>::~Constant() {}
|
||||
template <int KIND>
|
||||
Constant<Type<TypeCategory::Character, KIND>>::~Constant() {}
|
||||
|
||||
template <int KIND>
|
||||
bool Constant<Type<TypeCategory::Character, KIND>>::empty() const {
|
||||
|
@ -308,4 +309,4 @@ std::size_t Constant<SomeDerived>::CopyFrom(const Constant<SomeDerived> &source,
|
|||
}
|
||||
|
||||
INSTANTIATE_CONSTANT_TEMPLATES
|
||||
}
|
||||
} // namespace Fortran::evaluate
|
||||
|
|
|
@ -242,6 +242,6 @@ std::optional<Expr<SubscriptInteger>> Expr<SomeCharacter>::LEN() const {
|
|||
}
|
||||
|
||||
INSTANTIATE_EXPRESSION_TEMPLATES
|
||||
}
|
||||
} // namespace Fortran::evaluate
|
||||
DEFINE_DELETER(Fortran::evaluate::GenericExprWrapper)
|
||||
DEFINE_DELETER(Fortran::evaluate::GenericAssignmentWrapper)
|
||||
|
|
|
@ -93,4 +93,4 @@ Expr<Type<TypeCategory::Character, KIND>> FoldOperation(
|
|||
|
||||
FOR_EACH_CHARACTER_KIND(template class ExpressionBase, )
|
||||
template class ExpressionBase<SomeCharacter>;
|
||||
}
|
||||
} // namespace Fortran::evaluate
|
||||
|
|
|
@ -77,4 +77,4 @@ Expr<Type<TypeCategory::Complex, KIND>> FoldOperation(
|
|||
|
||||
FOR_EACH_COMPLEX_KIND(template class ExpressionBase, )
|
||||
template class ExpressionBase<SomeComplex>;
|
||||
}
|
||||
} // namespace Fortran::evaluate
|
||||
|
|
|
@ -1486,5 +1486,5 @@ Expr<T> ExpressionBase<T>::Rewrite(FoldingContext &context, Expr<T> &&expr) {
|
|||
|
||||
FOR_EACH_TYPE_AND_KIND(extern template class ExpressionBase, )
|
||||
|
||||
}
|
||||
} // namespace Fortran::evaluate
|
||||
#endif // FORTRAN_EVALUATE_FOLD_IMPLEMENTATION_H_
|
||||
|
|
|
@ -644,4 +644,4 @@ std::optional<std::int64_t> ToInt64(const Expr<SomeType> &expr) {
|
|||
|
||||
FOR_EACH_INTEGER_KIND(template class ExpressionBase, )
|
||||
template class ExpressionBase<SomeInteger>;
|
||||
}
|
||||
} // namespace Fortran::evaluate
|
||||
|
|
|
@ -162,11 +162,20 @@ Expr<Type<TypeCategory::Logical, KIND>> FoldOperation(
|
|||
if (auto folded{OperandsAreConstants(operation)}) {
|
||||
bool xt{folded->first.IsTrue()}, yt{folded->second.IsTrue()}, result{};
|
||||
switch (operation.logicalOperator) {
|
||||
case LogicalOperator::And: result = xt && yt; break;
|
||||
case LogicalOperator::Or: result = xt || yt; break;
|
||||
case LogicalOperator::Eqv: result = xt == yt; break;
|
||||
case LogicalOperator::Neqv: result = xt != yt; break;
|
||||
case LogicalOperator::Not: DIE("not a binary operator");
|
||||
case LogicalOperator::And:
|
||||
result = xt && yt;
|
||||
break;
|
||||
case LogicalOperator::Or:
|
||||
result = xt || yt;
|
||||
break;
|
||||
case LogicalOperator::Eqv:
|
||||
result = xt == yt;
|
||||
break;
|
||||
case LogicalOperator::Neqv:
|
||||
result = xt != yt;
|
||||
break;
|
||||
case LogicalOperator::Not:
|
||||
DIE("not a binary operator");
|
||||
}
|
||||
return Expr<LOGICAL>{Constant<LOGICAL>{result}};
|
||||
}
|
||||
|
@ -175,4 +184,4 @@ Expr<Type<TypeCategory::Logical, KIND>> FoldOperation(
|
|||
|
||||
FOR_EACH_LOGICAL_KIND(template class ExpressionBase, )
|
||||
template class ExpressionBase<SomeLogical>;
|
||||
}
|
||||
} // namespace Fortran::evaluate
|
||||
|
|
|
@ -162,4 +162,4 @@ Expr<Type<TypeCategory::Real, KIND>> FoldOperation(
|
|||
|
||||
FOR_EACH_REAL_KIND(template class ExpressionBase, )
|
||||
template class ExpressionBase<SomeReal>;
|
||||
}
|
||||
} // namespace Fortran::evaluate
|
||||
|
|
|
@ -85,14 +85,14 @@ Triplet FoldOperation(FoldingContext &context, Triplet &&triplet) {
|
|||
}
|
||||
|
||||
Subscript FoldOperation(FoldingContext &context, Subscript &&subscript) {
|
||||
return std::visit(
|
||||
common::visitors{
|
||||
return std::visit(common::visitors{
|
||||
[&](IndirectSubscriptIntegerExpr &&expr) {
|
||||
expr.value() = Fold(context, std::move(expr.value()));
|
||||
return Subscript(std::move(expr));
|
||||
},
|
||||
[&](Triplet &&triplet) {
|
||||
return Subscript(FoldOperation(context, std::move(triplet)));
|
||||
return Subscript(
|
||||
FoldOperation(context, std::move(triplet)));
|
||||
},
|
||||
},
|
||||
std::move(subscript.u));
|
||||
|
@ -128,8 +128,7 @@ CoarrayRef FoldOperation(FoldingContext &context, CoarrayRef &&coarrayRef) {
|
|||
}
|
||||
|
||||
DataRef FoldOperation(FoldingContext &context, DataRef &&dataRef) {
|
||||
return std::visit(
|
||||
common::visitors{
|
||||
return std::visit(common::visitors{
|
||||
[&](SymbolRef symbol) { return DataRef{*symbol}; },
|
||||
[&](auto &&x) {
|
||||
return DataRef{FoldOperation(context, std::move(x))};
|
||||
|
@ -188,4 +187,4 @@ Expr<ImpliedDoIndex::Result> FoldOperation(
|
|||
template class ExpressionBase<SomeDerived>;
|
||||
template class ExpressionBase<SomeType>;
|
||||
|
||||
}
|
||||
} // namespace Fortran::evaluate
|
||||
|
|
|
@ -168,11 +168,15 @@ template<int KIND>
|
|||
static Precedence ToPrecedence(const LogicalOperation<KIND> &x) {
|
||||
switch (x.logicalOperator) {
|
||||
SWITCH_COVERS_ALL_CASES
|
||||
case LogicalOperator::And: return Precedence::And;
|
||||
case LogicalOperator::Or: return Precedence::Or;
|
||||
case LogicalOperator::Not: return Precedence::Not;
|
||||
case LogicalOperator::And:
|
||||
return Precedence::And;
|
||||
case LogicalOperator::Or:
|
||||
return Precedence::Or;
|
||||
case LogicalOperator::Not:
|
||||
return Precedence::Not;
|
||||
case LogicalOperator::Eqv:
|
||||
case LogicalOperator::Neqv: return Precedence::Equivalence;
|
||||
case LogicalOperator::Neqv:
|
||||
return Precedence::Equivalence;
|
||||
}
|
||||
}
|
||||
template <int KIND> constexpr Precedence ToPrecedence(const Not<KIND> &) {
|
||||
|
@ -256,7 +260,8 @@ template<int KIND>
|
|||
static OperatorSpelling SpellOperator(const ComplexComponent<KIND> &x) {
|
||||
return {x.isImaginaryPart ? "aimag(" : "real(", "", ")"};
|
||||
}
|
||||
template<int KIND> constexpr OperatorSpelling SpellOperator(const Not<KIND> &) {
|
||||
template <int KIND>
|
||||
constexpr OperatorSpelling SpellOperator(const Not<KIND> &) {
|
||||
return OperatorSpelling{".NOT.", "", ""};
|
||||
}
|
||||
template <int KIND>
|
||||
|
@ -431,8 +436,7 @@ std::string ExpressionBase<RESULT>::AsFortran() const {
|
|||
template <typename RESULT>
|
||||
llvm::raw_ostream &ExpressionBase<RESULT>::AsFortran(
|
||||
llvm::raw_ostream &o) const {
|
||||
std::visit(
|
||||
common::visitors{
|
||||
std::visit(common::visitors{
|
||||
[&](const BOZLiteralConstant &x) {
|
||||
o << "z'" << x.Hexadecimal() << "'";
|
||||
},
|
||||
|
@ -617,8 +621,7 @@ llvm::raw_ostream &Component::AsFortran(llvm::raw_ostream &o) const {
|
|||
}
|
||||
|
||||
llvm::raw_ostream &NamedEntity::AsFortran(llvm::raw_ostream &o) const {
|
||||
std::visit(
|
||||
common::visitors{
|
||||
std::visit(common::visitors{
|
||||
[&](SymbolRef s) { EmitVar(o, s); },
|
||||
[&](const Component &c) { c.AsFortran(o); },
|
||||
},
|
||||
|
@ -701,8 +704,7 @@ llvm::raw_ostream &ProcedureDesignator::AsFortran(llvm::raw_ostream &o) const {
|
|||
|
||||
template <typename T>
|
||||
llvm::raw_ostream &Designator<T>::AsFortran(llvm::raw_ostream &o) const {
|
||||
std::visit(
|
||||
common::visitors{
|
||||
std::visit(common::visitors{
|
||||
[&](SymbolRef symbol) { EmitVar(o, symbol); },
|
||||
[&](const auto &x) { x.AsFortran(o); },
|
||||
},
|
||||
|
@ -712,11 +714,20 @@ llvm::raw_ostream &Designator<T>::AsFortran(llvm::raw_ostream &o) const {
|
|||
|
||||
llvm::raw_ostream &DescriptorInquiry::AsFortran(llvm::raw_ostream &o) const {
|
||||
switch (field_) {
|
||||
case Field::LowerBound: o << "lbound("; break;
|
||||
case Field::Extent: o << "size("; break;
|
||||
case Field::Stride: o << "%STRIDE("; break;
|
||||
case Field::Rank: o << "rank("; break;
|
||||
case Field::Len: break;
|
||||
case Field::LowerBound:
|
||||
o << "lbound(";
|
||||
break;
|
||||
case Field::Extent:
|
||||
o << "size(";
|
||||
break;
|
||||
case Field::Stride:
|
||||
o << "%STRIDE(";
|
||||
break;
|
||||
case Field::Rank:
|
||||
o << "rank(";
|
||||
break;
|
||||
case Field::Len:
|
||||
break;
|
||||
}
|
||||
base_.AsFortran(o);
|
||||
if (field_ == Field::Len) {
|
||||
|
@ -769,4 +780,4 @@ llvm::raw_ostream &Assignment::AsFortran(llvm::raw_ostream &o) const {
|
|||
INSTANTIATE_CONSTANT_TEMPLATES
|
||||
INSTANTIATE_EXPRESSION_TEMPLATES
|
||||
INSTANTIATE_VARIABLE_TEMPLATES
|
||||
}
|
||||
} // namespace Fortran::evaluate
|
||||
|
|
|
@ -76,10 +76,18 @@ void HostFloatingPointEnvironment::SetUpHostFloatingPointEnvironment(
|
|||
return;
|
||||
}
|
||||
switch (context.rounding().mode) {
|
||||
case common::RoundingMode::TiesToEven: fesetround(FE_TONEAREST); break;
|
||||
case common::RoundingMode::ToZero: fesetround(FE_TOWARDZERO); break;
|
||||
case common::RoundingMode::Up: fesetround(FE_UPWARD); break;
|
||||
case common::RoundingMode::Down: fesetround(FE_DOWNWARD); break;
|
||||
case common::RoundingMode::TiesToEven:
|
||||
fesetround(FE_TONEAREST);
|
||||
break;
|
||||
case common::RoundingMode::ToZero:
|
||||
fesetround(FE_TOWARDZERO);
|
||||
break;
|
||||
case common::RoundingMode::Up:
|
||||
fesetround(FE_UPWARD);
|
||||
break;
|
||||
case common::RoundingMode::Down:
|
||||
fesetround(FE_DOWNWARD);
|
||||
break;
|
||||
case common::RoundingMode::TiesAwayFromZero:
|
||||
fesetround(FE_TONEAREST);
|
||||
context.messages().Say(
|
||||
|
@ -135,4 +143,4 @@ void HostFloatingPointEnvironment::CheckAndRestoreFloatingPointEnvironment(
|
|||
}
|
||||
errno = 0;
|
||||
}
|
||||
}
|
||||
} // namespace Fortran::evaluate::host
|
||||
|
|
|
@ -252,7 +252,7 @@ struct BiggerOrSameHostTypeHelper<Type<TypeCategory::Complex, KIND>> {
|
|||
using FortranType = std::conditional_t<HostTypeExists<T>(), T,
|
||||
typename BiggerOrSameHostTypeHelper<NextT>::FortranType>;
|
||||
};
|
||||
}
|
||||
}
|
||||
} // namespace host
|
||||
} // namespace Fortran::evaluate
|
||||
|
||||
#endif // FORTRAN_EVALUATE_HOST_H_
|
||||
|
|
|
@ -54,5 +54,5 @@ ValueWithRealFlags<REAL> IntPower(
|
|||
REAL one{REAL::FromInteger(INT{1}).value};
|
||||
return TimesIntPowerOf(one, base, power, rounding);
|
||||
}
|
||||
}
|
||||
} // namespace Fortran::evaluate
|
||||
#endif // FORTRAN_EVALUATE_INT_POWER_H_
|
||||
|
|
|
@ -28,4 +28,4 @@ static_assert(Integer<64>::partBits == 32);
|
|||
static_assert(std::is_same_v<typename Integer<64>::Part, std::uint32_t>);
|
||||
static_assert(Integer<128>::partBits == 32);
|
||||
static_assert(std::is_same_v<typename Integer<128>::Part, std::uint32_t>);
|
||||
}
|
||||
} // namespace Fortran::evaluate::value
|
||||
|
|
|
@ -205,5 +205,5 @@ HostIntrinsicProceduresLibrary::GetHostProcedureWrapper(
|
|||
return std::nullopt;
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace Fortran::evaluate
|
||||
#endif // FORTRAN_EVALUATE_INTRINSICS_LIBRARY_TEMPLATES_H_
|
||||
|
|
|
@ -558,7 +558,7 @@ static void InitHostIntrinsicLibraryWithLibpgmath(
|
|||
AddLibmComplexHostProcedures<long double>(lib);
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace pgmath
|
||||
#endif // LINK_WITH_LIBPGMATH
|
||||
|
||||
// Define which host runtime functions will be used for folding
|
||||
|
@ -581,4 +581,4 @@ HostIntrinsicProceduresLibrary::HostIntrinsicProceduresLibrary() {
|
|||
InitHostIntrinsicLibraryWithLibm(*this);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
} // namespace Fortran::evaluate
|
||||
|
|
|
@ -1138,7 +1138,9 @@ std::optional<SpecificCall> IntrinsicInterface::Match(
|
|||
case KindCode::defaultLogicalKind:
|
||||
argOk = type->kind() == defaults.GetDefaultKind(TypeCategory::Logical);
|
||||
break;
|
||||
case KindCode::any: argOk = true; break;
|
||||
case KindCode::any:
|
||||
argOk = true;
|
||||
break;
|
||||
case KindCode::kindArg:
|
||||
CHECK(type->category() == TypeCategory::Integer);
|
||||
CHECK(!kindArg);
|
||||
|
@ -1175,8 +1177,11 @@ std::optional<SpecificCall> IntrinsicInterface::Match(
|
|||
"for intrinsic '%s'",
|
||||
d.keyword, name);
|
||||
break;
|
||||
case KindCode::addressable: argOk = true; break;
|
||||
default: CRASH_NO_CASE;
|
||||
case KindCode::addressable:
|
||||
argOk = true;
|
||||
break;
|
||||
default:
|
||||
CRASH_NO_CASE;
|
||||
}
|
||||
if (!argOk) {
|
||||
messages.Say(
|
||||
|
@ -1210,8 +1215,12 @@ std::optional<SpecificCall> IntrinsicInterface::Match(
|
|||
}
|
||||
argOk = rank == 0 || rank == elementalRank;
|
||||
break;
|
||||
case Rank::scalar: argOk = rank == 0; break;
|
||||
case Rank::vector: argOk = rank == 1; break;
|
||||
case Rank::scalar:
|
||||
argOk = rank == 0;
|
||||
break;
|
||||
case Rank::vector:
|
||||
argOk = rank == 1;
|
||||
break;
|
||||
case Rank::shape:
|
||||
CHECK(!shapeArgSize);
|
||||
if (rank == 1) {
|
||||
|
@ -1229,7 +1238,9 @@ std::optional<SpecificCall> IntrinsicInterface::Match(
|
|||
return std::nullopt;
|
||||
}
|
||||
break;
|
||||
case Rank::matrix: argOk = rank == 2; break;
|
||||
case Rank::matrix:
|
||||
argOk = rank == 2;
|
||||
break;
|
||||
case Rank::array:
|
||||
argOk = rank > 0;
|
||||
if (!arrayArg) {
|
||||
|
@ -1244,7 +1255,9 @@ std::optional<SpecificCall> IntrinsicInterface::Match(
|
|||
}
|
||||
argOk = rank == knownArg->Rank();
|
||||
break;
|
||||
case Rank::anyOrAssumedRank: argOk = true; break;
|
||||
case Rank::anyOrAssumedRank:
|
||||
argOk = true;
|
||||
break;
|
||||
case Rank::conformable:
|
||||
CHECK(arrayArg);
|
||||
argOk = rank == 0 || rank == arrayArg->Rank();
|
||||
|
@ -1383,7 +1396,8 @@ std::optional<SpecificCall> IntrinsicInterface::Match(
|
|||
common::die(
|
||||
"INTERNAL: bad KindCode appears on intrinsic '%s' result", name);
|
||||
break;
|
||||
default: CRASH_NO_CASE;
|
||||
default:
|
||||
CRASH_NO_CASE;
|
||||
}
|
||||
} else {
|
||||
if (!call.isSubroutineCall) {
|
||||
|
@ -1396,10 +1410,18 @@ std::optional<SpecificCall> IntrinsicInterface::Match(
|
|||
// Determine the rank of the function result.
|
||||
int resultRank{0};
|
||||
switch (rank) {
|
||||
case Rank::elemental: resultRank = elementalRank; break;
|
||||
case Rank::scalar: resultRank = 0; break;
|
||||
case Rank::vector: resultRank = 1; break;
|
||||
case Rank::matrix: resultRank = 2; break;
|
||||
case Rank::elemental:
|
||||
resultRank = elementalRank;
|
||||
break;
|
||||
case Rank::scalar:
|
||||
resultRank = 0;
|
||||
break;
|
||||
case Rank::vector:
|
||||
resultRank = 1;
|
||||
break;
|
||||
case Rank::matrix:
|
||||
resultRank = 2;
|
||||
break;
|
||||
case Rank::conformable:
|
||||
CHECK(arrayArg);
|
||||
resultRank = arrayArg->Rank();
|
||||
|
@ -1798,10 +1820,14 @@ static DynamicType GetReturnType(const SpecificIntrinsicInterface &interface,
|
|||
const common::IntrinsicTypeDefaultKinds &defaults) {
|
||||
TypeCategory category{TypeCategory::Integer};
|
||||
switch (interface.result.kindCode) {
|
||||
case KindCode::defaultIntegerKind: break;
|
||||
case KindCode::defaultIntegerKind:
|
||||
break;
|
||||
case KindCode::doublePrecision:
|
||||
case KindCode::defaultRealKind: category = TypeCategory::Real; break;
|
||||
default: CRASH_NO_CASE;
|
||||
case KindCode::defaultRealKind:
|
||||
category = TypeCategory::Real;
|
||||
break;
|
||||
default:
|
||||
CRASH_NO_CASE;
|
||||
}
|
||||
int kind{interface.result.kindCode == KindCode::doublePrecision
|
||||
? defaults.doublePrecisionKind()
|
||||
|
@ -2063,4 +2089,4 @@ llvm::raw_ostream &IntrinsicProcTable::Implementation::Dump(
|
|||
llvm::raw_ostream &IntrinsicProcTable::Dump(llvm::raw_ostream &o) const {
|
||||
return impl_->Dump(o);
|
||||
}
|
||||
}
|
||||
} // namespace Fortran::evaluate
|
||||
|
|
|
@ -14,4 +14,4 @@ template class Logical<8>;
|
|||
template class Logical<16>;
|
||||
template class Logical<32>;
|
||||
template class Logical<64>;
|
||||
}
|
||||
} // namespace Fortran::evaluate::value
|
||||
|
|
|
@ -400,11 +400,16 @@ void Real<W, P>::NormalizeAndRound(ValueWithRealFlags<Real> &result,
|
|||
inline enum decimal::FortranRounding MapRoundingMode(
|
||||
common::RoundingMode rounding) {
|
||||
switch (rounding) {
|
||||
case common::RoundingMode::TiesToEven: break;
|
||||
case common::RoundingMode::ToZero: return decimal::RoundToZero;
|
||||
case common::RoundingMode::Down: return decimal::RoundDown;
|
||||
case common::RoundingMode::Up: return decimal::RoundUp;
|
||||
case common::RoundingMode::TiesAwayFromZero: return decimal::RoundCompatible;
|
||||
case common::RoundingMode::TiesToEven:
|
||||
break;
|
||||
case common::RoundingMode::ToZero:
|
||||
return decimal::RoundToZero;
|
||||
case common::RoundingMode::Down:
|
||||
return decimal::RoundDown;
|
||||
case common::RoundingMode::Up:
|
||||
return decimal::RoundUp;
|
||||
case common::RoundingMode::TiesAwayFromZero:
|
||||
return decimal::RoundCompatible;
|
||||
}
|
||||
return decimal::RoundNearest; // dodge gcc warning about lack of result
|
||||
}
|
||||
|
@ -522,4 +527,4 @@ template class Real<Integer<32>, 24>;
|
|||
template class Real<Integer<64>, 53>;
|
||||
template class Real<Integer<80>, 64>;
|
||||
template class Real<Integer<128>, 113>;
|
||||
}
|
||||
} // namespace Fortran::evaluate::value
|
||||
|
|
|
@ -653,4 +653,4 @@ bool CheckConformance(parser::ContextualMessages &messages, const Shape &left,
|
|||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} // namespace Fortran::evaluate
|
||||
|
|
|
@ -93,4 +93,4 @@ std::optional<std::u32string> StaticDataObject::AsU32String() const {
|
|||
}
|
||||
return std::nullopt;
|
||||
}
|
||||
}
|
||||
} // namespace Fortran::evaluate
|
||||
|
|
|
@ -705,8 +705,7 @@ bool IsProcedure(const Expr<SomeType> &expr) {
|
|||
}
|
||||
|
||||
bool IsProcedurePointer(const Expr<SomeType> &expr) {
|
||||
return std::visit(
|
||||
common::visitors{
|
||||
return std::visit(common::visitors{
|
||||
[](const NullPointer &) { return true; },
|
||||
[](const ProcedureDesignator &) { return true; },
|
||||
[](const ProcedureRef &) { return true; },
|
||||
|
|
|
@ -80,7 +80,7 @@ bool IsDescriptor(const Symbol &symbol) {
|
|||
},
|
||||
symbol.details());
|
||||
}
|
||||
}
|
||||
} // namespace Fortran::semantics
|
||||
|
||||
namespace Fortran::evaluate {
|
||||
|
||||
|
@ -256,7 +256,7 @@ static bool AreSameComponent(const semantics::Symbol &x,
|
|||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} // namespace Fortran::evaluate
|
||||
else {
|
||||
// TODO: non-object components
|
||||
return true;
|
||||
|
@ -387,37 +387,45 @@ DynamicType DynamicType::ResultTypeForMultiply(const DynamicType &that) const {
|
|||
case TypeCategory::Integer:
|
||||
return DynamicType{TypeCategory::Integer, std::max(kind_, that.kind_)};
|
||||
case TypeCategory::Real:
|
||||
case TypeCategory::Complex: return that;
|
||||
default: CRASH_NO_CASE;
|
||||
case TypeCategory::Complex:
|
||||
return that;
|
||||
default:
|
||||
CRASH_NO_CASE;
|
||||
}
|
||||
break;
|
||||
case TypeCategory::Real:
|
||||
switch (that.category_) {
|
||||
case TypeCategory::Integer: return *this;
|
||||
case TypeCategory::Integer:
|
||||
return *this;
|
||||
case TypeCategory::Real:
|
||||
return DynamicType{TypeCategory::Real, std::max(kind_, that.kind_)};
|
||||
case TypeCategory::Complex:
|
||||
return DynamicType{TypeCategory::Complex, std::max(kind_, that.kind_)};
|
||||
default: CRASH_NO_CASE;
|
||||
default:
|
||||
CRASH_NO_CASE;
|
||||
}
|
||||
break;
|
||||
case TypeCategory::Complex:
|
||||
switch (that.category_) {
|
||||
case TypeCategory::Integer: return *this;
|
||||
case TypeCategory::Integer:
|
||||
return *this;
|
||||
case TypeCategory::Real:
|
||||
case TypeCategory::Complex:
|
||||
return DynamicType{TypeCategory::Complex, std::max(kind_, that.kind_)};
|
||||
default: CRASH_NO_CASE;
|
||||
default:
|
||||
CRASH_NO_CASE;
|
||||
}
|
||||
break;
|
||||
case TypeCategory::Logical:
|
||||
switch (that.category_) {
|
||||
case TypeCategory::Logical:
|
||||
return DynamicType{TypeCategory::Logical, std::max(kind_, that.kind_)};
|
||||
default: CRASH_NO_CASE;
|
||||
default:
|
||||
CRASH_NO_CASE;
|
||||
}
|
||||
break;
|
||||
default: CRASH_NO_CASE;
|
||||
default:
|
||||
CRASH_NO_CASE;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
@ -557,4 +565,4 @@ int SelectedRealKind(
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace Fortran::evaluate
|
||||
|
|
|
@ -230,7 +230,8 @@ std::optional<Expr<SomeCharacter>> Substring::Fold(FoldingContext &context) {
|
|||
case 4:
|
||||
return {AsCategoryExpr(Constant<Type<TypeCategory::Character, 4>>{
|
||||
*newStaticData->AsU32String()})};
|
||||
default: CRASH_NO_CASE;
|
||||
default:
|
||||
CRASH_NO_CASE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -298,8 +299,7 @@ std::optional<Expr<SubscriptInteger>> CoarrayRef::LEN() const {
|
|||
}
|
||||
|
||||
std::optional<Expr<SubscriptInteger>> DataRef::LEN() const {
|
||||
return std::visit(
|
||||
common::visitors{
|
||||
return std::visit(common::visitors{
|
||||
[](SymbolRef symbol) { return SymbolLEN(symbol); },
|
||||
[](const auto &x) { return x.LEN(); },
|
||||
},
|
||||
|
@ -319,8 +319,7 @@ std::optional<Expr<SubscriptInteger>> Substring::LEN() const {
|
|||
template <typename T>
|
||||
std::optional<Expr<SubscriptInteger>> Designator<T>::LEN() const {
|
||||
if constexpr (T::category == TypeCategory::Character) {
|
||||
return std::visit(
|
||||
common::visitors{
|
||||
return std::visit(common::visitors{
|
||||
[](SymbolRef symbol) { return SymbolLEN(symbol); },
|
||||
[](const auto &x) { return x.LEN(); },
|
||||
},
|
||||
|
@ -354,8 +353,7 @@ std::optional<Expr<SubscriptInteger>> ProcedureDesignator::LEN() const {
|
|||
|
||||
// Rank()
|
||||
int BaseObject::Rank() const {
|
||||
return std::visit(
|
||||
common::visitors{
|
||||
return std::visit(common::visitors{
|
||||
[](SymbolRef symbol) { return symbol->Rank(); },
|
||||
[](const StaticDataObject::Pointer &) { return 0; },
|
||||
},
|
||||
|
@ -370,8 +368,7 @@ int Component::Rank() const {
|
|||
}
|
||||
|
||||
int NamedEntity::Rank() const {
|
||||
return std::visit(
|
||||
common::visitors{
|
||||
return std::visit(common::visitors{
|
||||
[](const SymbolRef s) { return s->Rank(); },
|
||||
[](const Component &c) { return c.Rank(); },
|
||||
},
|
||||
|
@ -379,8 +376,7 @@ int NamedEntity::Rank() const {
|
|||
}
|
||||
|
||||
int Subscript::Rank() const {
|
||||
return std::visit(
|
||||
common::visitors{
|
||||
return std::visit(common::visitors{
|
||||
[](const IndirectSubscriptIntegerExpr &x) {
|
||||
return x.value().Rank();
|
||||
},
|
||||
|
@ -416,8 +412,7 @@ int CoarrayRef::Rank() const {
|
|||
}
|
||||
|
||||
int DataRef::Rank() const {
|
||||
return std::visit(
|
||||
common::visitors{
|
||||
return std::visit(common::visitors{
|
||||
[](SymbolRef symbol) { return symbol->Rank(); },
|
||||
[](const auto &x) { return x.Rank(); },
|
||||
},
|
||||
|
@ -425,8 +420,7 @@ int DataRef::Rank() const {
|
|||
}
|
||||
|
||||
int Substring::Rank() const {
|
||||
return std::visit(
|
||||
common::visitors{
|
||||
return std::visit(common::visitors{
|
||||
[](const DataRef &dataRef) { return dataRef.Rank(); },
|
||||
[](const StaticDataObject::Pointer &) { return 0; },
|
||||
},
|
||||
|
@ -436,8 +430,7 @@ int Substring::Rank() const {
|
|||
int ComplexPart::Rank() const { return complex_.Rank(); }
|
||||
|
||||
template <typename T> int Designator<T>::Rank() const {
|
||||
return std::visit(
|
||||
common::visitors{
|
||||
return std::visit(common::visitors{
|
||||
[](SymbolRef symbol) { return symbol->Rank(); },
|
||||
[](const auto &x) { return x.Rank(); },
|
||||
},
|
||||
|
@ -450,8 +443,7 @@ const Symbol &Component::GetFirstSymbol() const {
|
|||
}
|
||||
|
||||
const Symbol &NamedEntity::GetFirstSymbol() const {
|
||||
return std::visit(
|
||||
common::visitors{
|
||||
return std::visit(common::visitors{
|
||||
[](SymbolRef s) -> const Symbol & { return s; },
|
||||
[](const Component &c) -> const Symbol & {
|
||||
return c.GetFirstSymbol();
|
||||
|
@ -461,8 +453,7 @@ const Symbol &NamedEntity::GetFirstSymbol() const {
|
|||
}
|
||||
|
||||
const Symbol &NamedEntity::GetLastSymbol() const {
|
||||
return std::visit(
|
||||
common::visitors{
|
||||
return std::visit(common::visitors{
|
||||
[](SymbolRef s) -> const Symbol & { return s; },
|
||||
[](const Component &c) -> const Symbol & {
|
||||
return c.GetLastSymbol();
|
||||
|
@ -472,8 +463,7 @@ const Symbol &NamedEntity::GetLastSymbol() const {
|
|||
}
|
||||
|
||||
const Component *NamedEntity::UnwrapComponent() const {
|
||||
return std::visit(
|
||||
common::visitors{
|
||||
return std::visit(common::visitors{
|
||||
[](SymbolRef) -> const Component * { return nullptr; },
|
||||
[](const Component &c) { return &c; },
|
||||
},
|
||||
|
@ -481,8 +471,7 @@ const Component *NamedEntity::UnwrapComponent() const {
|
|||
}
|
||||
|
||||
Component *NamedEntity::UnwrapComponent() {
|
||||
return std::visit(
|
||||
common::visitors{
|
||||
return std::visit(common::visitors{
|
||||
[](SymbolRef &) -> Component * { return nullptr; },
|
||||
[](Component &c) { return &c; },
|
||||
},
|
||||
|
@ -496,8 +485,7 @@ const Symbol &ArrayRef::GetFirstSymbol() const {
|
|||
const Symbol &ArrayRef::GetLastSymbol() const { return base_.GetLastSymbol(); }
|
||||
|
||||
const Symbol &DataRef::GetFirstSymbol() const {
|
||||
return *std::visit(
|
||||
common::visitors{
|
||||
return *std::visit(common::visitors{
|
||||
[](SymbolRef symbol) { return &*symbol; },
|
||||
[](const auto &x) { return &x.GetFirstSymbol(); },
|
||||
},
|
||||
|
@ -505,8 +493,7 @@ const Symbol &DataRef::GetFirstSymbol() const {
|
|||
}
|
||||
|
||||
const Symbol &DataRef::GetLastSymbol() const {
|
||||
return *std::visit(
|
||||
common::visitors{
|
||||
return *std::visit(common::visitors{
|
||||
[](SymbolRef symbol) { return &*symbol; },
|
||||
[](const auto &x) { return &x.GetLastSymbol(); },
|
||||
},
|
||||
|
@ -514,8 +501,7 @@ const Symbol &DataRef::GetLastSymbol() const {
|
|||
}
|
||||
|
||||
BaseObject Substring::GetBaseObject() const {
|
||||
return std::visit(
|
||||
common::visitors{
|
||||
return std::visit(common::visitors{
|
||||
[](const DataRef &dataRef) {
|
||||
return BaseObject{dataRef.GetFirstSymbol()};
|
||||
},
|
||||
|
@ -571,7 +557,8 @@ template<typename T> const Symbol *Designator<T>::GetLastSymbol() const {
|
|||
u);
|
||||
}
|
||||
|
||||
template<typename T> std::optional<DynamicType> Designator<T>::GetType() const {
|
||||
template <typename T>
|
||||
std::optional<DynamicType> Designator<T>::GetType() const {
|
||||
if constexpr (IsLengthlessIntrinsicType<Result>) {
|
||||
return {Result::GetType()};
|
||||
} else {
|
||||
|
@ -684,6 +671,6 @@ bool DescriptorInquiry::operator==(const DescriptorInquiry &that) const {
|
|||
}
|
||||
|
||||
INSTANTIATE_VARIABLE_TEMPLATES
|
||||
}
|
||||
} // namespace Fortran::evaluate
|
||||
|
||||
template class Fortran::common::Indirection<Fortran::evaluate::Component, true>;
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue