[cfe-commits] r40526 - /cfe/trunk/Sema/SemaExpr.cpp

Steve Naroff snaroff at apple.com
Thu Jul 26 07:35:56 PDT 2007


Author: snaroff
Date: Thu Jul 26 09:35:56 2007
New Revision: 40526

URL: http://llvm.org/viewvc/llvm-project?rev=40526&view=rev
Log:
Fix the following bogus diagnostic...reported by Jeroen.

#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.


Modified:
    cfe/trunk/Sema/SemaExpr.cpp

Modified: cfe/trunk/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Sema/SemaExpr.cpp?rev=40526&r1=40525&r2=40526&view=diff

==============================================================================
--- cfe/trunk/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/Sema/SemaExpr.cpp Thu Jul 26 09:35:56 2007
@@ -585,10 +585,6 @@
         (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 @@
            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;





More information about the cfe-commits mailing list