Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlena Laskavaia2011-05-01 22:18:23 -0400
committerAlena Laskavaia2011-05-01 22:18:23 -0400
commit38bd4a60943931a6c917ec454a6c4bc715e5bcb4 (patch)
treea6bad516c759bdfd5d672ee1877e2de67789d6b8 /codan/org.eclipse.cdt.codan.checkers
parent36843b8c72daa4dafcf84b87ce40d8ebfb7cf750 (diff)
downloadorg.eclipse.cdt-38bd4a60943931a6c917ec454a6c4bc715e5bcb4.tar.gz
org.eclipse.cdt-38bd4a60943931a6c917ec454a6c4bc715e5bcb4.tar.xz
org.eclipse.cdt-38bd4a60943931a6c917ec454a6c4bc715e5bcb4.zip
fixed reporting of error in empty constructor
Diffstat (limited to 'codan/org.eclipse.cdt.codan.checkers')
-rw-r--r--codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/ReturnChecker.java31
1 files changed, 18 insertions, 13 deletions
diff --git a/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/ReturnChecker.java b/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/ReturnChecker.java
index c9c5e35e0c..548eae0599 100644
--- a/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/ReturnChecker.java
+++ b/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/ReturnChecker.java
@@ -96,7 +96,7 @@ public class ReturnChecker extends AbstractAstFunctionChecker {
if (hasret == false && hasValue) {
hasret = true;
}
- if (!isVoid(func) && !isConstructorDestructor()) {
+ if (!isVoid(func) && !isConstructorDestructor(func)) {
if (checkImplicitReturn(RET_NO_VALUE_ID) || isExplicitReturn(func)) {
if (!hasValue)
reportProblem(RET_NO_VALUE_ID, ret);
@@ -113,20 +113,21 @@ public class ReturnChecker extends AbstractAstFunctionChecker {
}
return PROCESS_CONTINUE;
}
+ }
- /**
- * @return
- *
- */
- public boolean isConstructorDestructor() {
- if (func instanceof ICPPASTFunctionDefinition) {
- IBinding method = func.getDeclarator().getName().resolveBinding();
- if (method instanceof ICPPConstructor || method instanceof ICPPMethod && ((ICPPMethod) method).isDestructor()) {
- return true;
- }
+ /**
+ * @param func
+ * @return
+ *
+ */
+ public boolean isConstructorDestructor(IASTFunctionDefinition func) {
+ if (func instanceof ICPPASTFunctionDefinition) {
+ IBinding method = func.getDeclarator().getName().resolveBinding();
+ if (method instanceof ICPPConstructor || method instanceof ICPPMethod && ((ICPPMethod) method).isDestructor()) {
+ return true;
}
- return false;
}
+ return false;
}
/*
@@ -157,7 +158,8 @@ public class ReturnChecker extends AbstractAstFunctionChecker {
reportNoRet(func, visitor.hasret);
}
} else {
- reportNoRet(func, false);
+
+ reportNoRet(func, false);
}
}
}
@@ -172,6 +174,9 @@ public class ReturnChecker extends AbstractAstFunctionChecker {
if (checkImplicitReturn(RET_NORET_ID) == false && isExplicitReturn(func) == false) {
return;
}
+ if (isConstructorDestructor(func)) {
+ return;
+ }
}
reportProblem(RET_NORET_ID, func.getDeclSpecifier());
}

Back to the top