]> granicus.if.org Git - clang/commitdiff
Fix the following bogus diagnostic...reported by Jeroen.
authorSteve Naroff <snaroff@apple.com>
Thu, 26 Jul 2007 14:35:56 +0000 (14:35 +0000)
committerSteve Naroff <snaroff@apple.com>
Thu, 26 Jul 2007 14:35:56 +0000 (14:35 +0000)
#include <stdio.h>

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

Sema/SemaExpr.cpp

index cd19872a1a6ed7fc0972af6bdc164d4e2bfebabd..00838f79c1b9cc73c1694c9cb67380c78dfd882e 100644 (file)
@@ -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;