mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 14:42:11 +02:00
Fixed f.p. for c++ lazy evaluation hacks
This commit is contained in:
parent
6d88bba776
commit
fe3d182f42
2 changed files with 13 additions and 6 deletions
|
@ -23,6 +23,7 @@ import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
|||
import org.eclipse.cdt.core.dom.ast.IASTUnaryExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.IBasicType;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBasicType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
|
||||
import org.eclipse.cdt.core.dom.ast.gnu.IGNUASTCompoundStatementExpression;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTBinaryExpression;
|
||||
|
@ -85,6 +86,10 @@ public class StatementHasNoEffectChecker extends AbstractIndexAstChecker {
|
|||
case IASTBinaryExpression.op_shiftLeftAssign:
|
||||
case IASTBinaryExpression.op_shiftRightAssign:
|
||||
return false;
|
||||
case IASTBinaryExpression.op_logicalOr:
|
||||
case IASTBinaryExpression.op_logicalAnd:
|
||||
return hasNoEffect(binExpr.getOperand1())
|
||||
&& hasNoEffect(binExpr.getOperand2());
|
||||
}
|
||||
if (binExpr instanceof CPPASTBinaryExpression) {
|
||||
// unfortunately ICPPASTBinaryExpression does not have
|
||||
|
@ -95,9 +100,8 @@ public class StatementHasNoEffectChecker extends AbstractIndexAstChecker {
|
|||
return false;
|
||||
IType expressionType = binExpr.getOperand1()
|
||||
.getExpressionType();
|
||||
if (!(expressionType instanceof IBasicType)) {
|
||||
return false; // must be overloaded but parser could not
|
||||
// find it
|
||||
if (!(expressionType instanceof IBasicType || expressionType instanceof ICPPBasicType)) {
|
||||
return false; // must be overloaded but parser could not find it
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -113,11 +113,14 @@ public class StatementHasNoEffectCheckerTest extends CheckerTestCase {
|
|||
loadCodeAndRun(getAboveComment());
|
||||
checkNoErrors();
|
||||
}
|
||||
// main() {
|
||||
// a = foo(1) || a = foo(2);
|
||||
// void main() {
|
||||
// bool a;
|
||||
// class c {};
|
||||
// c z;
|
||||
// (a = z.foo(1)) || (a = z.foo(2));
|
||||
// }
|
||||
public void testLazyEvalHack() {
|
||||
loadCodeAndRun(getAboveComment());
|
||||
loadCodeAndRunCpp(getAboveComment());
|
||||
checkNoErrors();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue