forked from OSchip/llvm-project
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; } llvm-svn: 41341
This commit is contained in:
parent
7b939cf606
commit
8ddb23a6c5
|
@ -1256,7 +1256,8 @@ QualType Sema::CheckIncrementDecrementOperand(Expr *op, SourceLocation OpLoc) {
|
||||||
QualType resType = op->getType();
|
QualType resType = op->getType();
|
||||||
assert(!resType.isNull() && "no type for increment/decrement expression");
|
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 (const PointerType *pt = dyn_cast<PointerType>(resType)) {
|
||||||
if (!pt->getPointeeType()->isObjectType()) { // C99 6.5.2.4p2, 6.5.6p2
|
if (!pt->getPointeeType()->isObjectType()) { // C99 6.5.2.4p2, 6.5.6p2
|
||||||
Diag(OpLoc, diag::err_typecheck_arithmetic_incomplete_type,
|
Diag(OpLoc, diag::err_typecheck_arithmetic_incomplete_type,
|
||||||
|
@ -1264,7 +1265,6 @@ QualType Sema::CheckIncrementDecrementOperand(Expr *op, SourceLocation OpLoc) {
|
||||||
return QualType();
|
return QualType();
|
||||||
}
|
}
|
||||||
} else if (!resType->isRealType() && !resType->isComplexType()) {
|
} else if (!resType->isRealType() && !resType->isComplexType()) {
|
||||||
// Allowing Complex is a GCC extension.
|
|
||||||
Diag(OpLoc, diag::err_typecheck_illegal_increment_decrement,
|
Diag(OpLoc, diag::err_typecheck_illegal_increment_decrement,
|
||||||
resType.getAsString(), op->getSourceRange());
|
resType.getAsString(), op->getSourceRange());
|
||||||
return QualType();
|
return QualType();
|
||||||
|
@ -1555,7 +1555,9 @@ Action::ExprResult Sema::ParseUnaryOp(SourceLocation OpLoc, tok::TokenKind Op,
|
||||||
case UnaryOperator::Not: // bitwise complement
|
case UnaryOperator::Not: // bitwise complement
|
||||||
UsualUnaryConversions(Input);
|
UsualUnaryConversions(Input);
|
||||||
resultType = Input->getType();
|
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,
|
return Diag(OpLoc, diag::err_typecheck_unary_expr,
|
||||||
resultType.getAsString());
|
resultType.getAsString());
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue