Skip to content

Commit

Permalink
Fix C++20 compilation errors (verilator#4670)
Browse files Browse the repository at this point in the history
  • Loading branch information
wsnyder authored Nov 6, 2023
1 parent 27102ea commit dc10118
Show file tree
Hide file tree
Showing 11 changed files with 118 additions and 109 deletions.
2 changes: 1 addition & 1 deletion include/verilated_timing.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
using namespace experimental; // Bring std::experimental into the std namespace
}
#else
# if defined __clang__ && defined __GLIBCXX__
# if defined __clang__ && defined __GLIBCXX__ && !defined __cpp_impl_coroutine
# define __cpp_impl_coroutine 1 // Clang doesn't define this, but it's needed for libstdc++
# endif
# include <coroutine>
Expand Down
10 changes: 7 additions & 3 deletions src/V3Ast.h
Original file line number Diff line number Diff line change
Expand Up @@ -757,11 +757,15 @@ class VDirection final {
bool isRef() const VL_MT_SAFE { return m_e == REF; }
bool isConstRef() const VL_MT_SAFE { return m_e == CONSTREF; }
};
constexpr bool operator==(const VDirection& lhs, const VDirection& rhs) {
constexpr bool operator==(const VDirection& lhs, const VDirection& rhs) VL_MT_SAFE {
return lhs.m_e == rhs.m_e;
}
constexpr bool operator==(const VDirection& lhs, VDirection::en rhs) { return lhs.m_e == rhs; }
constexpr bool operator==(VDirection::en lhs, const VDirection& rhs) { return lhs == rhs.m_e; }
constexpr bool operator==(const VDirection& lhs, VDirection::en rhs) VL_MT_SAFE {
return lhs.m_e == rhs;
}
constexpr bool operator==(VDirection::en lhs, const VDirection& rhs) VL_MT_SAFE {
return lhs == rhs.m_e;
}
inline std::ostream& operator<<(std::ostream& os, const VDirection& rhs) {
return os << rhs.ascii();
}
Expand Down
8 changes: 1 addition & 7 deletions src/V3AstNodeDType.h
Original file line number Diff line number Diff line change
Expand Up @@ -777,13 +777,7 @@ class AstEnumDType final : public AstNodeDType {
}
ASTGEN_MEMBERS_AstEnumDType;

const char* broken() const override {
BROKEN_RTN(!((m_refDTypep && !childDTypep() && m_refDTypep->brokeExists())
|| (!m_refDTypep && childDTypep())));
BROKEN_RTN(std::any_of(m_tableMap.begin(), m_tableMap.end(),
[](const auto& p) { return !p.second->brokeExists(); }));
return nullptr;
}
const char* broken() const override;
void cloneRelink() override {
if (m_refDTypep && m_refDTypep->clonep()) m_refDTypep = m_refDTypep->clonep();
}
Expand Down
8 changes: 8 additions & 0 deletions src/V3AstNodes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1577,6 +1577,14 @@ void AstEnumItemRef::dump(std::ostream& str) const {
str << "UNLINKED";
}
}
const char* AstEnumDType::broken() const {
BROKEN_RTN(!((m_refDTypep && !childDTypep() && m_refDTypep->brokeExists())
|| (!m_refDTypep && childDTypep())));
BROKEN_RTN(std::any_of(m_tableMap.begin(), m_tableMap.end(),
[](const auto& p) { return !p.second->brokeExists(); }));
return nullptr;
}

const char* AstEnumItemRef::broken() const {
BROKEN_RTN(m_itemp && !m_itemp->brokeExists());
BROKEN_RTN(m_classOrPackagep && !m_classOrPackagep->brokeExists());
Expand Down
2 changes: 1 addition & 1 deletion src/V3Const.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1126,7 +1126,7 @@ class ConstVisitor final : public VNVisitor {
// commonly appears after V3Expand and the simplification in matchMaskedOr. Similarly,
// drop redundant masking of left shift result. E.g.: 0xff000000 & ((uint32_t)a << 24).

const auto checkMask = [=](const V3Number& mask) -> bool {
const auto checkMask = [nodep, this](const V3Number& mask) -> bool {
const AstConst* const constp = VN_AS(nodep->lhsp(), Const);
if (constp->num().isCaseEq(mask)) {
AstNode* const rhsp = nodep->rhsp();
Expand Down
4 changes: 2 additions & 2 deletions src/V3Dfg.h
Original file line number Diff line number Diff line change
Expand Up @@ -752,13 +752,13 @@ class DfgVertexWithArity VL_NOT_FINAL : public DfgVertex {
std::array<DfgEdge, Arity> m_srcs; // Source edges

protected:
DfgVertexWithArity<Arity>(DfgGraph& dfg, VDfgType type, FileLine* flp, AstNodeDType* dtypep)
DfgVertexWithArity(DfgGraph& dfg, VDfgType type, FileLine* flp, AstNodeDType* dtypep)
: DfgVertex{dfg, type, flp, dtypep} {
// Initialize source edges
for (size_t i = 0; i < Arity; ++i) m_srcs[i].init(this);
}

~DfgVertexWithArity<Arity>() override = default;
~DfgVertexWithArity() override = default;

public:
std::pair<DfgEdge*, size_t> sourceEdges() final override { //
Expand Down
4 changes: 2 additions & 2 deletions src/V3DfgDecomposition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -292,11 +292,11 @@ class ExtractCyclicComponents final {

// Visit all neighbors. We stop at variable boundaries,
// which is where we will split the graphs
vtx.forEachSource([=](DfgVertex& other) {
vtx.forEachSource([this, targetComponent](DfgVertex& other) {
if (other.is<DfgVertexVar>()) return;
visitMergeSCCs(other, targetComponent);
});
vtx.forEachSink([=](DfgVertex& other) {
vtx.forEachSink([this, targetComponent](DfgVertex& other) {
if (other.is<DfgVertexVar>()) return;
visitMergeSCCs(other, targetComponent);
});
Expand Down
2 changes: 1 addition & 1 deletion src/V3DfgVertices.h
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ class DfgVarArray final : public DfgVertexVar {
uint32_t driverIndex(size_t idx) const { return m_driverData[idx].second; }

DfgVertex* driverAt(size_t idx) const {
const DfgEdge* const edgep = findSourceEdge([=](const DfgEdge&, size_t i) { //
const DfgEdge* const edgep = findSourceEdge([this, idx](const DfgEdge&, size_t i) { //
return driverIndex(i) == idx;
});
return edgep ? edgep->sourcep() : nullptr;
Expand Down
Loading

0 comments on commit dc10118

Please sign in to comment.