[cfe-commits] r172016 - in /cfe/trunk: include/clang/AST/Expr.h lib/AST/ExprConstant.cpp lib/Sema/SemaStmt.cpp test/Sema/switch-1.c

jahanian fjahanian at apple.com
Thu Jan 17 14:50:00 PST 2013


On Jan 17, 2013, at 1:09 PM, Richard Smith <richard at metafoo.co.uk> wrote:

> On Thu, Jan 17, 2013 at 12:35 PM, jahanian <fjahanian at apple.com> wrote:
>> 
>> On Jan 17, 2013, at 11:31 AM, jahanian <fjahanian at apple.com> wrote:
>> 
>>> 
>>> On Jan 16, 2013, at 5:19 PM, Richard Smith <richard at metafoo.co.uk> wrote:
>>> 
>>>> On Wed, Jan 16, 2013 at 5:05 PM, jahanian <fjahanian at apple.com> wrote:
>>>>> 
>>>>> Any more thought on this?
>>>> 
>>>> Here's one possible plan:
>>>> 
>>>> Add a mode to the expression evaluator which visits all subexpressions
>>>> and produces warnings for overflow etc. Call it in that mode from
>>>> CheckCompletedExpr (just added in r172690), except in cases where the
>>>> expression is required to be constant (the callers of
>>>> ActOnFinishFullExpr should know this).
>>> 
>>> 
>>> Here is the patch which moves checking to CheckCompletedExpr and avoids re-evaluation.
>>> I still had to add the overflow check in the case statement because case label expressions do not
>>> go through ActOnFinishFullExpr.
> 
> They are full-expressions, so they should go through
> ActOnFinishFullExpr. Here's an accepts-invalid resulting from this
> omission:
> 
> template<int...N> void f(int k) { switch(k) case N: ; }

> 
>> Oops I forgot about the 'except' part. A new patch will be coming.

This is the completed patch.

	
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: patch-intoverflow.txt
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130117/4627b151/attachment.txt>
-------------- next part --------------


- Thanks, Fariborz


> 
> Thanks!



More information about the cfe-commits mailing list