From: Steve Naroff Date: Thu, 26 Jul 2007 14:35:56 +0000 (+0000) Subject: Fix the following bogus diagnostic...reported by Jeroen. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=08f794b2124a917f41e3b3d93f1e433c7954a153;p=clang Fix the following bogus diagnostic...reported by Jeroen. #include int main(void) { int test = 0; printf("Type is %s\n", (test >= 1 ? "short" : "char")); return (0); } It comes up with a diagnostic that's misleading upon first read. t.c:7:36: error: incompatible operand types ('char *' and 'char *') printf("Type is %s\n", (test >= 1 ? "short" : "char")); ^ ~~~~~~~ ~~~~~~ 1 diagnostic generated. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40526 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/Sema/SemaExpr.cpp b/Sema/SemaExpr.cpp index cd19872a1a..00838f79c1 100644 --- a/Sema/SemaExpr.cpp +++ b/Sema/SemaExpr.cpp @@ -585,10 +585,6 @@ inline QualType Sema::CheckConditionalOperands( // C99 6.5.15 (lhptee->isObjectType() || lhptee->isIncompleteType())) return rexT; - // FIXME: C99 6.5.15p6: If both operands are pointers to compatible types - // *or* to differently qualified versions of compatible types, the result - // type is a pointer to an appropriately qualified version of the - // *composite* type. if (!Type::typesAreCompatible(lhptee.getUnqualifiedType(), rhptee.getUnqualifiedType())) { Diag(questionLoc, diag::ext_typecheck_cond_incompatible_pointers, @@ -596,6 +592,11 @@ inline QualType Sema::CheckConditionalOperands( // C99 6.5.15 lex->getSourceRange(), rex->getSourceRange()); return lexT; // FIXME: this is an _ext - is this return o.k? } + // The pointer types are compatible. + // C99 6.5.15p6: If both operands are pointers to compatible types *or* to + // differently qualified versions of compatible types, the result type is a + // pointer to an appropriately qualified version of the *composite* type. + return lexT; // FIXME: Need to return the composite type. } if (lexT->isVoidType() && rexT->isVoidType()) // C99 6.5.15p3 return lexT;