[cfe-commits] r83267 - in /cfe/trunk: lib/AST/ExprConstant.cpp test/CodeGenCXX/references.cpp

Anders Carlsson andersca at mac.com
Sat Oct 3 09:30:22 PDT 2009


Author: andersca
Date: Sat Oct  3 11:30:22 2009
New Revision: 83267

URL: http://llvm.org/viewvc/llvm-project?rev=83267&view=rev
Log:
Ignore No-op casts when evaluating lvalue expressions. Fixes PR5122.

Modified:
    cfe/trunk/lib/AST/ExprConstant.cpp
    cfe/trunk/test/CodeGenCXX/references.cpp

Modified: cfe/trunk/lib/AST/ExprConstant.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=83267&r1=83266&r2=83267&view=diff

==============================================================================
--- cfe/trunk/lib/AST/ExprConstant.cpp (original)
+++ cfe/trunk/lib/AST/ExprConstant.cpp Sat Oct  3 11:30:22 2009
@@ -180,6 +180,16 @@
     { return Visit(E->getSubExpr()); }
   APValue VisitChooseExpr(const ChooseExpr *E)
     { return Visit(E->getChosenSubExpr(Info.Ctx)); }
+
+  APValue VisitCastExpr(CastExpr *E) {
+    switch (E->getCastKind()) {
+    default:
+      return APValue();
+
+    case CastExpr::CK_NoOp:
+      return Visit(E->getSubExpr());
+    }
+  }
   // FIXME: Missing: __real__, __imag__
 };
 } // end anonymous namespace

Modified: cfe/trunk/test/CodeGenCXX/references.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/references.cpp?rev=83267&r1=83266&r2=83267&view=diff

==============================================================================
--- cfe/trunk/test/CodeGenCXX/references.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/references.cpp Sat Oct  3 11:30:22 2009
@@ -95,3 +95,8 @@
 void f(A* a) {
   int b = a->b();
 }
+
+// PR5122
+void *foo = 0;
+void * const & kFoo = foo;
+





More information about the cfe-commits mailing list