r215048 - Update the context location of the condition of a conditional operator to the

David Blaikie dblaikie at gmail.com
Fri Aug 8 16:09:56 PDT 2014


On Fri, Aug 8, 2014 at 4:05 PM, Richard Trieu <rtrieu at google.com> wrote:
> This didn't affect any existing tests or diagnostics.  r215251 has the first
> diagnostic that is impacted with this change.  The difference is that:
>
> #define foo(x) ((x) ? *x : 0)
> int x = 5;
> int y = foo(&x);
>
> Without this change, this would cause a conversion warning, with a the
> diagnostic pointing to both 'x' and 'y' in the last line.  With this change,
> no diagnostic would be emitted since the context is inside the macro.

Ah, OK - yeah, always a bit of a toss-up with behavior changes like
that as to whether to include them in the patch that uses them, etc.

Thanks for the details,

- David

>
>
> On Wed, Aug 6, 2014 at 10:25 PM, David Blaikie <dblaikie at gmail.com> wrote:
>>
>> Test coverage?
>>
>> On Aug 6, 2014 7:26 PM, "Richard Trieu" <rtrieu at google.com> wrote:
>>>
>>> Author: rtrieu
>>> Date: Wed Aug  6 21:09:05 2014
>>> New Revision: 215048
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=215048&view=rev
>>> Log:
>>> Update the context location of the condition of a conditional operator to
>>> the
>>> question mark instead of the context of the conditional operator.  The
>>> condition does not need the context of the conditional operator at all.
>>>
>>> Modified:
>>>     cfe/trunk/lib/Sema/SemaChecking.cpp
>>>
>>> Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=215048&r1=215047&r2=215048&view=diff
>>>
>>> ==============================================================================
>>> --- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
>>> +++ cfe/trunk/lib/Sema/SemaChecking.cpp Wed Aug  6 21:09:05 2014
>>> @@ -6193,7 +6193,7 @@ void CheckConditionalOperand(Sema &S, Ex
>>>
>>>  void CheckConditionalOperator(Sema &S, ConditionalOperator *E,
>>>                                SourceLocation CC, QualType T) {
>>> -  AnalyzeImplicitConversions(S, E->getCond(), CC);
>>> +  AnalyzeImplicitConversions(S, E->getCond(), E->getQuestionLoc());
>>>
>>>    bool Suspicious = false;
>>>    CheckConditionalOperand(S, E->getTrueExpr(), T, CC, Suspicious);
>>>
>>>
>>> _______________________________________________
>>> 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