diff options
author | Jason Merrill <jason@redhat.com> | 2011-11-17 11:34:59 -0500 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2011-11-17 11:34:59 -0500 |
commit | a8e237782fe24e86b8f166454a0441e05d492631 (patch) | |
tree | 03d895e8c25b621baca604f09ef4088bcc638668 /gcc | |
parent | f14c43566a1fc02c036396baec3c04f27817899f (diff) | |
download | gcc-a8e237782fe24e86b8f166454a0441e05d492631.zip gcc-a8e237782fe24e86b8f166454a0441e05d492631.tar.gz gcc-a8e237782fe24e86b8f166454a0441e05d492631.tar.bz2 |
re PR c++/51137 ([C++0x] [4.7 Regression] ICE with -std=c++0x and virtual inheritance)
PR c++/51137
* class.c (build_base_path): Don't do calculation in templates.
From-SVN: r181444
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/cp/class.c | 14 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/template/virtual2.C | 11 |
4 files changed, 28 insertions, 7 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 4e5b265..3807f9a 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2011-11-17 Jason Merrill <jason@redhat.com> + + PR c++/51137 + * class.c (build_base_path): Don't do calculation in templates. + 2011-11-15 Torvald Riegel <triegel@redhat.com> * parser.c (cp_parser_transaction_expression): Require parentheses diff --git a/gcc/cp/class.c b/gcc/cp/class.c index 4a291ac..0765817 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -304,8 +304,13 @@ build_base_path (enum tree_code code, virtual_access = (v_binfo && fixed_type_p <= 0); /* Don't bother with the calculations inside sizeof; they'll ICE if the - source type is incomplete and the pointer value doesn't matter. */ - if (cp_unevaluated_operand != 0) + source type is incomplete and the pointer value doesn't matter. In a + template (even in fold_non_dependent_expr), we don't have vtables set + up properly yet, and the value doesn't matter there either; we're just + interested in the result of overload resolution. */ + if (cp_unevaluated_operand != 0 + || (current_function_decl + && uses_template_parms (current_function_decl))) { expr = build_nop (ptr_target_type, expr); if (!want_pointer) @@ -359,11 +364,6 @@ build_base_path (enum tree_code code, V_BINFO. That offset is an entry in D_BINFO's vtable. */ tree v_offset; - /* In a constructor template, current_in_charge_parm isn't set, - and we might end up here via fold_non_dependent_expr. */ - if (fixed_type_p < 0 && !(cfun && current_in_charge_parm)) - fixed_type_p = 0; - if (fixed_type_p < 0 && in_base_initializer) { /* In a base member initializer, we cannot rely on the diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index f345882..0aaaaaf 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2011-11-17 Jason Merrill <jason@redhat.com> + + PR c++/51137 + * g++.dg/template/virtual2.C: New. + 2011-11-17 Michael Matz <matz@suse.de> PR middle-end/50644 diff --git a/gcc/testsuite/g++.dg/template/virtual2.C b/gcc/testsuite/g++.dg/template/virtual2.C new file mode 100644 index 0000000..83b7ed6 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/virtual2.C @@ -0,0 +1,11 @@ +// PR c++/51137 + +struct A {}; + +template<int> struct B : virtual A +{ + void foo() + { + (new A(*this))->A::~A(); + } +}; |