]> granicus.if.org Git - clang/commitdiff
implement codegen support for preinc as an lvalue, PR5514.
authorChris Lattner <sabre@nondot.org>
Sat, 9 Jan 2010 21:44:40 +0000 (21:44 +0000)
committerChris Lattner <sabre@nondot.org>
Sat, 9 Jan 2010 21:44:40 +0000 (21:44 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93076 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGExpr.cpp
test/CodeGenCXX/expr.cpp

index 2c2b76f2e43cdb36f782c8fad647b82a7c98f6d3..5809d1e70d8b19401966082a2ad524540d4036ff 100644 (file)
@@ -1120,8 +1120,16 @@ LValue CodeGenFunction::EmitUnaryOpLValue(const UnaryOperator *E) {
                             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;
+  }
   }
 }
 
index 6d641dcb622db5c6e635ae465c7a31dd6037720f..d92cfb46a45447d73cde0d6da8da7b1b130f1eed 100644 (file)
@@ -10,3 +10,7 @@ void test1() {
   char *xpto;
   while ( true && xpto[0] );
 }
+
+// PR5514
+int a;
+void test2() { ++a+=10; }