[cfe-dev] Fixes for References
Bill Wendling
isanbard at gmail.com
Sun Jul 15 22:37:38 PDT 2007
On Jul 15, 2007, at 10:28 PM, Chris Lattner wrote:
> On Jul 15, 2007, at 10:18 PM, Bill Wendling wrote:
>
>> Hi,
>>
>> This is an updated patch to fix references. It now should
>> implement subscripted references and references to functions
>> correctly. I believe I got all of Chris's feedback into this
>> patch. And it has the benefit of actually working!! :-)
>
> Heh, oops, I just responded.
We crossed pathes :-)
> This patch has similar problems to the previous one. The citation
> [C++ 3.10p5] doesn't make sense for isLvalue, because it only
> applies to call results. isLvalue applies to everything.
>
> +++ Sema/SemaExpr.cpp (working copy)
> @@ -282,10 +282,8 @@
> Expr *LHSExp = static_cast<Expr*>(Base), *RHSExp =
> static_cast<Expr*>(Idx);
>
> // Perform default conversions.
> - DefaultFunctionArrayConversion(LHSExp);
> - DefaultFunctionArrayConversion(RHSExp);
> -
> - QualType LHSTy = LHSExp->getType(), RHSTy = RHSExp->getType();
> + QualType LHSTy = DefaultFunctionArrayConversion(LHSExp);
> + QualType RHSTy = DefaultFunctionArrayConversion(RHSExp);
> assert(!LHSTy.isNull() && !RHSTy.isNull() && "missing types");
>
>
> This is logically independent from the rest of the patch. I'd like
> to eventually remove the return value of
> DefaultFunctionArrayConversion, so please remove this piece.
That would break the references stuff. The "stripping of the
references" is why I made this change. Otherwise, we get a reference
type from
QualType LHSTy = LHSExp->getType(), RHSTy = RHSExp->getType();
And it fails below. If you're going to remove the return value of
DefaultFunctionArrayConversion, then we'd have to do yet another
stripping of the reference afterwards.
> + if (PT == 0) {
> + // C++ 8.5.3p1: This is a reference to a function.
> + const ReferenceType *RT = dyn_cast<ReferenceType>(qType);
>
> This spec citation also seems wrong. It applies to initialization
> of references.
I'll put the correct one on when I fix the bigger problem.
-bw
More information about the cfe-dev
mailing list