[cfe-commits] [PATCH] PR 12746: Code generation of variables reference expressions when mixing blocks and lambdas

Meador Inge meadori at gmail.com
Tue May 15 15:46:19 PDT 2012


Ping.

On Tue, May 8, 2012 at 8:18 PM, Meador Inge <meadori at gmail.com> wrote:
> Hi All,
>
> In PR 12746 a failing assertion was reported when mixing blocks and lambdas.
> The original reproduction case looked something like:
>
> void foo(int *x)
> {
>  ^() {
>    [&]() {
>      return x == 0;
>    }();
>  }();
> }
>
> The following assert in 'clang::CodeGenFunction::EmitDeclRefLValue' was failing
> because the variable declaration referenced in 'E' was not in the 'LocalDeclMap'
> and was not marked as referring to an enclosing local:
>
>      assert(isa<BlockDecl>(CurCodeDecl) && E->refersToEnclosingLocal());
>
> This problem has been fixed by ensuring that the 'DeclRefExpr' gets marked as
> referring to an enclosing local as it should be.
>
> While investigating this issue I noticed that the reverse nesting fails too,
> but for a different reason:
>
> void foo(int *x)
> {
>  [&]() {
>    ^() {
>      return x == 0;
>    }();
>  }();
> }
>
> This time 'clang::CodeGen::CodeGenFunction::EmitBlockLiteral' goes to lookup
> the capture information for the nested parameter 'x', but crashes because it
> is actually nested in a lambda and the  'BlockInfo' is NULL.  This was fixed by
> adding a check to ensure 'BlockInfo' is not NULL.
>
> OK?
>
> -- Meador
>
> P.S.  If it is OK, then can someone commit for me?  (I don't have
> commit rights.)



-- 
# Meador




More information about the cfe-commits mailing list