[cfe-commits] r51958 - in /cfe/trunk: lib/CodeGen/CGExprScalar.cpp test/CodeGen/conditional.c

Nuno Lopes nunoplopes at sapo.pt
Wed Jun 4 12:15:46 PDT 2008


Author: nlopes
Date: Wed Jun  4 14:15:45 2008
New Revision: 51958

URL: http://llvm.org/viewvc/llvm-project?rev=51958&view=rev
Log:
fix crash when codegening 'cond ? lhs : call-to-void-func()'

Modified:
    cfe/trunk/lib/CodeGen/CGExprScalar.cpp
    cfe/trunk/test/CodeGen/conditional.c

Modified: cfe/trunk/lib/CodeGen/CGExprScalar.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprScalar.cpp?rev=51958&r1=51957&r2=51958&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CGExprScalar.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprScalar.cpp Wed Jun  4 14:15:45 2008
@@ -1074,7 +1074,7 @@
   
   CGF.EmitBlock(ContBlock);
   
-  if (!LHS) {
+  if (!LHS || !RHS) {
     assert(E->getType()->isVoidType() && "Non-void value should have a value");
     return 0;
   }

Modified: cfe/trunk/test/CodeGen/conditional.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/conditional.c?rev=51958&r1=51957&r2=51958&view=diff

==============================================================================
--- cfe/trunk/test/CodeGen/conditional.c (original)
+++ cfe/trunk/test/CodeGen/conditional.c Wed Jun  4 14:15:45 2008
@@ -30,3 +30,15 @@
 void test7(int);
 void* test8() {return 1 ? test6 : test7;}
 
+
+void _efree(void *ptr);
+
+void _php_stream_free3()
+{
+	(1 ? free(0) : _efree(0));
+}
+
+void _php_stream_free4()
+{
+	1 ? _efree(0) : free(0);
+}





More information about the cfe-commits mailing list