Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomasz Wesolowski2011-06-25 22:29:01 -0400
committerAlena Laskavaia2011-06-25 22:29:01 -0400
commit0060fff70212821ed51e7c13d9ed33a5e2254943 (patch)
tree80c0f635f265a605eb2ddfc6477492e2e84682a5 /codan/org.eclipse.cdt.codan.checkers
parent30a6e551f5d7c355da1e834750109c89ecc1e293 (diff)
downloadorg.eclipse.cdt-0060fff70212821ed51e7c13d9ed33a5e2254943.tar.gz
org.eclipse.cdt-0060fff70212821ed51e7c13d9ed33a5e2254943.tar.xz
org.eclipse.cdt-0060fff70212821ed51e7c13d9ed33a5e2254943.zip
Bug 346559 - [fp] undeserved "no return in function returning non-void"
when using goto
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.java5
1 files changed, 5 insertions, 0 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 548eae0599..b917dece9b 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
@@ -31,6 +31,7 @@ import org.eclipse.cdt.core.dom.ast.IASTForStatement;
import org.eclipse.cdt.core.dom.ast.IASTFunctionDeclarator;
import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition;
import org.eclipse.cdt.core.dom.ast.IASTIfStatement;
+import org.eclipse.cdt.core.dom.ast.IASTLabelStatement;
import org.eclipse.cdt.core.dom.ast.IASTNamedTypeSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTReturnStatement;
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclSpecifier;
@@ -150,6 +151,10 @@ public class ReturnChecker extends AbstractAstFunctionChecker {
IASTStatement[] statements = ((IASTCompoundStatement) body).getStatements();
if (statements.length > 0) {
IASTStatement last = statements[statements.length - 1];
+ // get nested statement if this is a label
+ while (last instanceof IASTLabelStatement) {
+ last = ((IASTLabelStatement) last).getNestedStatement();
+ }
// now check if last statement if complex (for optimization reasons, building CFG is expensive)
if (isCompoundStatement(last)) {
if (endsWithNoExitNode(func))

Back to the top