[cfe-commits] r111159 - in /cfe/trunk: lib/Sema/SemaDeclCXX.cpp test/CodeGenCXX/anonymous-union-member-initializer.cpp

Argyrios Kyrtzidis akyrtzi at gmail.com
Mon Aug 16 10:27:13 PDT 2010


Author: akirtzidis
Date: Mon Aug 16 12:27:13 2010
New Revision: 111159

URL: http://llvm.org/viewvc/llvm-project?rev=111159&view=rev
Log:
Fix initialization for members of anonymous struct in a union.

Modified:
    cfe/trunk/lib/Sema/SemaDeclCXX.cpp
    cfe/trunk/test/CodeGenCXX/anonymous-union-member-initializer.cpp

Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=111159&r1=111158&r2=111159&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Mon Aug 16 12:27:13 2010
@@ -1798,6 +1798,9 @@
           // Once we've initialized a field of an anonymous union, the union
           // field in the class is also initialized, so exit immediately.
           return false;
+        } else if ((*FA)->isAnonymousStructOrUnion()) {
+          if (CollectFieldInitializer(Info, Top, *FA))
+            return true;
         }
       }
 

Modified: cfe/trunk/test/CodeGenCXX/anonymous-union-member-initializer.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/anonymous-union-member-initializer.cpp?rev=111159&r1=111158&r2=111159&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/anonymous-union-member-initializer.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/anonymous-union-member-initializer.cpp Mon Aug 16 12:27:13 2010
@@ -78,3 +78,15 @@
   // CHECK-NEXT: [[CVALUE:%.*]] = getelementptr inbounds {{.*}} [[STRUCT]], i32 0, i32 0
   // CHECK-NEXT: store i8* null, void i8** [[CVALUE]]
 }
+
+struct S {
+  // CHECK: store i32 42
+  // CHECK: store i32 55
+  S() : x(42), y(55) {}
+  union {
+    struct {
+      int x;
+      union { int y; };
+    };
+  };
+} s;





More information about the cfe-commits mailing list