]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/33459 (ICE on reference member in union)
authorPaolo Carlini <pcarlini@suse.de>
Thu, 20 Sep 2007 10:04:19 +0000 (10:04 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Thu, 20 Sep 2007 10:04:19 +0000 (10:04 +0000)
cp/
2007-09-20  Paolo Carlini  <pcarlini@suse.de>

PR c++/33459
* init.c (build_zero_init): If, recursively, build_zero_init
returns a NULL_TREE, do not append it to the VEC of constructors.

testsuite/
2007-09-20  Paolo Carlini  <pcarlini@suse.de>

PR c++/33459
* g++.dg/init/ref14.C: New.

From-SVN: r128616

gcc/cp/ChangeLog
gcc/cp/init.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/init/ref14.C [new file with mode: 0644]

index 6a1d20d872812156792c9013d98b5967f8764f0e..25a776083941a31b725f75b672dd3902eb699c3d 100644 (file)
@@ -1,3 +1,9 @@
+2007-09-20  Paolo Carlini  <pcarlini@suse.de>
+
+       PR c++/33459
+       * init.c (build_zero_init): If, recursively, build_zero_init
+       returns a NULL_TREE, do not append it to the VEC of constructors.
+
 2007-09-13  Jason Merrill  <jason@redhat.com>
 
        PR c++/15097
index 3c570c842f377891b53a6a5219fea611342e8db7..993b49af9b3d6e0e1c7eb33dccfc8c51042703df 100644 (file)
@@ -136,11 +136,12 @@ initialize_vtbl_ptrs (tree addr)
 /* Return an expression for the zero-initialization of an object with
    type T.  This expression will either be a constant (in the case
    that T is a scalar), or a CONSTRUCTOR (in the case that T is an
-   aggregate).  In either case, the value can be used as DECL_INITIAL
-   for a decl of the indicated TYPE; it is a valid static initializer.
-   If NELTS is non-NULL, and TYPE is an ARRAY_TYPE, NELTS is the
-   number of elements in the array.  If STATIC_STORAGE_P is TRUE,
-   initializers are only generated for entities for which
+   aggregate), or NULL (in the case that T does not require
+   initialization).  In either case, the value can be used as
+   DECL_INITIAL for a decl of the indicated TYPE; it is a valid static
+   initializer. If NELTS is non-NULL, and TYPE is an ARRAY_TYPE, NELTS
+   is the number of elements in the array.  If STATIC_STORAGE_P is
+   TRUE, initializers are only generated for entities for which
    zero-initialization does not simply mean filling the storage with
    zero bytes.  */
 
@@ -199,7 +200,8 @@ build_zero_init (tree type, tree nelts, bool static_storage_p)
              tree value = build_zero_init (TREE_TYPE (field),
                                            /*nelts=*/NULL_TREE,
                                            static_storage_p);
-             CONSTRUCTOR_APPEND_ELT(v, field, value);
+             if (value)
+               CONSTRUCTOR_APPEND_ELT(v, field, value);
            }
 
          /* For unions, only the first field is initialized.  */
index 86a0d88d6a05a3d80034e1ca66dad2ab2618649c..b9b825795fa307fc6c2761c501b14b2d42a0bb7b 100644 (file)
@@ -1,3 +1,8 @@
+2007-09-20  Paolo Carlini  <pcarlini@suse.de>
+
+       PR c++/33459
+       * g++.dg/init/ref14.C: New.
+
 2007-09-12  John David Anglin  <dave.anglin@nrc-crnc.gc.ca>
 
        PR testsuite/33153
diff --git a/gcc/testsuite/g++.dg/init/ref14.C b/gcc/testsuite/g++.dg/init/ref14.C
new file mode 100644 (file)
index 0000000..212e6e9
--- /dev/null
@@ -0,0 +1,11 @@
+// PR c++/33459
+
+union A
+{
+  int &i; // { dg-error "may not have reference type" }
+};
+
+void foo()
+{
+  A();
+}