From: Jason Merrill Date: Mon, 28 Jan 2008 16:27:17 +0000 (-0500) Subject: re PR c++/27177 (ICE in build_simple_base_path, at cp/class.c:474) X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ea02170cf404f378c05440cdc1ac66fb66c63eab;p=thirdparty%2Fgcc.git re PR c++/27177 (ICE in build_simple_base_path, at cp/class.c:474) PR c++/27177 * class.c (build_base_path): Fix previous change. PR c++/27177 * class.c (build_base_path): Don't mess with virtual access if skip_evaluation. * call.c (standard_conversion): Don't check whether source type is complete. PR c++/33959 * pt.c (tsubst_aggr_type): Make sure our context is complete. From-SVN: r131907 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 85e439bd7861..0dd212a6edff 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,17 @@ +2008-01-27 Jason Merrill + + PR c++/27177 + * class.c (build_base_path): Fix previous change. + + PR c++/27177 + * class.c (build_base_path): Don't mess with virtual access if + skip_evaluation. + * call.c (standard_conversion): Don't check whether source type + is complete. + + PR c++/33959 + * pt.c (tsubst_aggr_type): Make sure our context is complete. + 2007-10-26 Jakub Jelinek PR c++/33744 diff --git a/gcc/cp/call.c b/gcc/cp/call.c index b9941bc40152..508982d3e4cc 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -714,19 +714,7 @@ 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)) - /* 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))) + && DERIVED_FROM_P (TREE_TYPE (to), TREE_TYPE (from))) { from = cp_build_qualified_type (TREE_TYPE (to), diff --git a/gcc/cp/class.c b/gcc/cp/class.c index 5249c8b72ab2..9d7dd8800fd0 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -294,6 +294,11 @@ build_base_path (enum tree_code code, /* Do we need to look in the vtable for the real offset? */ 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 (skip_evaluation) + return build_nop (build_pointer_type (target_type), expr); + /* Do we need to check for a null pointer? */ if (want_pointer && !nonnull) { diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 2c91eb0718cc..e3d5d05cb485 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -6164,8 +6164,14 @@ tsubst_aggr_type (tree t, up. */ context = TYPE_CONTEXT (t); if (context) - context = tsubst_aggr_type (context, args, complain, - in_decl, /*entering_scope=*/1); + { + context = tsubst_aggr_type (context, args, complain, + in_decl, /*entering_scope=*/1); + /* If context is a nested class inside a class template, + it may still need to be instantiated (c++/33959). */ + if (TYPE_P (context)) + complete_type (context); + } /* Then, figure out what arguments are appropriate for the type we are trying to find. For example, given: