[cfe-commits] [PATCH] Model C++11 rules for odr-use for variables correctly

Eli Friedman eli.friedman at gmail.com
Fri Jan 27 15:26:36 PST 2012

On Fri, Jan 27, 2012 at 3:12 PM, John McCall <rjmccall at apple.com> wrote:
> On Jan 27, 2012, at 2:53 PM, Eli Friedman wrote:
>> On Thu, Jan 26, 2012 at 7:29 PM, John McCall <rjmccall at apple.com> wrote:
>>> On Jan 24, 2012, at 9:34 PM, Eli Friedman wrote:
>>>> Patch attached.  Basically, this is implementing the C++11 rules in
>>>> [basic.def.odr]p2 for variables allowed in constant expressions.
>>>> (Those rules don't matter so much for most code given how we do code
>>>> generation, but we have to get the rules exactly right to get implicit
>>>> capture in lambda expressions working correctly.)
>>>> I don't really like this patch, but it seems like it is necessary.
>>> Yeah, I'm really not happy with this.  Obvious alternative:  mark ODR use
>>> at the DRE creation site unless the object is not already marked and it
>>> meets the constant-loading criteria.  If it does, flag that this full-expression
>>> contains a potential reference, then walk back over the completed
>>> full-expression looking for PE DREs not direct operands of L2R casts.
>> Is there any existing hook that actually triggers where I need it to?
>> MaybeCreateExprWithCleanups seems close... but doesn't quite cover
>> everything.
> What's missing?

In essence, things which are constant-expressions in the C++ grammar
are missing.  Not too hard to add them, I guess.


More information about the cfe-commits mailing list