Simple test:
int a() {
int i; short j;
float* k = 1 ? &i : &j;
}

This crashes in codegen because clang warns, and then neglects to
actually make the types match.

Patch attached.  As noted, I deciced to coerce both pointers to void*
because that's what gcc does.

-Eli
Index: Sema/SemaExpr.cpp
===================================================================
--- Sema/SemaExpr.cpp   (revision 46389)
+++ Sema/SemaExpr.cpp   (working copy)
@@ -823,7 +833,13 @@
         Diag(questionLoc, diag::ext_typecheck_cond_incompatible_pointers,
              lexT.getAsString(), rexT.getAsString(),
              lex->getSourceRange(), rex->getSourceRange());
-        return lexT; // FIXME: this is an _ext - is this return o.k?
+        // In this situation, we assume void* type. No especially good
+        // reason, but this is what gcc does, and we do have to pick
+        // to get a consistent AST.
+        QualType voidPtrTy = Context.getPointerType(Context.VoidTy);
+        ImpCastExprToType(lex, voidPtrTy);
+        ImpCastExprToType(rex, voidPtrTy);
+        return voidPtrTy;
       }
       // The pointer types are compatible.
       // C99 6.5.15p6: If both operands are pointers to compatible types *or* 
to
_______________________________________________
cfe-dev mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev

Reply via email to