[cfe-commits] r54080 - in /cfe/trunk: lib/Sema/SemaExpr.cpp test/Sema/complex-int.c

Chris Lattner sabre at nondot.org
Fri Jul 25 16:52:49 PDT 2008


Author: lattner
Date: Fri Jul 25 18:52:49 2008
New Revision: 54080

URL: http://llvm.org/viewvc/llvm-project?rev=54080&view=rev
Log:
GCC supports the complex conjugate operator (an extension) on complex int 
as well as complex float. rdar://6097730

Modified:
    cfe/trunk/lib/Sema/SemaExpr.cpp
    cfe/trunk/test/Sema/complex-int.c

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=54080&r1=54079&r2=54080&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Fri Jul 25 18:52:49 2008
@@ -2261,16 +2261,14 @@
   case UnaryOperator::Not: // bitwise complement
     UsualUnaryConversions(Input);
     resultType = Input->getType();
-    // C99 6.5.3.3p1. We allow complex as a GCC extension.
-    if (!resultType->isIntegerType()) {
-      if (resultType->isComplexType())
-        // C99 does not support '~' for complex conjugation.
-        Diag(OpLoc, diag::ext_integer_complement_complex,
-                    resultType.getAsString());
-      else
-        return Diag(OpLoc, diag::err_typecheck_unary_expr,
-                    resultType.getAsString());
-    }
+    // C99 6.5.3.3p1. We allow complex int and float as a GCC extension.
+    if (resultType->isComplexType() || resultType->isComplexIntegerType())
+      // C99 does not support '~' for complex conjugation.
+      Diag(OpLoc, diag::ext_integer_complement_complex,
+           resultType.getAsString(), Input->getSourceRange());
+    else if (!resultType->isIntegerType())
+      return Diag(OpLoc, diag::err_typecheck_unary_expr,
+                  resultType.getAsString(), Input->getSourceRange());
     break;
   case UnaryOperator::LNot: // logical negation
     // Unlike +/-/~, integer promotions aren't done here (C99 6.5.3.3p5).

Modified: cfe/trunk/test/Sema/complex-int.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/complex-int.c?rev=54080&r1=54079&r2=54080&view=diff

==============================================================================
--- cfe/trunk/test/Sema/complex-int.c (original)
+++ cfe/trunk/test/Sema/complex-int.c Fri Jul 25 18:52:49 2008
@@ -41,3 +41,12 @@
 TestPairs(7); TestPairs(8);
 }
 
+// rdar://6097730
+void test3(_Complex int *x) {
+  *x = ~*x;
+}		
+
+void test4(_Complex float *x) {
+  *x = ~*x;
+}		
+





More information about the cfe-commits mailing list