Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlena Laskavaia2011-04-24 21:45:28 -0400
committerAlena Laskavaia2011-04-24 21:45:28 -0400
commitb8b9084ce272fddef85a52d50cc26fcebb598223 (patch)
tree33d484fd1f34dbbe038cd86f820e1cce4b099fd2 /codan/org.eclipse.cdt.codan.checkers
parent42958023adc2fa6620f61dcebb071269cba797c8 (diff)
downloadorg.eclipse.cdt-b8b9084ce272fddef85a52d50cc26fcebb598223.tar.gz
org.eclipse.cdt-b8b9084ce272fddef85a52d50cc26fcebb598223.tar.xz
org.eclipse.cdt-b8b9084ce272fddef85a52d50cc26fcebb598223.zip
Bug 332285 - Parser misinterprets return statement in lambda
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.java20
1 files changed, 9 insertions, 11 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 f95c474367..0a2fb6a844 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
@@ -24,7 +24,7 @@ import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
-import org.eclipse.cdt.core.dom.ast.IASTExpressionStatement;
+import org.eclipse.cdt.core.dom.ast.IASTExpression;
import org.eclipse.cdt.core.dom.ast.IASTFunctionDeclarator;
import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition;
import org.eclipse.cdt.core.dom.ast.IASTNamedTypeSpecifier;
@@ -38,11 +38,11 @@ import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.c.ICASTSimpleDeclSpecifier;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDefinition;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTLambdaExpression;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTSimpleDeclSpecifier;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateDeclaration;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
-import org.eclipse.cdt.core.dom.ast.gnu.IGNUASTCompoundStatementExpression;
/**
* The checker suppose to find issue related to mismatched return value/function
@@ -65,6 +65,7 @@ public class ReturnChecker extends AbstractAstFunctionChecker {
ReturnStmpVisitor(IASTFunctionDefinition func) {
shouldVisitStatements = true;
shouldVisitDeclarations = true;
+ shouldVisitExpressions = true;
this.func = func;
this.hasret = false;
}
@@ -74,7 +75,12 @@ public class ReturnChecker extends AbstractAstFunctionChecker {
return PROCESS_SKIP; // skip inner functions
return PROCESS_CONTINUE;
}
-
+ public int visit(IASTExpression expr) {
+ if (expr instanceof ICPPASTLambdaExpression) {
+ return PROCESS_SKIP;
+ }
+ return PROCESS_CONTINUE;
+ }
public int visit(IASTStatement stmt) {
if (stmt instanceof IASTReturnStatement) {
hasret = true;
@@ -94,14 +100,6 @@ public class ReturnChecker extends AbstractAstFunctionChecker {
}
return PROCESS_SKIP;
}
- if (stmt instanceof IASTExpressionStatement) {
- // do not process expression they may contain nasty stuff
- IASTExpressionStatement stmt1 = (IASTExpressionStatement) stmt;
- if (stmt1.getExpression() instanceof IGNUASTCompoundStatementExpression) {
- return PROCESS_CONTINUE;
- }
- return PROCESS_SKIP;
- }
return PROCESS_CONTINUE;
}

Back to the top