mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 14:42:11 +02:00
Bug 321933 fixed f.p. in assignment to itself checker when assignment is in macro
This commit is contained in:
parent
c209eb8372
commit
f546ade7fc
2 changed files with 16 additions and 1 deletions
|
@ -44,7 +44,12 @@ public class AssignmentToItselfChecker extends AbstractIndexAstChecker {
|
|||
if (e instanceof IASTBinaryExpression) {
|
||||
IASTBinaryExpression binExpr = (IASTBinaryExpression) e;
|
||||
if (binExpr.getOperator() == IASTBinaryExpression.op_assign) {
|
||||
return binExpr.getOperand1().getRawSignature().equals(binExpr.getOperand2().getRawSignature());
|
||||
String op1 = binExpr.getOperand1().getRawSignature();
|
||||
String op2 = binExpr.getOperand2().getRawSignature();
|
||||
String expr = binExpr.getRawSignature();
|
||||
return op1.equals(op2)
|
||||
// when macro is used RawSignature returns macro name, see Bug 321933
|
||||
&& !op1.equals(expr);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -54,4 +54,14 @@ public class AssignmentToItselfCheckerTest extends CheckerTestCase {
|
|||
loadCodeAndRun(getAboveComment());
|
||||
checkErrorLine(4);
|
||||
}
|
||||
|
||||
// #define X a = 1
|
||||
// void main() {
|
||||
// int a;
|
||||
// X;
|
||||
// }
|
||||
public void testNoError_Bug321933() {
|
||||
loadCodeAndRun(getAboveComment());
|
||||
checkNoErrors();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue