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

Douglas Gregor dgregor at apple.com
Tue Jul 12 19:14:02 PDT 2011


Author: dgregor
Date: Tue Jul 12 21:14:02 2011
New Revision: 135027

URL: http://llvm.org/viewvc/llvm-project?rev=135027&view=rev
Log:
Eliminate an incomplete/incorrect attempt to provide support for C++0x
unrestricted unions, which ended up attempting to initialize objects
in a union (which CodeGen isn't prepared for). Fixes PR9683.

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=135027&r1=135026&r2=135027&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Tue Jul 12 21:14:02 2011
@@ -2190,11 +2190,8 @@
         }
       }
 
-      // 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.

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=135027&r1=135026&r2=135027&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/anonymous-union-member-initializer.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/anonymous-union-member-initializer.cpp Tue Jul 12 21:14:02 2011
@@ -114,3 +114,19 @@
   };
 };
 Foo<int> f;
+
+namespace PR9683 {
+  struct QueueEntry {
+    union {
+      struct {
+        void* mPtr;
+        union {
+          unsigned mSubmissionTag;
+        };
+      };
+      unsigned mValue;
+    };
+    QueueEntry() {}
+  };
+  QueueEntry QE;
+}





More information about the cfe-commits mailing list