forked from OSchip/llvm-project
require that operands to __real/__imag are complex or arithmetic. This
fixes GCC PR33193 llvm-svn: 41428
This commit is contained in:
parent
b5e1262437
commit
e267f5d2f7
|
@ -283,9 +283,17 @@ ParseSizeOfAlignOfTypeExpr(SourceLocation OpLoc, bool isSizeof,
|
|||
QualType Sema::CheckRealImagOperand(Expr *&V, SourceLocation Loc) {
|
||||
DefaultFunctionArrayConversion(V);
|
||||
|
||||
// These operators return the element type of a complex type.
|
||||
if (const ComplexType *CT = V->getType()->getAsComplexType())
|
||||
return CT->getElementType();
|
||||
return V->getType();
|
||||
|
||||
// Otherwise they pass through real integer and floating point types here.
|
||||
if (V->getType()->isArithmeticType())
|
||||
return V->getType();
|
||||
|
||||
// Reject anything else.
|
||||
Diag(Loc, diag::err_realimag_invalid_type, V->getType().getAsString());
|
||||
return QualType();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -610,6 +610,8 @@ DIAG(err_typecheck_arithmetic_incomplete_type, ERROR,
|
|||
"arithmetic on pointer to incomplete type '%0'")
|
||||
DIAG(err_typecheck_decl_incomplete_type, ERROR,
|
||||
"variable has incomplete type '%0'")
|
||||
DIAG(err_realimag_invalid_type, ERROR,
|
||||
"invalid type '%0' to __real or __imag operator")
|
||||
DIAG(err_typecheck_sclass_fscope, ERROR,
|
||||
"illegal storage class on file-scoped variable")
|
||||
DIAG(err_typecheck_sclass_func, ERROR,
|
||||
|
|
Loading…
Reference in New Issue