[cfe-commits] r147026 - in /cfe/trunk: lib/AST/Expr.cpp test/Sema/static-init.c

Richard Smith richard at metafoo.co.uk
Wed Dec 21 21:27:18 PST 2011


On Thu, December 22, 2011 04:48, Eli Friedman wrote:
> On Wed, Dec 21, 2011 at 2:51 PM, Eli Friedman <eli.friedman at gmail.com> wrote:
>
>> On Tue, Dec 20, 2011 at 7:42 PM, Richard Smith <richard at metafoo.co.uk>
>> wrote:
>>
>>>> Err, great.  That will be a bit annoying to write.  It would make all
>>>> the constant stuff a bit less complicated if Evaluate could handle all
>>>> scalar expressions...
>>>
>>> I agree, and we're very close. The cases we can't evaluate are:
>>>
>>>
>>>  - difference of two address labels (would need a new APValue kind)
>>>  - calls to trivial constructors (which are not constexpr)
>>>  - vector bitcasts
>>>  - cast to union
>>>
>>
>> I think there might be a few other cases you're missing (one or two
>> involving compound literals, some cases involving string literals, maybe a
>> couple others), but yes, it's close.
>
> Here's a more-or-less complete list of what is missing on trunk to get
> through the clang regression tests with isConstantInitializer forwarding to
> Evaluate:
> - StringLiteral and ObjCEncodeExpr outside of an InitListExpr
> - InitListExprs of scalar type (int, float, etc.)
> - CXXTemporaryObjectExpr

I'd be very interested in any specific examples where these don't work --
those would probably be holes in our constexpr support. Note that InitListExpr
for scalars is supported by ExprEvaluatorBase, CXXTemporaryObjectExpr derives
from CXXConstructExpr so is supported by the code which handles that, and
ObjCEncodeExpr is supported by LValueExprEvaluator.

> - RecordExprEvaluator::ValueInitialization

For initializer-lists which don't initialize all members? OK.

> - cast to union
> - difference of two address labels

- Richard




More information about the cfe-commits mailing list