mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Removed an invalid exemption for abstract classes.
This commit is contained in:
parent
1feac1a80a
commit
822ae5e4a9
2 changed files with 7 additions and 23 deletions
|
@ -8,6 +8,7 @@
|
|||
* Contributors:
|
||||
* Alena Laskavaia - initial API and implementation
|
||||
* Patrick Hofer [bug 315528]
|
||||
* Sergey Prigogin (Google)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.codan.internal.checkers;
|
||||
|
||||
|
@ -83,11 +84,7 @@ public class NonVirtualDestructor extends AbstractIndexAstChecker {
|
|||
}
|
||||
ICPPMethod virtualMethod = null;
|
||||
for (ICPPMethod method : classType.getAllDeclaredMethods()) {
|
||||
if (method.isPureVirtual()) {
|
||||
// Class has at least one pure virtual method, it is abstract
|
||||
// and cannot be instantiated.
|
||||
return PROCESS_SKIP;
|
||||
} else if (method.isVirtual() && !method.isDestructor()) {
|
||||
if (!method.isDestructor() && method.isVirtual()) {
|
||||
virtualMethod = method;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,6 +7,8 @@
|
|||
*
|
||||
* Contributors:
|
||||
* Patrick Hofer - Initial API and implementation
|
||||
* Tomasz Wesolowski
|
||||
* Sergey Prigogin (Google)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.codan.core.internal.checkers;
|
||||
|
||||
|
@ -143,9 +145,7 @@ public class NonVirtualDestructorCheckerTest extends CheckerTestCase {
|
|||
checkErrorLines(3, 7, 11, 13);
|
||||
}
|
||||
|
||||
// class A { // OK. Do _not_ warn here.
|
||||
// // A is an abstract class because it has one pure virtual method.
|
||||
// // A cannot be instantiated.
|
||||
// class A {
|
||||
// virtual void f1() { };
|
||||
// virtual void f2() = 0;
|
||||
// };
|
||||
|
@ -157,7 +157,8 @@ public class NonVirtualDestructorCheckerTest extends CheckerTestCase {
|
|||
// };
|
||||
public void testAbstractBaseClass() {
|
||||
loadCodeAndRun(getAboveComment());
|
||||
checkNoErrors();
|
||||
// It doesn't matter if the class is abstract or not - dtor can be called polymorphically.
|
||||
checkErrorLines(1);
|
||||
}
|
||||
|
||||
// struct Base {
|
||||
|
@ -180,18 +181,4 @@ public class NonVirtualDestructorCheckerTest extends CheckerTestCase {
|
|||
loadCodeAndRun(getAboveComment());
|
||||
checkErrorLines(4);
|
||||
}
|
||||
|
||||
// struct IBase {
|
||||
// virtual void foo() = 0;
|
||||
// };
|
||||
// struct IDerived : IBase {
|
||||
// };
|
||||
// struct ADerived : IDerived {
|
||||
// void foo();
|
||||
// virtual void bar() = 0;
|
||||
// };
|
||||
public void testInheritedAbstractClasses() {
|
||||
loadCodeAndRun(getAboveComment());
|
||||
checkNoErrors();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue