]> granicus.if.org Git - clang/commitdiff
Fix minor oversight for increment/decrement of complex int. Add tests for
authorEli Friedman <eli.friedman@gmail.com>
Sun, 3 Jan 2010 00:20:48 +0000 (00:20 +0000)
committerEli Friedman <eli.friedman@gmail.com>
Sun, 3 Jan 2010 00:20:48 +0000 (00:20 +0000)
coverage.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92433 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaExpr.cpp
test/CodeGen/complex.c
test/Sema/complex-int.c

index 7bf04d88cd5991c6c144eaf015647cac7ad60273..feb6b2b666e48c44aacde394896efba4873275cc 100644 (file)
@@ -5776,7 +5776,7 @@ QualType Sema::CheckIncrementDecrementOperand(Expr *Op, SourceLocation OpLoc,
         << PointeeTy << Op->getSourceRange();
       return QualType();
     }
-  } else if (ResType->isComplexType()) {
+  } else if (ResType->isAnyComplexType()) {
     // C99 does not support ++/-- on complex types, we allow as an extension.
     Diag(OpLoc, diag::ext_integer_increment_complex)
       << ResType << Op->getSourceRange();
index 8d9c68d074efadf968247a73cbc44e1af781cc18..ca606109f8b22d26b63f9b3c4def4afe6c6483e8 100644 (file)
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -emit-llvm < %s
+// RUN: %clang_cc1 -emit-llvm-only %s
 
 int main(void)
 {
@@ -39,6 +39,25 @@ void test3() {
   g1 = D + g1;
 }
 
+__complex__ int ci1, ci2;
+__complex__ short cs;
+int i;
+void test3int() {
+  ci1 = ci1 + ci2;
+  ci1 = ci1 - ci2;
+  ci1 = ci1 * ci2;
+  ci1 = +-~ci1;
+
+  i = __real ci1;
+
+  cs += i;
+  // FIXME: Currently unsupported!
+  //D += cf;
+  cs /= ci1;
+  ci1 = ci1 + i;
+  ci1 = i + ci1;
+}
+
 void t1() {
   (__real__ cf) = 4.0;
 }
@@ -59,3 +78,14 @@ void t5() {
   float _Complex x = t4();
 }
 
+void t6() {
+  g1++;
+  g1--;
+  ++g1;
+  --g1;
+  ci1++;
+  ci1--;
+  ++ci1;
+  --ci1;
+}
+
index 2bd03744d7a0414721d6293bbc021f0bfb9a8512..cb76a342c2d0e0c7dca0a3d573a705213305742a 100644 (file)
@@ -49,3 +49,7 @@ void test3(_Complex int *x) {
 void test4(_Complex float *x) {
   *x = ~*x;
 }
+
+void test5(_Complex int *x) {
+  (*x)++;
+}