]> granicus.if.org Git - clang/commitdiff
Eliminate an incomplete/incorrect attempt to provide support for C++0x
authorDouglas Gregor <dgregor@apple.com>
Wed, 13 Jul 2011 02:14:02 +0000 (02:14 +0000)
committerDouglas Gregor <dgregor@apple.com>
Wed, 13 Jul 2011 02:14:02 +0000 (02:14 +0000)
unrestricted unions, which ended up attempting to initialize objects
in a union (which CodeGen isn't prepared for). Fixes PR9683.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135027 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaDeclCXX.cpp
test/CodeGenCXX/anonymous-union-member-initializer.cpp

index 62c163435c7a216daf9bc1b4b5e959abbf41008b..d793daf9d826408ce3a166066525eb554ed2f32f 100644 (file)
@@ -2190,11 +2190,8 @@ static bool CollectFieldInitializer(Sema &SemaRef, BaseAndFieldInfo &Info,
         }
       }
 
-      // Fallthrough and construct a default initializer for the union as
-      // a whole, which can call its default constructor if such a thing exists
-      // (C++0x perhaps). FIXME: It's not clear that this is the correct
-      // behavior going forward with C++0x, when anonymous unions there are
-      // finalized, we should revisit this.
+      // FIXME: C++0x unrestricted unions might call a default constructor here.
+      return false;
     } else {
       // For structs, we simply descend through to initialize all members where
       // necessary.
index ce2ffb38d2c22c11a1b6428cc4179cf8ba948b56..324ff4aee2b7a384ad1102ed90bc7355226c6105 100644 (file)
@@ -114,3 +114,19 @@ template <typename T> struct Foo {
   };
 };
 Foo<int> f;
+
+namespace PR9683 {
+  struct QueueEntry {
+    union {
+      struct {
+        void* mPtr;
+        union {
+          unsigned mSubmissionTag;
+        };
+      };
+      unsigned mValue;
+    };
+    QueueEntry() {}
+  };
+  QueueEntry QE;
+}