[flang] Address review comments

Use better names for template parameters of `LoopBounds`, and also
for the constructor arguments.

Use two overloadings of `loopBounds()` instead of `std::is_same_v<>`.

Original-commit: flang-compiler/f18@a2c0c75462
Reviewed-on: https://github.com/flang-compiler/f18/pull/455
Tree-same-pre-rewrite: false
This commit is contained in:
Tim Keith 2019-05-09 10:00:13 -07:00
parent 351dc98948
commit 4c4f4d2807
2 changed files with 15 additions and 14 deletions

View File

@ -962,14 +962,14 @@ constexpr auto doVariable{scalar(integer(name))};
// NOTE: In loop-control we allow REAL name and bounds too.
// This means parse them without the integer constraint and check later.
inline constexpr auto loopBounds(decltype(scalarExpr) &p) {
return construct<LoopBounds<ScalarName, ScalarExpr>>(
scalar(name) / "=", p / ",", p, maybe("," >> p));
}
template<typename PA> inline constexpr auto loopBounds(const PA &p) {
if constexpr (std::is_same_v<typename PA::resultType, ScalarExpr>) {
return construct<LoopBounds<ScalarName, typename PA::resultType>>(
scalar(name) / "=", p / ",", p, maybe("," >> p));
} else {
return construct<LoopBounds<DoVariable, typename PA::resultType>>(
doVariable / "=", p / ",", p, maybe("," >> p));
}
return construct<LoopBounds<DoVariable, typename PA::resultType>>(
doVariable / "=", p / ",", p, maybe("," >> p));
}
// R769 array-constructor -> (/ ac-spec /) | lbracket ac-spec rbracket

View File

@ -1208,15 +1208,16 @@ WRAPPER_CLASS(ArrayConstructor, AcSpec);
// R1124 do-variable -> scalar-int-variable-name
using DoVariable = Scalar<Integer<Name>>;
template<typename A, typename B> struct LoopBounds {
template<typename VAR, typename BOUND> struct LoopBounds {
LoopBounds(LoopBounds &&that) = default;
LoopBounds(A &&n, B &&a, B &&z, std::optional<B> &&s)
: name{std::move(n)}, lower{std::move(a)}, upper{std::move(z)},
step{std::move(s)} {}
LoopBounds(
VAR &&name, BOUND &&lower, BOUND &&upper, std::optional<BOUND> &&step)
: name{std::move(name)}, lower{std::move(lower)}, upper{std::move(upper)},
step{std::move(step)} {}
LoopBounds &operator=(LoopBounds &&) = default;
A name;
B lower, upper;
std::optional<B> step;
VAR name;
BOUND lower, upper;
std::optional<BOUND> step;
};
using ScalarName = Scalar<Name>;