2013-05-08 Jason Merrill <jason@redhat.com>
+ * except.c (is_admissible_throw_operand_or_catch_parameter): Check
+ variably_modified_type_p.
+ (expand_start_catch_block): Mark the typeinfo used here.
+ * semantics.c (finish_handler_parms): Not here.
+
+ * error.c (dump_type_suffix): Try harder on VLA length.
+
Core 624/N2932
* init.c (throw_bad_array_new_length): New.
(build_new_1): Use it. Don't warn about braced-init-list.
pp_character (cxx_pp, '0');
else if (host_integerp (max, 0))
pp_wide_integer (cxx_pp, tree_low_cst (max, 0) + 1);
- else if (TREE_CODE (max) == MINUS_EXPR)
- dump_expr (TREE_OPERAND (max, 0),
- flags & ~TFF_EXPR_IN_PARENS);
else
- dump_expr (fold_build2_loc (input_location,
- PLUS_EXPR, dtype, max,
- build_int_cst (dtype, 1)),
- flags & ~TFF_EXPR_IN_PARENS);
+ {
+ STRIP_NOPS (max);
+ if (TREE_CODE (max) == SAVE_EXPR)
+ max = TREE_OPERAND (max, 0);
+ if (TREE_CODE (max) == MINUS_EXPR
+ || TREE_CODE (max) == PLUS_EXPR)
+ {
+ max = TREE_OPERAND (max, 0);
+ while (CONVERT_EXPR_P (max))
+ max = TREE_OPERAND (max, 0);
+ }
+ else
+ max = fold_build2_loc (input_location,
+ PLUS_EXPR, dtype, max,
+ build_int_cst (dtype, 1));
+ dump_expr (max, flags & ~TFF_EXPR_IN_PARENS);
+ }
}
pp_cxx_right_bracket (cxx_pp);
dump_type_suffix (TREE_TYPE (t), flags);
decl = error_mark_node;
type = prepare_eh_type (TREE_TYPE (decl));
+ mark_used (eh_type_info (type));
}
else
type = NULL_TREE;
"reference type %qT", type);
return false;
}
+ else if (variably_modified_type_p (type, NULL_TREE))
+ {
+ if (is_throw)
+ error ("cannot throw expression of type %qT because it involves "
+ "types of variable size", type);
+ else
+ error ("cannot catch type %qT because it involves types of "
+ "variable size", type);
+ return false;
+ }
return true;
}
else
type = expand_start_catch_block (decl);
HANDLER_TYPE (handler) = type;
- if (!processing_template_decl && type)
- mark_used (eh_type_info (type));
}
/* Finish a handler, which may be given by HANDLER. The BLOCKs are