Steve Naroff wrote:
> +    // Variable will be bound by-copy, make it const within the closure.
> +    VD->getType().addConst();
> +    return new BlockDeclRefExpr(VD, VD->getType(), Loc, false);

"VD->getType().addConst()" will add 'const' to a temporary QualType 
returned by VD->getType(), it doesn't have any effect, e.g.:

void f() {
  void (^blck)(void);
  int v;
  struct S {} s;
  blck = ^{ int x; x = v+s; }; // reports "error: invalid operands to 
binary expression ('int' and 'struct S')", 'const' is not added
}

it should probably be changed like this:

   return new BlockDeclRefExpr(VD, 
VD->getType()->getWithAdditionalQualifiers(QualType::Const), Loc, false);

BTW, how about adding methods like this to QualType class:

  QualType withConst() { return getWithAdditionalQualifiers(Const); }

So that the above line becomes

  return new BlockDeclRefExpr(VD, VD->getType().withConst(), Loc, false);


-Argiris
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to