]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/38698 (ICE initializing union with initializer list)
authorJason Merrill <jason@redhat.com>
Tue, 6 Jan 2009 03:27:39 +0000 (22:27 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Tue, 6 Jan 2009 03:27:39 +0000 (22:27 -0500)
        PR c++/38698
        * typeck2.c (process_init_constructor_union): Handle union with
        no fields.

        * mangle.c (write_expression): Remove mangling for zero-operand
        casts.

From-SVN: r143111

gcc/cp/ChangeLog
gcc/cp/mangle.c
gcc/cp/typeck2.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/initlist12.C

index cc4fce11d63f0135851e87a5efc88ab660c0200f..1e85539e988e2cd9f6e4ac36268b1a10c777a697 100644 (file)
@@ -5,6 +5,13 @@
 
 2009-01-05  Jason Merrill  <jason@redhat.com>
 
+       PR c++/38698
+       * typeck2.c (process_init_constructor_union): Handle union with
+       no fields.
+
+       * mangle.c (write_expression): Remove mangling for zero-operand
+       casts.
+
        PR c++/38701
        * decl.c (cp_finish_decl): Clear DECL_INITIAL for invalid
        defaulting.
index 1ec27c1ffcd722ea1e322caa05dd1beeefa14db6..a7b466217ebd0aaf7e32d07636681d67f8f05f0d 100644 (file)
@@ -2348,12 +2348,12 @@ write_expression (tree expr)
 
        case CAST_EXPR:
          write_type (TREE_TYPE (expr));
+         /* There is no way to mangle a zero-operand cast like
+            "T()".  */
          if (!TREE_OPERAND (expr, 0))
-           /* "T()" is mangled as "T(void)".  */
-           write_char ('v');
+           sorry ("zero-operand casts cannot be mangled due to a defect "
+                  "in the C++ ABI");
          else if (list_length (TREE_OPERAND (expr, 0)) > 1)
-           /* FIXME the above hack for T() needs to be replaced with
-              something more general.  */
            sorry ("mangling function-style cast with more than one argument");
          else
            write_expression (TREE_VALUE (TREE_OPERAND (expr, 0)));
index e313e4b9a5d08f17b0ec2bfa3688f1723a414cf5..60e4ef1725429dfc01635bb0dea59908b9362512 100644 (file)
@@ -1147,7 +1147,11 @@ process_init_constructor_union (tree type, tree init)
       tree field = TYPE_FIELDS (type);
       while (field && (!DECL_NAME (field) || TREE_CODE (field) != FIELD_DECL))
        field = TREE_CHAIN (field);
-      gcc_assert (field);
+      if (field == NULL_TREE)
+       {
+         error ("too many initializers for %qT", type);
+         ce->value = error_mark_node;
+       }
       ce->index = field;
     }
 
index 9e7d658d7159a405d02ee100d89a18061de11b7b..7c43f7826750f0b18adf80e75162dcb457b64ee9 100644 (file)
@@ -53,6 +53,8 @@
 
 2009-01-05  Jason Merrill  <jason@redhat.com>
 
+       * g++.dg/cpp0x/initlist12.C: Add another test.
+
        * g++.dg/cpp0x/defaulted7.C: New test.
 
 2009-01-05  Thomas Koenig  <tkoenig@gcc.gnu.org>
index 54349bf9feffc163d880368fd8bb293b8c8e7ae5..31d34c4e71db85aa17306639e8e995887738898e 100644 (file)
@@ -14,3 +14,7 @@ union U
 };
 
 U u({1,2});                    // { dg-error "too many initializers" }
+
+union V {};
+
+V v({1});                      // { dg-error "too many initializers" }