re PR c++/51431 (ICE with invalid use of abstract class)
authorPaolo Carlini <paolo.carlini@oracle.com>
Tue, 6 Dec 2011 17:12:17 +0000 (17:12 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Tue, 6 Dec 2011 17:12:17 +0000 (17:12 +0000)
/cp
2011-12-06  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/51431
* init.c (build_value_init): Check build_aggr_init_expr return
value for error_mark_node.

/testsuite
2011-12-06  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/51431
* g++.dg/other/abstract3.C: New.

From-SVN: r182055

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

index 4391a478e9ada4ba4f1bfcbd3ae5ae97b80ee4c5..f979af5999fb8ae6f144a61ec50c2250d7a97381 100644 (file)
@@ -1,3 +1,9 @@
+2011-12-06  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/51431
+       * init.c (build_value_init): Check build_aggr_init_expr return
+       value for error_mark_node.
+
 2011-12-06  Dodji Seketeli  <dodji@redhat.com>
 
        PR c++/51427
index 8e28e3b3044bd4fb604912b73cffe2882ab307ed..e1eb681de67636a74d5343a26b8137c1b0392195 100644 (file)
@@ -359,11 +359,9 @@ build_value_init (tree type, tsubst_flags_t complain)
          tree ctor = build_special_member_call
            (NULL_TREE, complete_ctor_identifier,
             NULL, type, LOOKUP_NORMAL, complain);
+         ctor = build_aggr_init_expr (type, ctor, complain);
          if (ctor != error_mark_node)
-           {
-             ctor = build_aggr_init_expr (type, ctor, complain);
-             AGGR_INIT_ZERO_FIRST (ctor) = 1;
-           }
+           AGGR_INIT_ZERO_FIRST (ctor) = 1;
          return ctor;
        }
     }
index f4c61d34f9c758f04b2188116820e2f9b554d1c7..ac537cf44e879ba9352614bd9c9087c7ceedd043 100644 (file)
@@ -1,3 +1,8 @@
+2011-12-06  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/51431
+       * g++.dg/other/abstract3.C: New.
+
 2011-12-06  Richard Guenther  <rguenther@suse.de>
 
        PR tree-optimization/49997
diff --git a/gcc/testsuite/g++.dg/other/abstract3.C b/gcc/testsuite/g++.dg/other/abstract3.C
new file mode 100644 (file)
index 0000000..528b7d7
--- /dev/null
@@ -0,0 +1,12 @@
+// PR c++/51431
+
+struct A                  // { dg-message "note" }
+{
+  virtual void foo() = 0; // { dg-message "note" }
+};
+
+struct B
+{
+  A a;           // { dg-error "abstract" }
+  B() : a() {}   // { dg-error "abstract" }
+};