Eclipse cdt code analysis does not understand virtual inheritance

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; //Copy of the pointer with a different type public: BDecorator(B* b) : ADecorator(b), decoratedB(b) {} void bar() {return decoratedB->bar();} }; class BImpl : public B, public AImpl { public: void bar() {}; }; B* b = new BDecorator(new BImpl()); } 

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.

+7
c ++ eclipse virtual-inheritance eclipse-cdt code-analysis
source share
1 answer

I think you might have to index your code again. Right-click on your project in the project explorer, click Index and then click Refresh All Files. This will force eclipse to index all of your code.

+2
source share

All Articles