[cfe-dev] Fixes for References

Chris Lattner clattner at apple.com
Sun Jul 15 22:28:16 PDT 2007


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.

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.

+  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.

-Chris



More information about the cfe-dev mailing list