mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-19 15:05:36 +02:00
Bug 332285 - fixed lambda expressions
This commit is contained in:
parent
db436ae417
commit
08cf5bcb27
2 changed files with 29 additions and 0 deletions
|
@ -24,6 +24,7 @@ import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
|||
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.IASTExpressionStatement;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTFunctionDeclarator;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTNamedTypeSpecifier;
|
||||
|
@ -37,6 +38,7 @@ import org.eclipse.cdt.core.dom.ast.c.ICASTSimpleDeclSpecifier;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDefinition;
|
||||
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
|
||||
|
@ -89,6 +91,14 @@ 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;
|
||||
}
|
||||
/**
|
||||
|
|
|
@ -138,4 +138,23 @@ public class ReturnCheckerTest extends CheckerTestCase {
|
|||
loadCodeAndRunCpp(getAboveComment());
|
||||
checkNoErrors();
|
||||
}
|
||||
|
||||
// void f()
|
||||
// {
|
||||
// [](int r){return r;}(5);
|
||||
// }
|
||||
public void testLambda_Bug332285() {
|
||||
loadCodeAndRunCpp(getAboveComment());
|
||||
checkNoErrors();
|
||||
}
|
||||
|
||||
// void g()
|
||||
// {
|
||||
// int r;
|
||||
// ({return r;});
|
||||
// }
|
||||
public void testGccExtensions() {
|
||||
loadCodeAndRunCpp(getAboveComment());
|
||||
checkErrorLine(4);
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue