mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-03-22 15:00:55 +08:00
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
This commit is contained in:
parent
a87394d5fb
commit
ebb526f950
@ -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
|
||||
|
@ -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
|
||||
|
@ -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.
|
||||
|
28
gcc/testsuite/g++.dg/cpp0x/constexpr-base4.C
Normal file
28
gcc/testsuite/g++.dg/cpp0x/constexpr-base4.C
Normal file
@ -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;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user