Skip to content

Commit 7cbb365

Browse files
authored
[flang] Fix broken shared library build (#112444)
I just introduced a dependency from the Evaluate library to the Semantics library, which is circular in a shared library build. Rearrange the code a little to ensure that the dependence is only on a header.
1 parent 4c89473 commit 7cbb365

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

flang/include/flang/Semantics/type.h

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,13 @@ namespace Fortran::parser {
2929
struct Keyword;
3030
}
3131

32+
namespace Fortran::evaluate { // avoid including all of Evaluate/tools.h
33+
template <typename T>
34+
std::optional<bool> AreEquivalentInInterface(const Expr<T> &, const Expr<T> &);
35+
extern template std::optional<bool> AreEquivalentInInterface<SomeInteger>(
36+
const Expr<SomeInteger> &, const Expr<SomeInteger> &);
37+
} // namespace Fortran::evaluate
38+
3239
namespace Fortran::semantics {
3340

3441
class Scope;
@@ -110,7 +117,11 @@ class ParamValue {
110117
return category_ == that.category_ && expr_ == that.expr_;
111118
}
112119
bool operator!=(const ParamValue &that) const { return !(*this == that); }
113-
bool IsEquivalentInInterface(const ParamValue &) const;
120+
bool IsEquivalentInInterface(const ParamValue &that) const {
121+
return (category_ == that.category_ &&
122+
expr_.has_value() == that.expr_.has_value() &&
123+
(!expr_ || evaluate::AreEquivalentInInterface(*expr_, *that.expr_)));
124+
}
114125
std::string AsFortran() const;
115126

116127
private:

flang/lib/Semantics/type.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -758,12 +758,6 @@ void ParamValue::SetExplicit(SomeIntExpr &&x) {
758758
expr_ = std::move(x);
759759
}
760760

761-
bool ParamValue::IsEquivalentInInterface(const ParamValue &that) const {
762-
return (category_ == that.category_ &&
763-
expr_.has_value() == that.expr_.has_value() &&
764-
(!expr_ || evaluate::AreEquivalentInInterface(*expr_, *that.expr_)));
765-
}
766-
767761
std::string ParamValue::AsFortran() const {
768762
switch (category_) {
769763
SWITCH_COVERS_ALL_CASES

0 commit comments

Comments
 (0)