aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2010-12-27 13:54:30 +0100
committerJakub Jelinek <jakub@gcc.gnu.org>2010-12-27 13:54:30 +0100
commitebb526f950a667e2bef588325e9a5f7bfb80ed09 (patch)
treed73ad4fa3267fddb914074659619e8abf36ece58 /gcc
parenta87394d5fb3101a6939fdd6c9514859a38898725 (diff)
downloadgcc-ebb526f950a667e2bef588325e9a5f7bfb80ed09.zip
gcc-ebb526f950a667e2bef588325e9a5f7bfb80ed09.tar.gz
gcc-ebb526f950a667e2bef588325e9a5f7bfb80ed09.tar.bz2
re PR c++/46626 (simple use of virtual methods causes pure virtual method call in c++0x mode)
PR c++/46626 * semantics.c (build_data_member_initialization): For CLEANUP_STMT recurse into CLEANUP_BODY. * g++.dg/cpp0x/constexpr-base4.C: New test. From-SVN: r168271
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/semantics.c24
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/constexpr-base4.C28
4 files changed, 58 insertions, 5 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 09e4353..b8247b4 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,9 @@
+2010-12-27 Jakub Jelinek <jakub@redhat.com>
+
+ PR c++/46626
+ * semantics.c (build_data_member_initialization): For CLEANUP_STMT
+ recurse into CLEANUP_BODY.
+
2010-12-25 Kai Tietz <kai.tietz@onevision.com>
PR c++/15774
diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index 25b9932..93493fb 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -5440,11 +5440,25 @@ build_data_member_initialization (tree t, VEC(constructor_elt,gc) **vec)
if (t == error_mark_node)
return false;
if (TREE_CODE (t) == CLEANUP_STMT)
- /* We can't see a CLEANUP_STMT in a constructor for a literal class,
- but we can in a constexpr constructor for a non-literal class. Just
- ignore it; either all the initialization will be constant, in which
- case the cleanup can't run, or it can't be constexpr. */
- return true;
+ {
+ /* We can't see a CLEANUP_STMT in a constructor for a literal class,
+ but we can in a constexpr constructor for a non-literal class. Just
+ ignore it; either all the initialization will be constant, in which
+ case the cleanup can't run, or it can't be constexpr.
+ Still recurse into CLEANUP_BODY. */
+ t = CLEANUP_BODY (t);
+ if (TREE_CODE (t) == STATEMENT_LIST)
+ {
+ tree_stmt_iterator i;
+ for (i = tsi_start (t); !tsi_end_p (i); tsi_next (&i))
+ {
+ if (! build_data_member_initialization (tsi_stmt (i), vec))
+ return false;
+ }
+ return true;
+ }
+ return build_data_member_initialization (t, vec);
+ }
if (TREE_CODE (t) == CONVERT_EXPR)
t = TREE_OPERAND (t, 0);
if (TREE_CODE (t) == INIT_EXPR
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 2e7a079..cf8ff72 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2010-12-27 Jakub Jelinek <jakub@redhat.com>
+
+ PR c++/46626
+ * g++.dg/cpp0x/constexpr-base4.C: New test.
+
2010-12-26 Nicola Pero <nicola.pero@meta-innovation.com>
* objc.dg/gnu-api-2-class.m: Xfail the test on Apple Darwin m64.
diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-base4.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-base4.C
new file mode 100644
index 0000000..ce23cb9
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-base4.C
@@ -0,0 +1,28 @@
+// PR c++/46626
+// { dg-do run }
+// { dg-options "-std=c++0x" }
+
+struct A
+{
+ virtual void f () = 0;
+ virtual ~A () { }
+};
+
+struct B : A
+{
+ virtual void f () { }
+};
+
+static void
+foo (A *a)
+{
+ a->f ();
+}
+
+int
+main ()
+{
+ B b;
+ foo (&b);
+ return 0;
+}