aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/decl.c
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2009-03-21 16:15:41 -0400
committerJason Merrill <jason@gcc.gnu.org>2009-03-21 16:15:41 -0400
commitc11655358bd4a0f3dba75e77dc531a9399f37684 (patch)
tree632fbc5aeb17457459bfa8833e865a8f2f37a7fd /gcc/cp/decl.c
parentb39f88bd05693c200851c934fca5ee8d0121173e (diff)
downloadgcc-c11655358bd4a0f3dba75e77dc531a9399f37684.zip
gcc-c11655358bd4a0f3dba75e77dc531a9399f37684.tar.gz
gcc-c11655358bd4a0f3dba75e77dc531a9399f37684.tar.bz2
re PR c++/28879 (ICE with VLA in template function)
PR c++/28879 * parser.c (cp_parser_direct_declarator): In a template, wrap non-constant expression in NOP_EXPR with TREE_SIDE_EFFECTS set. * pt.c (tsubst): Preserve it in a partial instantiation. (dependent_type_p_r): Don't check value_dependent_expression_p. * decl.c (compute_array_index_type): Don't check value_dependent_expression_p if TREE_SIDE_EFFECTS. From-SVN: r144988
Diffstat (limited to 'gcc/cp/decl.c')
-rw-r--r--gcc/cp/decl.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 9a6ab02..a96e606 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -7179,13 +7179,22 @@ compute_array_index_type (tree name, tree size)
type = TREE_TYPE (size);
}
- if (value_dependent_expression_p (size))
- {
- /* We cannot do any checking for a value-dependent SIZE. Just
- build the index type and mark that it requires structural
- equality checks. */
+ /* We can only call value_dependent_expression_p on integral constant
+ expressions; the parser adds a dummy NOP_EXPR with TREE_SIDE_EFFECTS
+ set if this isn't one. */
+ if (processing_template_decl
+ && (TREE_SIDE_EFFECTS (size) || value_dependent_expression_p (size)))
+ {
+ /* We cannot do any checking for a SIZE that isn't known to be
+ constant. Just build the index type and mark that it requires
+ structural equality checks. */
itype = build_index_type (build_min (MINUS_EXPR, sizetype,
size, integer_one_node));
+ if (!TREE_SIDE_EFFECTS (size))
+ {
+ TYPE_DEPENDENT_P (itype) = 1;
+ TYPE_DEPENDENT_P_VALID (itype) = 1;
+ }
SET_TYPE_STRUCTURAL_EQUALITY (itype);
return itype;
}