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

Richard Smith richard at metafoo.co.uk
Thu Jan 17 13:09:53 PST 2013


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.

Thanks!



More information about the cfe-commits mailing list