Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSergey Prigogin2011-07-17 20:20:16 -0400
committerSergey Prigogin2011-07-17 22:07:11 -0400
commit21e056c85659a76f88f4a26de0e0704c9ed1756a (patch)
tree10aca629091b87bfcf2b5e5b0354c9d85695c9f1 /codan/org.eclipse.cdt.codan.core.test
parente6b07afaf6e6ef100cbc5d09fa8442a0718c3c96 (diff)
downloadorg.eclipse.cdt-21e056c85659a76f88f4a26de0e0704c9ed1756a.tar.gz
org.eclipse.cdt-21e056c85659a76f88f4a26de0e0704c9ed1756a.tar.xz
org.eclipse.cdt-21e056c85659a76f88f4a26de0e0704c9ed1756a.zip
Bug 315528 - [fp] Non-virtual destructor diagnostics doesn't take
superclass into account. Fix and additional tests including the ones contributed by Tomasz Wesolowski.
Diffstat (limited to 'codan/org.eclipse.cdt.codan.core.test')
-rw-r--r--codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/internal/checkers/NonVirtualDestructorCheckerTest.java59
1 files changed, 55 insertions, 4 deletions
diff --git a/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/internal/checkers/NonVirtualDestructorCheckerTest.java b/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/internal/checkers/NonVirtualDestructorCheckerTest.java
index a86b87dafb..4a587027b8 100644
--- a/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/internal/checkers/NonVirtualDestructorCheckerTest.java
+++ b/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/internal/checkers/NonVirtualDestructorCheckerTest.java
@@ -14,7 +14,7 @@ import org.eclipse.cdt.codan.core.test.CheckerTestCase;
import org.eclipse.cdt.codan.internal.checkers.NonVirtualDestructor;
/**
- * Test for {@see NonVirtualDestructor} class.
+ * Test for {@link NonVirtualDestructor} class.
*/
public class NonVirtualDestructorCheckerTest extends CheckerTestCase {
@Override
@@ -25,7 +25,7 @@ public class NonVirtualDestructorCheckerTest extends CheckerTestCase {
@Override
public void setUp() throws Exception {
super.setUp();
- enableProblems(NonVirtualDestructor.ER_ID);
+ enableProblems(NonVirtualDestructor.PROBLEM_ID);
}
// struct A {
@@ -86,7 +86,7 @@ public class NonVirtualDestructorCheckerTest extends CheckerTestCase {
// struct B {
// ~B(); // ok.
// };
- public void testVirtualDtorInBaseClass() {
+ public void testVirtualDtorInBaseClass1() {
loadCodeAndRun(getAboveComment());
checkNoErrors();
}
@@ -108,6 +108,22 @@ public class NonVirtualDestructorCheckerTest extends CheckerTestCase {
checkNoErrors();
}
+ // class A {
+ // public:
+ // virtual ~A();
+ // };
+ //
+ // class B : public A {
+ // public:
+ // ~B();
+ // virtual void m();
+ // friend class C;
+ // };
+ public void testVirtualDtorInBaseClass3() {
+ loadCodeAndRun(getAboveComment());
+ checkNoErrors();
+ }
+
// struct A {
// virtual void f() { };
// ~A(); // warn! public non-virtual dtor.
@@ -122,7 +138,7 @@ public class NonVirtualDestructorCheckerTest extends CheckerTestCase {
//
// struct E : public D {
// };
- public void testNonVirtualDtorInBaseClass2() {
+ public void testNonVirtualDtorInBaseClass() {
loadCodeAndRun(getAboveComment());
checkErrorLines(3, 7, 11, 13);
}
@@ -143,4 +159,39 @@ public class NonVirtualDestructorCheckerTest extends CheckerTestCase {
loadCodeAndRun(getAboveComment());
checkNoErrors();
}
+
+ // struct Base {
+ // };
+ // struct Derived : Base {
+ // virtual void bar();
+ // };
+ public void testImplicitDtorInBaseClass() {
+ loadCodeAndRun(getAboveComment());
+ checkErrorLines(3);
+ }
+
+ // struct Base {
+ // ~Base();
+ // };
+ // struct Derived : Base {
+ // virtual void bar();
+ // };
+ public void testExplicitDtorInBaseClass() {
+ 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();
+ }
}

Back to the top