summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2010-01-09 21:44:40 +0000
committerChris Lattner <sabre@nondot.org>2010-01-09 21:44:40 +0000
commitbb8976e36e73560f0556a53ebc3fa2ff4d2449f1 (patch)
tree25caaf51bc66ad2414c4c65e4149ad0728507e2f /clang
parent116ce8f1729a074419b985fe9ca6be715ecc7ac9 (diff)
downloadbcm5719-llvm-bb8976e36e73560f0556a53ebc3fa2ff4d2449f1.tar.gz
bcm5719-llvm-bb8976e36e73560f0556a53ebc3fa2ff4d2449f1.zip
implement codegen support for preinc as an lvalue, PR5514.
llvm-svn: 93076
Diffstat (limited to 'clang')
-rw-r--r--clang/lib/CodeGen/CGExpr.cpp12
-rw-r--r--clang/test/CodeGenCXX/expr.cpp4
2 files changed, 14 insertions, 2 deletions
diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp
index 2c2b76f2e43..5809d1e70d8 100644
--- a/clang/lib/CodeGen/CGExpr.cpp
+++ b/clang/lib/CodeGen/CGExpr.cpp
@@ -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;
+ }
}
}
diff --git a/clang/test/CodeGenCXX/expr.cpp b/clang/test/CodeGenCXX/expr.cpp
index 6d641dcb622..d92cfb46a45 100644
--- a/clang/test/CodeGenCXX/expr.cpp
+++ b/clang/test/CodeGenCXX/expr.cpp
@@ -10,3 +10,7 @@ void test1() {
char *xpto;
while ( true && xpto[0] );
}
+
+// PR5514
+int a;
+void test2() { ++a+=10; }
OpenPOWER on IntegriCloud