[cfe-commits] r57337 - in /cfe/trunk: include/clang/AST/Decl.h include/clang/AST/DeclBase.h include/clang/Parse/Action.h lib/AST/Decl.cpp lib/AST/DeclBase.cpp lib/Parse/ParseExpr.cpp lib/Sema/Sema.h lib/Sema/SemaExpr.cpp
steve naroff
snaroff at apple.com
Fri Oct 10 08:09:36 PDT 2008
On Oct 10, 2008, at 1:34 PM, Argiris Kirtzidis wrote:
> 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);
>
Good catch!
> 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);
>
Looks great. I'll add this later today...
Thanks,
snaroff
>
> -Argiris
More information about the cfe-commits
mailing list