I have a class hierarchy with two diamonds, caused by the need to expand all classes in the decorator template (they are almost expanding):
namespace _sandbox { class A { public: virtual ~A() {} virtual void foo()=0; }; class ADecorator : public virtual A { private: A* decoratedA; public: ADecorator(A* a) : decoratedA(a) {} void foo() {return decoratedA->foo();} }; class AImpl : public virtual A { public: void foo() {}; }; class B : public virtual A { public: virtual ~B() {} virtual void bar()=0; }; class BDecorator : public ADecorator, public B { private: B* decoratedB;
Graphically:
A /|\ v /v| \ v / | \ AImpl B ADecorator | / \ | | / \ | |/ \| BImpl BDecorator
GCC compiles this without a problem, but eclipse code analysis insists that BDecorator does not implement foo ()
The type '_sandbox::BDecorator' must implement the inherited pure virtual method '_sandbox::A::foo'
I can disable this problem by setting this type of error to โInformationโ in the settings, but I wonder if there is actually a mistake in the code that GCC ignores, or if I can do something to make the code. Analysis accepts the code? If possible, I would prefer that this code analysis feature not be disabled, so I can easily detect actual errors.
How is BImpl different from BDecorator in terms of what methods it implements? Code analysis says nothing about BImpl, but the way to implement foo () is similar.
c ++ eclipse virtual-inheritance eclipse-cdt code-analysis
Baro
source share