From 38bd4a60943931a6c917ec454a6c4bc715e5bcb4 Mon Sep 17 00:00:00 2001 From: Alena Laskavaia Date: Mon, 2 May 2011 02:18:23 +0000 Subject: [PATCH] fixed reporting of error in empty constructor --- .../internal/checkers/ReturnChecker.java | 31 +++++++++++-------- 1 file 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 c9c5e35e0c8..548eae05997 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()); }