Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 317042 - [fn] codan doesn't detect assignment in condition in while loops and conditional operators
Summary: [fn] codan doesn't detect assignment in condition in while loops and conditio...
Status: RESOLVED FIXED
Alias: None
Product: CDT
Classification: Tools
Component: cdt-codan (show other bugs)
Version: 7.0   Edit
Hardware: PC All
: P3 normal (vote)
Target Milestone: 8.0   Edit
Assignee: Elena Laskavaia CLA
QA Contact: Elena Laskavaia CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-06-16 09:12 EDT by Meisam CLA
Modified: 2010-06-19 14:23 EDT (History)
1 user (show)

See Also:


Attachments
Patch (1.14 KB, patch)
2010-06-16 09:55 EDT, Meisam CLA
elaskavaia.cdt: iplog+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Meisam CLA 2010-06-16 09:12:36 EDT
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);
Comment 1 Meisam CLA 2010-06-16 09:55:48 EDT
Created attachment 172039 [details]
Patch

Apparently this patch solves the problem.
Comment 2 Elena Laskavaia CLA 2010-06-16 09:57:52 EDT
thanks for the patch, -> 7.0.1
Comment 3 Elena Laskavaia CLA 2010-06-19 14:10:09 EDT
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.