diff options
author | Mark Mitchell <mark@codesourcery.com> | 2006-06-06 21:38:54 +0000 |
---|---|---|
committer | Mark Mitchell <mmitchel@gcc.gnu.org> | 2006-06-06 21:38:54 +0000 |
commit | b6ca28e64b3f31a4fac50e506f63d947d9697ca0 (patch) | |
tree | bd2f3421ea002ee456b375edb294c66e22917bae | |
parent | 6edf8a522985d30615ff15de817b1b47969dc5b9 (diff) | |
download | gcc-b6ca28e64b3f31a4fac50e506f63d947d9697ca0.zip gcc-b6ca28e64b3f31a4fac50e506f63d947d9697ca0.tar.gz gcc-b6ca28e64b3f31a4fac50e506f63d947d9697ca0.tar.bz2 |
re PR c++/27177 (ICE in build_simple_base_path, at cp/class.c:474)
PR c++/27177
* call.c (standard_conversion): Require that the derived type be
complete when performing a derived-to-base conversion.
PR c++/27177
* g++.dg/expr/cast7.C: New test.
From-SVN: r114448
-rw-r--r-- | gcc/cp/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/cp/call.c | 14 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/expr/cast7.C | 13 |
4 files changed, 37 insertions, 1 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index f0a8503..c63ad83 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2006-06-06 Mark Mitchell <mark@codesourcery.com> + + PR c++/27177 + * call.c (standard_conversion): Require that the derived type be + complete when performing a derived-to-base conversion. + 2006-06-04 Mark Mitchell <mark@codesourcery.com> PR c++/27819 diff --git a/gcc/cp/call.c b/gcc/cp/call.c index f852c97..db8dd21 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -727,7 +727,19 @@ standard_conversion (tree to, tree from, tree expr, bool c_cast_p, that necessitates this conversion is ill-formed. Therefore, we use DERIVED_FROM_P, and do not check access or uniqueness. */ - && DERIVED_FROM_P (TREE_TYPE (to), TREE_TYPE (from))) + && DERIVED_FROM_P (TREE_TYPE (to), TREE_TYPE (from)) + /* If FROM is not yet complete, then we must be parsing + the body of a class. We know what's derived from + what, but we can't actually perform a + derived-to-base conversion. For example, in: + + struct D : public B { + static const int i = sizeof((B*)(D*)0); + }; + + the D*-to-B* conversion is a reinterpret_cast, not a + static_cast. */ + && COMPLETE_TYPE_P (TREE_TYPE (from))) { from = cp_build_qualified_type (TREE_TYPE (to), diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index dc457d1..0f42204 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2006-06-06 Mark Mitchell <mark@codesourcery.com> + + PR c++/27177 + * g++.dg/expr/cast7.C: New test. + 2006-06-06 Janis Johnson <janis187@us.ibm.com> * lib/gcc-dg.exp (gcc-dg-test-1): Detect and report ICE. diff --git a/gcc/testsuite/g++.dg/expr/cast7.C b/gcc/testsuite/g++.dg/expr/cast7.C new file mode 100644 index 0000000..c948919 --- /dev/null +++ b/gcc/testsuite/g++.dg/expr/cast7.C @@ -0,0 +1,13 @@ +// PR c++/27177 + +struct X {}; + +struct Y : virtual X {}; +struct Z : virtual X {}; + +struct A : Y, Z {}; + +struct B : A +{ + static const int i = sizeof((Z*)(B*)0); +}; |