// pointer constants in case both operands are null pointer constants.
if ((LHSPT || LHSBPT) && (RHSPT || RHSBPT)) { // C99 6.5.15p3,6
// get the "pointed to" types
- QualType lhptee = LHSPT ? LHSPT->getPointeeType() : LHSBPT->getPointeeType();
- QualType rhptee = RHSPT ? RHSPT->getPointeeType() : RHSBPT->getPointeeType();
+ QualType lhptee = (LHSPT ? LHSPT->getPointeeType()
+ : LHSBPT->getPointeeType());
+ QualType rhptee = (RHSPT ? RHSPT->getPointeeType()
+ : RHSBPT->getPointeeType());
// ignore qualifiers on void (C99 6.5.15p3, clause 6)
if (lhptee->isVoidType()
// Enforce type constraints: C99 6.5.6p3.
// Handle the common case first (both operands are arithmetic).
- if (lex->getType()->isArithmeticType() && rex->getType()->isArithmeticType()) {
+ if (lex->getType()->isArithmeticType()
+ && rex->getType()->isArithmeticType()) {
if (CompLHSTy) *CompLHSTy = compType;
return compType;
}
QualType lType = lex->getType();
QualType rType = rex->getType();
- if (!lType->isFloatingType() && !(lType->isBlockPointerType() && isRelational)) {
+ if (!lType->isFloatingType()
+ && !(lType->isBlockPointerType() && isRelational)) {
// For non-floating point types, check for self-comparisons of the form
// x == x, x != x, x < x, etc. These always evaluate to a constant, and
// often indicate logic errors in the program.
return ResultTy;
}
// Handle block pointers.
- if (lType->isBlockPointerType() && rType->isIntegerType()) {
- if (isRelational)
- Diag(Loc, diag::err_typecheck_invalid_operands)
- << lType << rType << lex->getSourceRange() << rex->getSourceRange();
- else if (!RHSIsNull)
- Diag(Loc, diag::ext_typecheck_comparison_of_pointer_integer)
- << lType << rType << lex->getSourceRange() << rex->getSourceRange();
+ if (!isRelational && RHSIsNull
+ && lType->isBlockPointerType() && rType->isIntegerType()) {
ImpCastExprToType(rex, lType); // promote the integer to pointer
return ResultTy;
}
- if (lType->isIntegerType() && rType->isBlockPointerType()) {
- if (isRelational)
- Diag(Loc, diag::err_typecheck_invalid_operands)
- << lType << rType << lex->getSourceRange() << rex->getSourceRange();
- else if (!LHSIsNull)
- Diag(Loc, diag::ext_typecheck_comparison_of_pointer_integer)
- << lType << rType << lex->getSourceRange() << rex->getSourceRange();
+ if (!isRelational && LHSIsNull
+ && lType->isIntegerType() && rType->isBlockPointerType()) {
ImpCastExprToType(lex, rType); // promote the integer to pointer
return ResultTy;
}
}
void Sema::ActOnBlockArguments(Declarator &ParamInfo, Scope *CurScope) {
- assert(ParamInfo.getIdentifier() == 0 && "block-id should have no identifier!");
+ assert(ParamInfo.getIdentifier()==0 && "block-id should have no identifier!");
ProcessDeclAttributes(CurBlock->TheDecl, ParamInfo);
(void)(bp > bp); // expected-error {{invalid operands}}
(void)(bp > vp); // expected-error {{invalid operands}}
f(1 ? bp : rp); // expected-error {{incompatible operand types ('void (^)(int)' and 'void (*)(int)')}}
+ (void)(bp == 1); // expected-error {{invalid operands to binary expression}}
+ (void)(bp == 0);
+ (void)(1 == bp); // expected-error {{invalid operands to binary expression}}
+ (void)(0 == bp);
+ (void)(bp < 1); // expected-error {{invalid operands to binary expression}}
+ (void)(bp < 0); // expected-error {{invalid operands to binary expression}}
+ (void)(1 < bp); // expected-error {{invalid operands to binary expression}}
+ (void)(0 < bp); // expected-error {{invalid operands to binary expression}}
}