[cfe-commits] r124668 - in /cfe/trunk: include/clang/Basic/DiagnosticSemaKinds.td include/clang/Sema/Sema.h lib/Sema/SemaExpr.cpp test/Analysis/self-init.m test/SemaCXX/warn-assignment-condition.cpp

Argyrios Kyrtzidis kyrtzidis at apple.com
Tue Feb 1 14:04:46 PST 2011


On Feb 1, 2011, at 1:29 PM, jahanian wrote:

> 
> On Feb 1, 2011, at 11:37 AM, Argyrios Kyrtzidis wrote:
> 
>> On Feb 1, 2011, at 10:39 AM, John McCall wrote:
>> 
>>> On Feb 1, 2011, at 10:24 AM, Argyrios Kyrtzidis wrote:
>>>> Author: akirtzidis
>>>> Date: Tue Feb  1 12:24:22 2011
>>>> New Revision: 124668
>>>> 
>>>> URL: http://llvm.org/viewvc/llvm-project?rev=124668&view=rev
>>>> Log:
>>>> Warn for "if ((a == b))" where the equality expression is needlessly wrapped inside parentheses.
>>>> It's highly likely that the user intended an assignment used as condition.
>>> 
>>> Interesting.  I'm worried that some people do this idiomatically, but I'm willing to wait and see.  Please don't warn unless the LHS of the == is a modifiable l-value, though.
>> 
>> Oops, fixed in r124675, thanks for catching this blunder!
> 
> Do you warn for: "if (((a) == b))". It seems that if LHS is inside a paren, user did not have intention of doing an assignment.

Why not,

if (((do-something-elaborate-that-results-in-lvalue-that-i-want-to-assign-and-check) = b))

seems reasonable to me.

> 
> - Fariborz
> 
>> 
>> -Argiris
>> _______________________________________________
>> cfe-commits mailing list
>> cfe-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
> 
> 
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits





More information about the cfe-commits mailing list