[cfe-commits] r41341 - /cfe/trunk/Sema/SemaExpr.cpp
Steve Naroff
snaroff at apple.com
Thu Aug 23 15:06:41 PDT 2007
Author: snaroff
Date: Thu Aug 23 17:06:40 2007
New Revision: 41341
URL: http://llvm.org/viewvc/llvm-project?rev=41341&view=rev
Log:
Support '~' for complex conjugation. This is a GCC extension.
This following now compiles without error...
_Complex unsigned X, Y;
_Complex double x, y;
void test2(int c) {
X = ~Y;
x = ~y;
}
Modified:
cfe/trunk/Sema/SemaExpr.cpp
Modified: cfe/trunk/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Sema/SemaExpr.cpp?rev=41341&r1=41340&r2=41341&view=diff
==============================================================================
--- cfe/trunk/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/Sema/SemaExpr.cpp Thu Aug 23 17:06:40 2007
@@ -1256,7 +1256,8 @@
QualType resType = op->getType();
assert(!resType.isNull() && "no type for increment/decrement expression");
- // C99 6.5.2.4p1
+ // C99 6.5.2.4p1: C99 does not support ++/-- on complex types.
+ // We allow complex as a GCC extension.
if (const PointerType *pt = dyn_cast<PointerType>(resType)) {
if (!pt->getPointeeType()->isObjectType()) { // C99 6.5.2.4p2, 6.5.6p2
Diag(OpLoc, diag::err_typecheck_arithmetic_incomplete_type,
@@ -1264,7 +1265,6 @@
return QualType();
}
} else if (!resType->isRealType() && !resType->isComplexType()) {
- // Allowing Complex is a GCC extension.
Diag(OpLoc, diag::err_typecheck_illegal_increment_decrement,
resType.getAsString(), op->getSourceRange());
return QualType();
@@ -1555,7 +1555,9 @@
case UnaryOperator::Not: // bitwise complement
UsualUnaryConversions(Input);
resultType = Input->getType();
- if (!resultType->isIntegerType()) // C99 6.5.3.3p1
+ // C99 6.5.3.3p1. C99 does not support '~' for complex conjugation.
+ // We allow complex as a GCC extension.
+ if (!resultType->isIntegerType() && !resultType->isComplexType())
return Diag(OpLoc, diag::err_typecheck_unary_expr,
resultType.getAsString());
break;
More information about the cfe-commits
mailing list