implement codegen support for preinc as an lvalue, PR5514.

llvm-svn: 93076
diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp
index 2c2b76f..5809d1e 100644
--- a/clang/lib/CodeGen/CGExpr.cpp
+++ b/clang/lib/CodeGen/CGExpr.cpp
@@ -1120,8 +1120,16 @@
                             MakeQualifiers(ExprTy));
   }
   case UnaryOperator::PreInc:
-  case UnaryOperator::PreDec:
-    return EmitUnsupportedLValue(E, "pre-inc/dec expression");
+  case UnaryOperator::PreDec: {
+    LValue LV = EmitLValue(E->getSubExpr());
+    bool isInc = E->getOpcode() == UnaryOperator::PreInc;
+    
+    if (E->getType()->isAnyComplexType())
+      EmitComplexPrePostIncDec(E, LV, isInc, true/*isPre*/);
+    else
+      EmitScalarPrePostIncDec(E, LV, isInc, true/*isPre*/);
+    return LV;
+  }
   }
 }
 
diff --git a/clang/test/CodeGenCXX/expr.cpp b/clang/test/CodeGenCXX/expr.cpp
index 6d641dc..d92cfb4 100644
--- a/clang/test/CodeGenCXX/expr.cpp
+++ b/clang/test/CodeGenCXX/expr.cpp
@@ -10,3 +10,7 @@
   char *xpto;
   while ( true && xpto[0] );
 }
+
+// PR5514
+int a;
+void test2() { ++a+=10; }