| Summary: | [fn] codan doesn't detect assignment in condition in while loops and conditional operators | ||||||
|---|---|---|---|---|---|---|---|
| Product: | [Tools] CDT | Reporter: | Meisam <meisam.fathi> | ||||
| Component: | cdt-codan | Assignee: | Elena Laskavaia <elaskavaia.cdt> | ||||
| Status: | RESOLVED FIXED | QA Contact: | Elena Laskavaia <elaskavaia.cdt> | ||||
| Severity: | normal | ||||||
| Priority: | P3 | CC: | cdtdoug | ||||
| Version: | 7.0 | ||||||
| Target Milestone: | 8.0 | ||||||
| Hardware: | PC | ||||||
| OS: | All | ||||||
| Whiteboard: | |||||||
| Attachments: |
|
||||||
Created attachment 172039 [details]
Patch
Apparently this patch solves the problem.
thanks for the patch, -> 7.0.1 I don't think you tested your patch. Condition prop == IASTConditionalExpression.LOGICAL_CONDITION cannot be true for assignment expression because if you write a=b?a:b; - it will be a=(b?a:b), and if you write (a=b)?a:b; parent of assignment expression is unary bracket expression not ternary expression. Anyway I fix it on head and added tests. Thanks. *** cdt cvs genie on behalf of elaskavaia *** Bug 317042 added more cases for assignment in condition checker [*] AutomatedIntegrationSuite.java 1.9 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/test/AutomatedIntegrationSuite.java?root=Tools_Project&r1=1.8&r2=1.9 [+] AssignmentInConditionCheckerTest.java http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/internal/checkers/AssignmentInConditionCheckerTest.java?root=Tools_Project&revision=1.1&view=markup [*] AssignmentInConditionChecker.java 1.5 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/AssignmentInConditionChecker.java?root=Tools_Project&r1=1.4&r2=1.5 |
This remains undetected by codan: (a = b) ? do_somthing() : do_something_else(); also this one: while (a = b){ foo(); } and this one: do { bar(); }while (a = b);