re PR c++/60218 ([c++11] ICE using __bases for broken class hierarchy)

/cp
2015-12-09  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/60218
	* semantics.c (calculate_bases_helper): Don't call dfs_walk_all
	when TYPE_BINFO (type) is null.
	(calculate_bases): Handle gracefully a null vector->length ().

/testsuite
2015-12-09  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/60218
	* g++.dg/ext/bases2.C: New.

From-SVN: r231460
This commit is contained in:
Paolo Carlini 2015-12-09 16:59:26 +00:00 committed by Paolo Carlini
parent 026d0d538b
commit 2efc721885
4 changed files with 39 additions and 7 deletions

View File

@ -1,3 +1,10 @@
2015-12-09 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/60218
* semantics.c (calculate_bases_helper): Don't call dfs_walk_all
when TYPE_BINFO (type) is null.
(calculate_bases): Handle gracefully a null vector->length ().
2015-12-08 Martin Sebor <msebor@redhat.com> 2015-12-08 Martin Sebor <msebor@redhat.com>
PR c++/68711 PR c++/68711

View File

@ -3851,8 +3851,9 @@ calculate_bases_helper (tree type)
vec<tree, va_gc> *vector = make_tree_vector(); vec<tree, va_gc> *vector = make_tree_vector();
/* Now add non-virtual base classes in order of construction */ /* Now add non-virtual base classes in order of construction */
dfs_walk_all (TYPE_BINFO (type), if (TYPE_BINFO (type))
dfs_calculate_bases_pre, dfs_calculate_bases_post, &vector); dfs_walk_all (TYPE_BINFO (type),
dfs_calculate_bases_pre, dfs_calculate_bases_post, &vector);
return vector; return vector;
} }
@ -3886,13 +3887,18 @@ calculate_bases (tree type)
vec_safe_splice (vector, nonvbases); vec_safe_splice (vector, nonvbases);
release_tree_vector (nonvbases); release_tree_vector (nonvbases);
/* Last element is entire class, so don't copy */ /* Note that during error recovery vector->length can even be zero. */
bases_vec = make_tree_vec (vector->length () - 1); if (vector->length () > 1)
for (i = 0; i < vector->length () - 1; ++i)
{ {
TREE_VEC_ELT (bases_vec, i) = (*vector)[i]; /* Last element is entire class, so don't copy */
bases_vec = make_tree_vec (vector->length() - 1);
for (i = 0; i < vector->length () - 1; ++i)
TREE_VEC_ELT (bases_vec, i) = (*vector)[i];
} }
else
bases_vec = make_tree_vec (0);
release_tree_vector (vector); release_tree_vector (vector);
return bases_vec; return bases_vec;
} }

View File

@ -1,3 +1,8 @@
2015-12-09 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/60218
* g++.dg/ext/bases2.C: New.
2015-12-09 Uros Bizjak <ubizjak@gmail.com> 2015-12-09 Uros Bizjak <ubizjak@gmail.com>
* gcc.target/i386/sse4_1-roundps-1.c: Remove ASM_SUFFIX define. * gcc.target/i386/sse4_1-roundps-1.c: Remove ASM_SUFFIX define.

View File

@ -0,0 +1,14 @@
// PR c++/60218
// { dg-do compile { target c++11 } }
template<typename...> struct A {};
template<typename T> struct B
{
typedef A<__bases(T)...> C;
};
struct X {};
struct Y : X* {}; // { dg-error "expected" }
B<Y> b;