Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Gvozdev2011-04-29 15:25:26 -0400
committerAndrew Gvozdev2011-04-29 15:25:26 -0400
commit91ab5f5876a57e33baa6ea0f5358d8ba75962c82 (patch)
tree6fbe27c828668a5a713a063d530b5ef6c1a685a4 /codan/org.eclipse.cdt.codan.core.test
parent5efd41bb09f8510cec9a023bcc24306234b22e70 (diff)
downloadorg.eclipse.cdt-91ab5f5876a57e33baa6ea0f5358d8ba75962c82.tar.gz
org.eclipse.cdt-91ab5f5876a57e33baa6ea0f5358d8ba75962c82.tar.xz
org.eclipse.cdt-91ab5f5876a57e33baa6ea0f5358d8ba75962c82.zip
bug 343429: [checker] Checker to pinpoint unused static functions in a file
A few false positives corrected
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/UnusedSymbolInFileScopeCheckerTest.java52
1 files changed, 48 insertions, 4 deletions
diff --git a/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/internal/checkers/UnusedSymbolInFileScopeCheckerTest.java b/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/internal/checkers/UnusedSymbolInFileScopeCheckerTest.java
index 5975ea70d7..7206e8b785 100644
--- a/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/internal/checkers/UnusedSymbolInFileScopeCheckerTest.java
+++ b/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/internal/checkers/UnusedSymbolInFileScopeCheckerTest.java
@@ -161,6 +161,29 @@ public class UnusedSymbolInFileScopeCheckerTest extends CheckerTestCase {
checkErrorLine(1);
}
+ // static int test_fun(int i) {}
+ // int i = test_fun(X);
+ public void testStaticFunction_Definition_UnknownParameterType() throws IOException {
+ loadCodeAndRunCpp(getAboveComment());
+ checkNoErrors();
+ }
+
+ // static void test_fun(void) {}
+ // void Class::fun() {
+ // test_fun();
+ // }
+ public void testStaticFunction_Definition_InQualifiedFunction() throws IOException {
+ loadCodeAndRunCpp(getAboveComment());
+ checkNoErrors();
+ }
+
+ // static int test_fun(X) {}
+ // int i = test_fun(X);
+ public void testStaticFunction_Definition_UnknownArgumentType() throws IOException {
+ loadCodeAndRunCpp(getAboveComment());
+ checkNoErrors();
+ }
+
////////////////////////////////////////////////////////////////////////////
// Extern variables declaration
////////////////////////////////////////////////////////////////////////////
@@ -194,6 +217,12 @@ public class UnusedSymbolInFileScopeCheckerTest extends CheckerTestCase {
// int test_var;
// int test_var2=0;
+ public void testGlobalVariable_Definition() throws IOException {
+ loadCodeAndRun(getAboveComment());
+ checkNoErrors();
+ }
+
+ // extern int test_var=0; // not quite legal but some compilers allow that
public void testExternVariable_Definition() throws IOException {
loadCodeAndRun(getAboveComment());
checkNoErrors();
@@ -231,6 +260,15 @@ public class UnusedSymbolInFileScopeCheckerTest extends CheckerTestCase {
checkNoErrors();
}
+ // static int test_var;
+ // void Class::fun() {
+ // test_var = 0;
+ // }
+ public void testStaticVariable_Used_InQualifiedFunction() throws IOException {
+ loadCodeAndRunCpp(getAboveComment());
+ checkNoErrors();
+ }
+
// class Class;
// static Class test_var; // constructor is called here
public void testStaticVariable_Used_Constructor() throws IOException {
@@ -244,16 +282,22 @@ public class UnusedSymbolInFileScopeCheckerTest extends CheckerTestCase {
checkNoErrors();
}
- // static char* test_var="$Id: file.c,v 1.1 2000/01/01 11:11:11 agvozdev Exp $";
- public void testExternVariable_Declaration_cvs_ident() throws IOException {
+ // static char* test_var="$Id: UnusedSymbolInFileScopeCheckerTest.java,v 1.2 2011/04/29 11:17:42 agvozdev Exp $";
+ public void testExternVariable_Declaration_CvsIdent() throws IOException {
loadCodeAndRun(getAboveComment());
checkNoErrors();
}
- // static char* test_var="@(#) $Header: /src/file.c,v 1.1 2000/01/01 11:11:11 agvozdev Exp $";
- public void testExternVariable_Declaration_sccs_ident() throws IOException {
+ // static char* test_var="@(#) $Header: /cvsroot/tools/org.eclipse.cdt/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/internal/checkers/UnusedSymbolInFileScopeCheckerTest.java,v 1.2 2011/04/29 11:17:42 agvozdev Exp $";
+ public void testExternVariable_Declaration_SccsIdent() throws IOException {
loadCodeAndRun(getAboveComment());
checkNoErrors();
}
+ // static char test_var[]("@(#) $Id: UnusedSymbolInFileScopeCheckerTest.java,v 1.2 2011/04/29 11:17:42 agvozdev Exp $");
+ public void testExternVariable_Declaration_CvsIdentInitializer() throws IOException {
+ loadCodeAndRunCpp(getAboveComment());
+ checkNoErrors();
+ }
+
}

Back to the top