зеркало из https://github.com/microsoft/clang-1.git
GCC supports the complex conjugate operator (an extension) on complex int
as well as complex float. rdar://6097730 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@54080 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
d67cd9ef4c
Коммит
02a65146aa
|
@ -2261,16 +2261,14 @@ Action::ExprResult Sema::ActOnUnaryOp(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();
|
||||||
// C99 6.5.3.3p1. We allow complex as a GCC extension.
|
// C99 6.5.3.3p1. We allow complex int and float as a GCC extension.
|
||||||
if (!resultType->isIntegerType()) {
|
if (resultType->isComplexType() || resultType->isComplexIntegerType())
|
||||||
if (resultType->isComplexType())
|
// C99 does not support '~' for complex conjugation.
|
||||||
// C99 does not support '~' for complex conjugation.
|
Diag(OpLoc, diag::ext_integer_complement_complex,
|
||||||
Diag(OpLoc, diag::ext_integer_complement_complex,
|
resultType.getAsString(), Input->getSourceRange());
|
||||||
resultType.getAsString());
|
else if (!resultType->isIntegerType())
|
||||||
else
|
return Diag(OpLoc, diag::err_typecheck_unary_expr,
|
||||||
return Diag(OpLoc, diag::err_typecheck_unary_expr,
|
resultType.getAsString(), Input->getSourceRange());
|
||||||
resultType.getAsString());
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case UnaryOperator::LNot: // logical negation
|
case UnaryOperator::LNot: // logical negation
|
||||||
// Unlike +/-/~, integer promotions aren't done here (C99 6.5.3.3p5).
|
// Unlike +/-/~, integer promotions aren't done here (C99 6.5.3.3p5).
|
||||||
|
|
|
@ -41,3 +41,12 @@ TestPairs(5); TestPairs(6);
|
||||||
TestPairs(7); TestPairs(8);
|
TestPairs(7); TestPairs(8);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// rdar://6097730
|
||||||
|
void test3(_Complex int *x) {
|
||||||
|
*x = ~*x;
|
||||||
|
}
|
||||||
|
|
||||||
|
void test4(_Complex float *x) {
|
||||||
|
*x = ~*x;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче