* pt.c (tsubst) [ARRAY_TYPE]: Check valid_array_size_p.
(tsubst_copy_and_build) [NEW_EXPR]: Clear in_decl.
gcc/c-family/
* c-common.c (valid_array_size_p): Add complain parameter.
* c-common.h: ...which defaults to true.
From-SVN: r260227
+2018-05-09 Jason Merrill <jason@redhat.com>
+
+ * c-common.c (valid_array_size_p): Add complain parameter.
+ * c-common.h: ...which defaults to true.
+
2018-05-11 Jakub Jelinek <jakub@redhat.com>
PR c/85696
the name of the array, or NULL_TREE for unnamed arrays. */
bool
-valid_array_size_p (location_t loc, tree type, tree name)
+valid_array_size_p (location_t loc, tree type, tree name, bool complain)
{
if (type != error_mark_node
&& COMPLETE_TYPE_P (type)
&& TREE_CODE (TYPE_SIZE_UNIT (type)) == INTEGER_CST
&& !valid_constant_size_p (TYPE_SIZE_UNIT (type)))
{
- if (name)
- error_at (loc, "size of array %qE is too large", name);
- else
- error_at (loc, "size of unnamed array is too large");
+ if (complain)
+ {
+ if (name)
+ error_at (loc, "size of array %qE is too large", name);
+ else
+ error_at (loc, "size of unnamed array is too large");
+ }
return false;
}
return true;
extern tree replace_inv_trees (tree *, int *, void *);
extern bool reject_gcc_builtin (const_tree, location_t = UNKNOWN_LOCATION);
-extern bool valid_array_size_p (location_t, tree, tree);
+extern bool valid_array_size_p (location_t, tree, tree, bool = true);
/* In c-warn.c. */
extern void constant_expression_warning (tree);
+2018-05-14 Jason Merrill <jason@redhat.com>
+
+ * pt.c (tsubst) [ARRAY_TYPE]: Check valid_array_size_p.
+ (tsubst_copy_and_build) [NEW_EXPR]: Clear in_decl.
+
2018-05-11 Jakub Jelinek <jakub@redhat.com>
PR c/85696
r = build_cplus_array_type (type, domain);
+ if (!valid_array_size_p (input_location, r, in_decl,
+ (complain & tf_error)))
+ return error_mark_node;
+
if (TYPE_USER_ALIGN (t))
{
SET_TYPE_ALIGN (r, TYPE_ALIGN (t));
}
}
+ /* Avoid passing an enclosing decl to valid_array_size_p. */
+ in_decl = NULL_TREE;
+
tree op1 = tsubst (TREE_OPERAND (t, 1), args, complain, in_decl);
tree op2 = RECUR (TREE_OPERAND (t, 2));
ret = build_new (&placement_vec, op1, op2, &init_vec,
void
large_array_template1(int n)
{
- new T[n] // { dg-error "size of array is too large" }
+ new T[n] // { dg-error "size of unnamed array is too large" }
[(1ULL << (sizeof(void *) * 4)) / sizeof(T)]
[1ULL << (sizeof(void *) * 4)];
}
void
large_array_template2(int n)
{
- new T[n] // { dg-error "size of array is too large" }
+ new T[n] // { dg-error "size of unnamed array is too large" }
[(1ULL << (sizeof(void *) * 4)) / sizeof(T)]
[1ULL << (sizeof(void *) * 4)];
}
void
large_array_template3(int n)
{
- new T[n] // { dg-error "size of array is too large" }
+ new T[n] // { dg-error "size of unnamed array is too large" }
[(1ULL << (sizeof(void *) * 4)) / sizeof(T)]
[1ULL << (sizeof(void *) * 4)];
}
--- /dev/null
+template <int I>
+struct A
+{
+ int ar[I][I][I][I][I][I][I][I][I][I]; // { dg-error "too large" }
+};
+
+A<66000> a;