diff --git a/src/V3AstNodeOther.h b/src/V3AstNodeOther.h index c39932f6a..932aedaa9 100644 --- a/src/V3AstNodeOther.h +++ b/src/V3AstNodeOther.h @@ -488,7 +488,6 @@ class AstCFunc final : public AstNode { // an explicitly passed 'self' pointer as the first argument. This can // be slightly faster due to __restrict, and we do not declare in header // so adding/removing loose functions doesn't recompile everything. - bool m_isOverride : 1; // Override virtual function bool m_isVirtual : 1; // Virtual function bool m_entryPoint : 1; // User may call into this top level function bool m_dpiPure : 1; // Pure DPI function @@ -520,7 +519,6 @@ public: m_isDestructor = false; m_isMethod = true; m_isLoose = false; - m_isOverride = false; m_isVirtual = false; m_needProcess = false; m_entryPoint = false; @@ -584,11 +582,6 @@ public: bool isLoose() const { return m_isLoose; } void isLoose(bool flag) { m_isLoose = flag; } bool isProperMethod() const { return isMethod() && !isLoose(); } - bool isOverride() const { return m_isOverride; } - void isOverride(bool flag) { - m_isOverride = flag; - if (flag) isVirtual(true); - } bool isVirtual() const { return m_isVirtual; } void isVirtual(bool flag) { m_isVirtual = flag; } bool needProcess() const { return m_needProcess; } diff --git a/src/V3AstNodes.cpp b/src/V3AstNodes.cpp index 02795920d..afd4a978d 100644 --- a/src/V3AstNodes.cpp +++ b/src/V3AstNodes.cpp @@ -3233,7 +3233,6 @@ void AstCFunc::dump(std::ostream& str) const { if (isDestructor()) str << " [DTOR]"; if (isMethod()) str << " [METHOD]"; if (isLoose()) str << " [LOOSE]"; - if (isOverride()) str << " [OVERRIDE]"; if (isVirtual()) str << " [VIRT]"; if (isCoroutine()) str << " [CORO]"; if (needProcess()) str << " [NPRC]"; @@ -3250,7 +3249,6 @@ void AstCFunc::dumpJson(std::ostream& str) const { dumpJsonBoolFuncIf(str, dpiContext); dumpJsonBoolFuncIf(str, isConstructor); dumpJsonBoolFuncIf(str, isDestructor); - dumpJsonBoolFuncIf(str, isOverride); dumpJsonBoolFuncIf(str, isVirtual); dumpJsonBoolFuncIf(str, isCoroutine); dumpJsonBoolFuncIf(str, needProcess); diff --git a/src/V3Common.cpp b/src/V3Common.cpp index fdb66d65c..b86a2146b 100644 --- a/src/V3Common.cpp +++ b/src/V3Common.cpp @@ -94,7 +94,7 @@ static void makeToString(AstClass* nodep) { AstCFunc* const funcp = new AstCFunc{nodep->fileline(), "to_string", nullptr, "std::string"}; funcp->isConst(true); funcp->isStatic(false); - funcp->isOverride(true); + funcp->isVirtual(true); funcp->protect(false); AstCExpr* const exprp = new AstCExpr{nodep->fileline(), R"("'{"s + to_string_middle() + "}")"}; exprp->dtypeSetString(); diff --git a/src/V3EmitCBase.cpp b/src/V3EmitCBase.cpp index b09447aca..667983199 100644 --- a/src/V3EmitCBase.cpp +++ b/src/V3EmitCBase.cpp @@ -153,10 +153,11 @@ void EmitCBaseVisitorConst::emitCFuncDecl(const AstCFunc* funcp, const AstNodeMo if (funcp->isStatic() && funcp->isProperMethod()) putns(funcp, "static "); if (funcp->isVirtual()) { UASSERT_OBJ(funcp->isProperMethod(), funcp, "Virtual function is not a proper method"); - if (!funcp->isOverride()) putns(funcp, "virtual "); + putns(funcp, "virtual "); + // Intentionally no emit for "override" instead, as clang will then enable warning + // on other methods where virtual vs override is needed, and this is not tracked yet } emitCFuncHeader(funcp, modp, /* withScope: */ false); - if (funcp->isOverride()) putns(funcp, " override"); if (funcp->emptyBody() && !funcp->isLoose() && !cLinkage) { putns(funcp, " {}\n"); } else { diff --git a/src/V3EmitCHeaders.cpp b/src/V3EmitCHeaders.cpp index a7817fd13..869e9e636 100644 --- a/src/V3EmitCHeaders.cpp +++ b/src/V3EmitCHeaders.cpp @@ -187,7 +187,8 @@ class EmitCHeader final : public EmitCConstInit { decorateFirst(first, section); const std::string name = V3OutFormatter::quoteNameControls( VIdProtect::protectWordsIf(modp->prettyName(), v3Global.opt.protectIds())); - puts("const char* typeName() const override { return \""s + name + "\"; }\n"); + // "override", but don't want clang to start checking them: + puts("virtual const char* typeName() const { return \""s + name + "\"; }\n"); } if (v3Global.opt.coverage() && !VN_IS(modp, Class)) { diff --git a/test_regress/t/t_dist_cppstyle.py b/test_regress/t/t_dist_cppstyle.py index 719d869e5..8c79df855 100755 --- a/test_regress/t/t_dist_cppstyle.py +++ b/test_regress/t/t_dist_cppstyle.py @@ -62,7 +62,7 @@ for filename in sorted(files.keys()): contents = test.file_contents(filename) + "\n\n" - check_pattern(filename, contents, r"[^\']*virtual[^{};\n]+override[^\n]*", None, + check_pattern(filename, contents, r"[^\'/]*virtual[^{};\n]+override[^\n]*", None, "'virtual' keyword is redundant on 'override' method") check_pattern(filename, contents,