Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSergey Prigogin2011-05-28 00:57:43 -0400
committerSergey Prigogin2011-05-28 00:57:43 -0400
commitf651a8baa6663b12cbd1022e925b287c9e26fb3c (patch)
tree516ff345af53a6bbaaa9743b7e5a11f57ee38c4d /codan/org.eclipse.cdt.codan.core.test
parent46695ac68bb2968a36065dca95da3effaf05d8fb (diff)
downloadorg.eclipse.cdt-f651a8baa6663b12cbd1022e925b287c9e26fb3c.tar.gz
org.eclipse.cdt-f651a8baa6663b12cbd1022e925b287c9e26fb3c.tar.xz
org.eclipse.cdt-f651a8baa6663b12cbd1022e925b287c9e26fb3c.zip
Bug 315528 - [fp] Non-virtual destructor diagnostics doesn't take superclass into account. Patch by Patrick Hofer.
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.java32
1 files changed, 25 insertions, 7 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 eaefcc8cc3..a86b87dafb 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
@@ -48,7 +48,7 @@ public class NonVirtualDestructorCheckerTest extends CheckerTestCase {
}
// struct A {
- // virtual void f() = 0;
+ // virtual void f() { };
// ~A(); // warn! public non-virtual dtor.
// };
public void testPublicVirtualDtorInClass() {
@@ -57,7 +57,7 @@ public class NonVirtualDestructorCheckerTest extends CheckerTestCase {
}
// struct A {
- // virtual void f() = 0;
+ // virtual void f() { };
// // warn! implicit public non-virtual dtor.
// };
public void testImplicitPublicNonVirtualDtorInClass() {
@@ -68,7 +68,7 @@ public class NonVirtualDestructorCheckerTest extends CheckerTestCase {
// struct F { };
//
// struct A {
- // virtual void f() = 0;
+ // virtual void f() { };
// private:
// friend class F;
// ~A(); // warn! can be called from class F.
@@ -79,7 +79,7 @@ public class NonVirtualDestructorCheckerTest extends CheckerTestCase {
}
// struct A {
- // virtual void f() = 0;
+ // virtual void f() { };
// virtual ~A();
// };
//
@@ -92,7 +92,7 @@ public class NonVirtualDestructorCheckerTest extends CheckerTestCase {
}
// struct A {
- // virtual void f() = 0;
+ // virtual void f() { };
// virtual ~A(); // ok.
// };
//
@@ -109,7 +109,7 @@ public class NonVirtualDestructorCheckerTest extends CheckerTestCase {
}
// struct A {
- // virtual void f() = 0;
+ // virtual void f() { };
// ~A(); // warn! public non-virtual dtor.
// // this affects B, D and E further down in the hierarchy as well
// };
@@ -122,7 +122,25 @@ public class NonVirtualDestructorCheckerTest extends CheckerTestCase {
//
// struct E : public D {
// };
- public void _testNonVirtualDtorInBaseClass2() {
+ public void testNonVirtualDtorInBaseClass2() {
+ loadCodeAndRun(getAboveComment());
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.
+ // virtual void f1() { };
+ // virtual void f2() = 0;
+ // };
+ //
+ // class B : public A {
+ // virtual void f1() { };
+ // virtual void f2() { };
+ // virtual ~B();
+ // };
+ public void testAbstractBaseClass() {
+ loadCodeAndRun(getAboveComment());
+ checkNoErrors();
+ }
}

Back to the top