[cfe-commits] r114236 - in /cfe/trunk: lib/Sema/SemaExpr.cpp test/CodeGen/transparent-union.c

Daniel Dunbar daniel at zuster.org
Fri Sep 17 16:21:43 PDT 2010


Author: ddunbar
Date: Fri Sep 17 18:21:43 2010
New Revision: 114236

URL: http://llvm.org/viewvc/llvm-project?rev=114236&view=rev
Log:
Sema/transparent_union: Make sure to add implicit cast when constructing
implicit union values for the transparent_union extension.

Added:
    cfe/trunk/test/CodeGen/transparent-union.c
Modified:
    cfe/trunk/lib/Sema/SemaExpr.cpp

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=114236&r1=114235&r2=114236&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Fri Sep 17 18:21:43 2010
@@ -4954,6 +4954,7 @@
 
     if (CheckAssignmentConstraints(it->getType(), rExpr->getType())
           == Compatible) {
+      ImpCastExprToType(rExpr, it->getType(), CK_Unknown);
       InitField = *it;
       break;
     }

Added: cfe/trunk/test/CodeGen/transparent-union.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/transparent-union.c?rev=114236&view=auto
==============================================================================
--- cfe/trunk/test/CodeGen/transparent-union.c (added)
+++ cfe/trunk/test/CodeGen/transparent-union.c Fri Sep 17 18:21:43 2010
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -triple i386-unknown-unknown -emit-llvm -o %t %s
+// RUN: FileCheck < %t %s
+//
+// FIXME: Note that we don't currently get the ABI right here. f0() should be
+// f0(i8*).
+
+typedef union {
+  void *f0;
+} transp_t0 __attribute__((transparent_union));
+
+void f0(transp_t0 obj);
+
+// CHECK: define void @f1_0(i32* %a0) 
+// CHECK:  call void @f0(%union.anon* byval %{{.*}})
+// CHECK: }
+void f1_0(int *a0) {
+  f0(a0);
+}
+
+void f1_1(int *a0) {
+  f0((transp_t0) { a0 });
+}





More information about the cfe-commits mailing list