]> granicus.if.org Git - clang/commitdiff
Ignore No-op casts when evaluating lvalue expressions. Fixes PR5122.
authorAnders Carlsson <andersca@mac.com>
Sat, 3 Oct 2009 16:30:22 +0000 (16:30 +0000)
committerAnders Carlsson <andersca@mac.com>
Sat, 3 Oct 2009 16:30:22 +0000 (16:30 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@83267 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/ExprConstant.cpp
test/CodeGenCXX/references.cpp

index 2aefae6fd741eb3282a378c249fc9526641e2daf..94d22998ebbed043b983d164f7badcdfce9e5edb 100644 (file)
@@ -180,6 +180,16 @@ public:
     { 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
index 6f4c1032efab5315151894e2594a607f0c89d244..c235521d43b18ba5e37c31428ebc1473fbe0061f 100644 (file)
@@ -95,3 +95,8 @@ struct A {
 void f(A* a) {
   int b = a->b();
 }
+
+// PR5122
+void *foo = 0;
+void * const & kFoo = foo;
+