aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp
diff options
context:
space:
mode:
authorPaolo Carlini <paolo.carlini@oracle.com>2015-12-09 16:59:26 +0000
committerPaolo Carlini <paolo@gcc.gnu.org>2015-12-09 16:59:26 +0000
commit2efc721885206a44fc19814a7b1ef3d83ba3d2ab (patch)
tree1797e8f161c9dce3cd34b2b73145e4676c4fe834 /gcc/cp
parent026d0d538b66652ab69d361abb5542821c09c9b8 (diff)
downloadgcc-2efc721885206a44fc19814a7b1ef3d83ba3d2ab.zip
gcc-2efc721885206a44fc19814a7b1ef3d83ba3d2ab.tar.gz
gcc-2efc721885206a44fc19814a7b1ef3d83ba3d2ab.tar.bz2
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
Diffstat (limited to 'gcc/cp')
-rw-r--r--gcc/cp/ChangeLog7
-rw-r--r--gcc/cp/semantics.c20
2 files changed, 20 insertions, 7 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index ac41ca6..e8bcba5 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -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>
PR c++/68711
diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index 80d1b10..b8f4e8f 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -3851,8 +3851,9 @@ calculate_bases_helper (tree type)
vec<tree, va_gc> *vector = make_tree_vector();
/* Now add non-virtual base classes in order of construction */
- dfs_walk_all (TYPE_BINFO (type),
- dfs_calculate_bases_pre, dfs_calculate_bases_post, &vector);
+ if (TYPE_BINFO (type))
+ dfs_walk_all (TYPE_BINFO (type),
+ dfs_calculate_bases_pre, dfs_calculate_bases_post, &vector);
return vector;
}
@@ -3886,13 +3887,18 @@ calculate_bases (tree type)
vec_safe_splice (vector, nonvbases);
release_tree_vector (nonvbases);
- /* 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)
+ /* Note that during error recovery vector->length can even be zero. */
+ if (vector->length () > 1)
{
- 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);
return bases_vec;
}