[cfe-commits] r71145 - in /cfe/trunk: include/clang/Basic/DiagnosticSemaKinds.td lib/Sema/SemaExpr.cpp test/Sema/block-misc.c test/SemaObjC/conditional-expr-2.m
Eli Friedman
eli.friedman at gmail.com
Wed May 6 21:11:58 PDT 2009
On Wed, May 6, 2009 at 8:14 PM, Mike Stump <mrs at apple.com> wrote:
> // ignore qualifiers on void (C99 6.5.15p3, clause 6)
> - if (lhptee->isVoidType() &&
> - rhptee->isIncompleteOrObjectType()) {
> + if (lhptee->isVoidType()
> + && (RHSBPT || rhptee->isIncompleteOrObjectType())) {
This makes the handling for block pointers and function pointers
inconsistent; is that the intent? (It's fine if it isn't, but I'd
like confirmation.) In any case, I don't think you want to be
creating a block pointer with a qualified function type.
> // Figure out necessary qualifiers (C99 6.5.15p6)
> QualType destPointee=lhptee.getQualifiedType(rhptee.getCVRQualifiers());
> QualType destType = Context.getPointerType(destPointee);
> @@ -3671,7 +3680,7 @@
> QualType lType = lex->getType();
> QualType rType = rex->getType();
>
> - if (!lType->isFloatingType()) {
> + if (!lType->isFloatingType() && !(lType->isBlockPointerType() && isRelational)) {
This looks strange... if the issue is that we don't want to warn in
cases of errors, the code should be reorganized in a more general way.
> // 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.
> @@ -3867,14 +3881,20 @@
> }
> // Handle block pointers.
> if (lType->isBlockPointerType() && rType->isIntegerType()) {
> - if (!RHSIsNull)
> + if (isRelational)
> + Diag(Loc, diag::err_typecheck_invalid_operands)
> + << lType << rType << lex->getSourceRange() << rex->getSourceRange();
> + else if (!RHSIsNull)
Couldn't you just check isRelational in the outer if statement, and
fall through for the error case?
-Eli
More information about the cfe-commits
mailing list