[cfe-commits] r101935 - in /cfe/trunk: lib/Sema/SemaExprObjC.cpp test/SemaObjC/transparent-union.m

Fariborz Jahanian fjahanian at apple.com
Tue Apr 20 13:28:15 PDT 2010


Author: fjahanian
Date: Tue Apr 20 15:28:15 2010
New Revision: 101935

URL: http://llvm.org/viewvc/llvm-project?rev=101935&view=rev
Log:
Patch to support transparent_union types on
objective-c methods. Fixes radar 7875968.

Added:
    cfe/trunk/test/SemaObjC/transparent-union.m
Modified:
    cfe/trunk/lib/Sema/SemaExprObjC.cpp

Modified: cfe/trunk/lib/Sema/SemaExprObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprObjC.cpp?rev=101935&r1=101934&r2=101935&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExprObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprObjC.cpp Tue Apr 20 15:28:15 2010
@@ -216,6 +216,11 @@
 
     AssignConvertType Result =
       CheckSingleAssignmentConstraints(lhsType, argExpr);
+    if (Result == Incompatible && !getLangOptions().CPlusPlus &&
+        CheckTransparentUnionArgumentConstraints(lhsType, argExpr)
+        == Sema::Compatible)
+      Result = Compatible;
+        
     if (Args[i] != argExpr) // The expression was converted.
       Args[i] = argExpr; // Make sure we store the converted expression.
 

Added: cfe/trunk/test/SemaObjC/transparent-union.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/transparent-union.m?rev=101935&view=auto
==============================================================================
--- cfe/trunk/test/SemaObjC/transparent-union.m (added)
+++ cfe/trunk/test/SemaObjC/transparent-union.m Tue Apr 20 15:28:15 2010
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1  -fsyntax-only -verify %s
+
+typedef union {
+ struct xx_object_s *_do;
+ struct xx_continuation_s *_dc;
+ struct xx_queue_s *_dq;
+ struct xx_queue_attr_s *_dqa;
+ struct xx_group_s *_dg;
+ struct xx_source_s *_ds;
+ struct xx_source_attr_s *_dsa;
+ struct xx_semaphore_s *_dsema;
+} xx_object_t __attribute__((transparent_union));
+
+ at interface INTF
+- (void) doSomething : (xx_object_t) xxObject;
+- (void)testMeth;
+ at end
+
+ at implementation INTF
+- (void) doSomething : (xx_object_t) xxObject {}
+- (void)testMeth { struct xx_queue_s *sq; [self doSomething:sq ]; }
+ at end





More information about the cfe-commits mailing list