OSDN Git Service

PR c++/54325
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 7 Dec 2012 05:13:33 +0000 (05:13 +0000)
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 7 Dec 2012 05:13:33 +0000 (05:13 +0000)
* tree.c (build_aggr_init_expr): Don't check for abstract class.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_7-branch@194290 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/cp/ChangeLog
gcc/cp/tree.c
gcc/testsuite/g++.dg/cpp0x/initlist-pure.C [new file with mode: 0644]
gcc/testsuite/g++.dg/other/abstract3.C

index 8a018dd..35c620c 100644 (file)
@@ -1,5 +1,9 @@
 2012-12-06  Jason Merrill  <jason@redhat.com>
 
+       PR c++/54325
+       * tree.c (build_aggr_init_expr): Don't check for abstract class.
+       (build_cplus_new): Check here instead.
+
        PR c++/55058
        * pt.c (tsubst): Keep the quals when looking through a typedef.
 
index 8fad0fb..0341956 100644 (file)
@@ -396,18 +396,13 @@ build_aggr_init_array (tree return_type, tree fn, tree slot, int nargs,
    callable.  */
 
 tree
-build_aggr_init_expr (tree type, tree init, tsubst_flags_t complain)
+build_aggr_init_expr (tree type, tree init, tsubst_flags_t /*complain*/)
 {
   tree fn;
   tree slot;
   tree rval;
   int is_ctor;
 
-  /* Make sure that we're not trying to create an instance of an
-     abstract class.  */
-  if (abstract_virtuals_error_sfinae (NULL_TREE, type, complain))
-    return error_mark_node;
-
   if (TREE_CODE (init) == CALL_EXPR)
     fn = CALL_EXPR_FN (init);
   else if (TREE_CODE (init) == AGGR_INIT_EXPR)
@@ -466,6 +461,11 @@ build_cplus_new (tree type, tree init, tsubst_flags_t complain)
   tree rval = build_aggr_init_expr (type, init, complain);
   tree slot;
 
+  /* Make sure that we're not trying to create an instance of an
+     abstract class.  */
+  if (abstract_virtuals_error_sfinae (NULL_TREE, type, complain))
+    return error_mark_node;
+
   if (TREE_CODE (rval) == AGGR_INIT_EXPR)
     slot = AGGR_INIT_EXPR_SLOT (rval);
   else if (TREE_CODE (rval) == CALL_EXPR
diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist-pure.C b/gcc/testsuite/g++.dg/cpp0x/initlist-pure.C
new file mode 100644 (file)
index 0000000..63c341c
--- /dev/null
@@ -0,0 +1,25 @@
+// PR c++/54325
+// { dg-options -std=c++11 }
+
+class Base {
+public:
+  Base() {};
+  virtual ~Base() {};
+
+  virtual void do_stuff() = 0;
+};
+
+class Derived: public Base {
+public:
+  Derived() : Base{} {};
+  virtual ~Derived() {};
+
+  virtual void do_stuff() {};
+};
+
+int
+main() {
+  Derived d;
+
+  return 0;
+}
index 528b7d7..95e293e 100644 (file)
@@ -8,5 +8,5 @@ struct A                  // { dg-message "note" }
 struct B
 {
   A a;           // { dg-error "abstract" }
-  B() : a() {}   // { dg-error "abstract" }
+  B() : a() {}
 };