On 2/1/19 7:41 AM, Jason Merrill wrote:
On 1/31/19 5:49 PM, Martin Sebor wrote:
On 1/30/19 3:15 PM, Jason Merrill wrote:
On 1/29/19 7:15 PM, Martin Sebor wrote:
+ /* Try to convert the original SIZE to a ssizetype. */
+ if (orig_size != error_mark_node
+ && !TYPE_UNSIGNED (TREE_TYPE (orig_size)))
+ {
+ if (TREE_CODE (size) == INTEGER_CST
+ && tree_int_cst_sign_bit (size))
+ diagsize = build_converted_constant_expr (ssizetype, size,
+ tsubst_flags_t ());
+ else if (size == error_mark_node
+ && TREE_CODE (orig_size) == INTEGER_CST
+ && tree_int_cst_sign_bit (orig_size))
+ diagsize = build_converted_constant_expr (ssizetype,
orig_size,
+ tsubst_flags_t ());
+ }
Using build_converted_constant_expr here looks odd; that's a
language-level notion, and we're dealing with compiler internals.
fold_convert seems more appropriate.
Done.
+ if (TREE_CONSTANT (size))
+ {
+ if (!diagsize && TREE_CODE (size) == INTEGER_CST)
+ diagsize = size;
+ }
+ else
size = osize;
}
@@ -9732,15 +9758,12 @@ compute_array_index_type_loc (location_t
name_loc,
if (TREE_CODE (size) == INTEGER_CST)
{
/* An array must have a positive number of elements. */
- if (!valid_constant_size_p (size))
+ if (!diagsize)
+ diagsize = size;
It seems like the earlier hunk here is unnecessary; if size is an
INTEGER_CST, it will be unchanged, and so be used for diagsize in the
latter hunk without any changes to the earlier location. Actually,
why not do all of the diagsize logic down here? There doesn't seem
to be anything above that relies on information we will have lost at
this point.
Sure. Done in the attached revision.
- tree osize = size;
+ /* The original numeric size as seen in the source code after
+ any substitution and before conversion to size_t. */
+ tree origsize = NULL_TREE;
Can't you use osize? instantiate_non_dependent_expr doesn't do any
actual substitution, it shouldn't change the type of the expression or
affect whether it's an INTEGER_CST.
I went ahead and reused osize but kept the new name origsize (I assume
avoiding introducing a new variable is what you meant). The longer
name is more descriptive and also has a comment explaining what it's
for (which is why I didn't touch osize initially -- I didn't know
enough about what it was for or how it might change).
Martin
PR c++/87996 - size of array is negative error when SIZE_MAX/2 < sizeof(array) <= SIZE_MAX
gcc/ChangeLog:
PR c++/87996
* builtins.c (max_object_size): Move from here...
* builtins.h (max_object_size): ...and here...
* tree.c (max_object_size): ...to here...
* tree.h (max_object_size): ...and here.
gcc/c-family/ChangeLog:
PR c++/87996
* c-common.c (invalid_array_size_error): New function.
(valid_array_size_p): Call it. Handle size as well as type.
* c-common.h (valid_constant_size_p): New function.
(enum cst_size_error): New type.
gcc/cp/ChangeLog:
PR c++/87996
* decl.c (compute_array_index_type_loc): Preserve signed sizes
for diagnostics. Call valid_array_size_p instead of error.
* init.c (build_new_1): Compute size for diagnostic. Call
invalid_array_size_error
(build_new): Call valid_array_size_p instead of error.
gcc/testsuite/ChangeLog:
PR c++/87996
* c-c++-common/array-5.c: New test.
* c-c++-common/pr68107.c: Adjust text of diagnostics.
* g++.dg/init/new38.C: Same.
* g++.dg/init/new43.C: Same.
* g++.dg/init/new44.C: Same.
* g++.dg/init/new46.C: Same.
* g++.dg/other/large-size-array.C: Same.
* g++.dg/other/new-size-type.C: Same.
* g++.dg/template/array30.C: Same.
* g++.dg/template/array32.C: New test.
* g++.dg/template/dependent-name3.C: Adjust.
* gcc.dg/large-size-array-3.c: Same.
* gcc.dg/large-size-array-5.c: Same.
* gcc.dg/large-size-array.c: Same.
* g++.old-deja/g++.brendan/array1.C: Same.
* g++.old-deja/g++.mike/p6149.C: Same.
Index: gcc/builtins.c
===================================================================
--- gcc/builtins.c (revision 268547)
+++ gcc/builtins.c (working copy)
@@ -11210,12 +11210,3 @@ target_char_cst_p (tree t, char *p)
*p = (char)tree_to_uhwi (t);
return true;
}
-
-/* Return the maximum object size. */
-
-tree
-max_object_size (void)
-{
- /* To do: Make this a configurable parameter. */
- return TYPE_MAX_VALUE (ptrdiff_type_node);
-}
Index: gcc/builtins.h
===================================================================
--- gcc/builtins.h (revision 268547)
+++ gcc/builtins.h (working copy)
@@ -150,6 +150,5 @@ extern internal_fn replacement_internal_fn (gcall
extern void warn_string_no_nul (location_t, const char *, tree, tree);
extern tree unterminated_array (tree, tree * = NULL, bool * = NULL);
-extern tree max_object_size ();
#endif /* GCC_BUILTINS_H */
Index: gcc/c-family/c-common.c
===================================================================
--- gcc/c-family/c-common.c (revision 268547)
+++ gcc/c-family/c-common.c (working copy)
@@ -8231,29 +8231,82 @@ reject_gcc_builtin (const_tree expr, location_t lo
return false;
}
+/* Issue an ERROR for an invalid SIZE of array NAME which is null
+ for unnamed arrays. */
+
+void
+invalid_array_size_error (location_t loc, cst_size_error error,
+ const_tree size, const_tree name)
+{
+ tree maxsize = max_object_size ();
+ switch (error)
+ {
+ case cst_size_negative:
+ if (name)
+ error_at (loc, "size %qE of array %qE is negative",
+ size, name);
+ else
+ error_at (loc, "size %qE of array is negative",
+ size);
+ break;
+ case cst_size_too_big:
+ if (name)
+ error_at (loc, "size %qE of array %qE exceeds maximum "
+ "object size %qE", size, name, maxsize);
+ else
+ error_at (loc, "size %qE of array exceeds maximum "
+ "object size %qE", size, maxsize);
+ break;
+ case cst_size_overflow:
+ if (name)
+ error_at (loc, "size of array %qE exceeds maximum "
+ "object size %qE", name, maxsize);
+ else
+ error_at (loc, "size of array exceeds maximum "
+ "object size %qE", maxsize);
+ break;
+ default:
+ gcc_unreachable ();
+ }
+}
+
/* Check if array size calculations overflow or if the array covers more
than half of the address space. Return true if the size of the array
- is valid, false otherwise. TYPE is the type of the array and NAME is
- the name of the array, or NULL_TREE for unnamed arrays. */
+ is valid, false otherwise. T is either the type of the array or its
+ size, and NAME is the name of the array, or null for unnamed arrays. */
bool
-valid_array_size_p (location_t loc, tree type, tree name, bool complain)
+valid_array_size_p (location_t loc, const_tree t, 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 (t == error_mark_node)
+ return true;
+
+ const_tree size;
+ if (TYPE_P (t))
{
- 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;
+ if (!COMPLETE_TYPE_P (t))
+ return true;
+ size = TYPE_SIZE_UNIT (t);
}
- return true;
+ else
+ size = t;
+
+ if (TREE_CODE (size) != INTEGER_CST)
+ return true;
+
+ cst_size_error error;
+ if (valid_constant_size_p (size, &error))
+ return true;
+
+ if (!complain)
+ return false;
+
+ if (TREE_CODE (TREE_TYPE (size)) == ENUMERAL_TYPE)
+ /* Show the value of the enumerator rather than its name. */
+ size = convert (ssizetype, const_cast<tree> (size));
+
+ invalid_array_size_error (loc, error, size, name);
+ return false;
}
/* Read SOURCE_DATE_EPOCH from environment to have a deterministic
Index: gcc/c-family/c-common.h
===================================================================
--- gcc/c-family/c-common.h (revision 268547)
+++ gcc/c-family/c-common.h (working copy)
@@ -1270,7 +1270,9 @@ extern tree find_inv_trees (tree *, int *, void *)
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, bool = true);
+extern bool valid_array_size_p (location_t, const_tree, tree, bool = true);
+extern void invalid_array_size_error (location_t, cst_size_error,
+ const_tree, const_tree);
/* In c-warn.c. */
extern void constant_expression_warning (tree);
Index: gcc/cp/decl.c
===================================================================
--- gcc/cp/decl.c (revision 268547)
+++ gcc/cp/decl.c (working copy)
@@ -9653,7 +9653,9 @@ compute_array_index_type_loc (location_t name_loc,
tsubst_flags_t complain)
{
tree itype;
- tree osize = size;
+ /* The original numeric size as seen in the source code after
+ any substitution and before conversion to size_t. */
+ tree origsize = NULL_TREE;
if (error_operand_p (size))
return error_mark_node;
@@ -9662,7 +9664,10 @@ compute_array_index_type_loc (location_t name_loc,
if (!type_dependent_expression_p (size))
{
- osize = size = mark_rvalue_use (size);
+ /* Save the original size value in ORIGSIZE to determine if
+ an excessive size after conversion to size_t is due the value
+ being negative. If so, use the size to improve diagnostics. */
+ origsize = size = mark_rvalue_use (size);
if (cxx_dialect < cxx11 && TREE_CODE (size) == NOP_EXPR
&& TREE_SIDE_EFFECTS (size))
@@ -9679,7 +9684,7 @@ compute_array_index_type_loc (location_t name_loc,
/*manifestly_const_eval=*/true);
if (!TREE_CONSTANT (size))
- size = osize;
+ size = origsize;
}
if (error_operand_p (size))
@@ -9740,16 +9745,38 @@ compute_array_index_type_loc (location_t name_loc,
/* Normally, the array-bound will be a constant. */
if (TREE_CODE (size) == INTEGER_CST)
{
- /* An array must have a positive number of elements. */
- if (!valid_constant_size_p (size))
+ /* The size to use in diagnostics that reflects the constant
+ size used in the source, rather than size massaged above. */
+ tree diagsize = NULL_TREE;
+
+ /* Try to convert the original SIZE to a ssizetype. */
+ if (origsize
+ && origsize != error_mark_node
+ && !TYPE_UNSIGNED (TREE_TYPE (origsize)))
{
+ if (TREE_CODE (size) == INTEGER_CST
+ && tree_int_cst_sign_bit (size))
+ diagsize = fold_convert (ssizetype, size);
+ else if (size == error_mark_node
+ && TREE_CODE (origsize) == INTEGER_CST
+ && tree_int_cst_sign_bit (origsize))
+ diagsize = fold_convert (ssizetype, origsize);
+
+ /* Clear the overflow bit that may have been set as a result
+ of the conversion from the sizetype of the new size to
+ ssizetype. */
+ if (diagsize)
+ TREE_OVERFLOW (diagsize) = false;
+ }
+ if (!diagsize)
+ diagsize = size;
+
+ /* Verify that the array has a positive number of elements
+ and issue the appropriate diagnostic if it doesn't. */
+ if (!valid_array_size_p (loc, diagsize, name, (complain & tf_error)))
+ {
if (!(complain & tf_error))
return error_mark_node;
-
- if (name)
- error_at (loc, "size of array %qD is negative", name);
- else
- error_at (loc, "size of array is negative");
size = integer_one_node;
}
/* As an extension we allow zero-sized arrays. */
Index: gcc/cp/init.c
===================================================================
--- gcc/cp/init.c (revision 268547)
+++ gcc/cp/init.c (working copy)
@@ -3086,7 +3086,21 @@ build_new_1 (vec<tree, va_gc> **placement, tree ty
if (overflow || wi::gtu_p (inner_size, max_size))
{
if (complain & tf_error)
- error ("size of array is too large");
+ {
+ cst_size_error error;
+ if (overflow)
+ error = cst_size_overflow;
+ else
+ {
+ error = cst_size_too_big;
+ size = size_binop (MULT_EXPR, size,
+ wide_int_to_tree (sizetype,
+ inner_nelts_count));
+ size = cp_fully_fold (size);
+ }
+ invalid_array_size_error (input_location, error, size,
+ /*name=*/NULL_TREE);
+ }
return error_mark_node;
}
@@ -3105,7 +3119,11 @@ build_new_1 (vec<tree, va_gc> **placement, tree ty
isn't explicitly stated but it's enforced anyway -- see
grokdeclarator in cp/decl.c). */
if (complain & tf_error)
- error ("size of array is too large");
+ {
+ size = cp_fully_fold (size);
+ invalid_array_size_error (input_location, cst_size_too_big,
+ size, NULL_TREE);
+ }
return error_mark_node;
}
}
@@ -3747,12 +3765,9 @@ build_new (vec<tree, va_gc> **placement, tree type
less than zero. ... If the expression is a constant expression,
the program is ill-fomed. */
if (TREE_CODE (cst_nelts) == INTEGER_CST
- && tree_int_cst_sgn (cst_nelts) == -1)
- {
- if (complain & tf_error)
- error ("size of array is negative");
- return error_mark_node;
- }
+ && !valid_array_size_p (input_location, cst_nelts, NULL_TREE,
+ complain & tf_error))
+ return error_mark_node;
nelts = mark_rvalue_use (nelts);
nelts = cp_save_expr (cp_convert (sizetype, nelts, complain));
Index: gcc/testsuite/c-c++-common/array-5.c
===================================================================
--- gcc/testsuite/c-c++-common/array-5.c (nonexistent)
+++ gcc/testsuite/c-c++-common/array-5.c (working copy)
@@ -0,0 +1,60 @@
+/* PR c++/87996 - "size of array is negative" error when SIZE_MAX/2 < sizeof(array) <= SIZE_MAX
+ { dg-do compile }
+ { dg-options "-ftrack-macro-expansion=0" } */
+
+#define INT16_MAX __INT16_MAX__
+#define UINT16_MAX ((INT16_MAX << 1) + 1)
+
+#define DIFF_MAX __PTRDIFF_MAX__
+#define SIZE_MAX __SIZE_MAX__
+
+typedef __INT16_TYPE__ int16_t;
+typedef __INT32_TYPE__ int32_t;
+typedef __SIZE_TYPE__ size_t;
+
+/* Verify errors for types. */
+
+typedef char i8a1_d_m1_t[DIFF_MAX - 1];
+/* The following should also be diagnosed because the difference between
+ &i8a1_dx[0] and &i8a1_dx[sizeof i8a1_dx] cannot be represented.
+typedef char i8a1_d_t[DIFF_MAX];
+*/
+
+typedef char i8a1_d_p1_t[(size_t)DIFF_MAX + 1]; /* { dg-error "size .\[0-9\]+. of array .i8a1_d_p1_t. exceeds maximum object size .\[0-9\]+.|is too large" } */
+
+typedef char i8a1_s_t[SIZE_MAX]; /* { dg-error "size .\[0-9\]+. of array .i8a1_s_t. exceeds maximum object size .\[0-9\]+.|is too large" } */
+
+typedef int16_t i16a_s_d2_t[SIZE_MAX / 2]; /* { dg-error "size .\[0-9\]+. of array .i16a_s_d2_t. exceeds maximum object size .\[0-9\]+." } */
+typedef int16_t i16a_s_d3_t[SIZE_MAX / 3]; /* { dg-error "size .\[0-9\]+. of array .i16a_s_d3_t. exceeds maximum object size .\[0-9\]+." } */
+typedef int16_t i16a_s_d4_m1_t[SIZE_MAX / 4 - 1];
+typedef int16_t i16a_s_d4_p1_t[SIZE_MAX / 4 + 1]; /* { dg-error "size .\[0-9\]+. of array .i16a_s_d4_p1_t. exceeds maximum object size .\[0-9\]+." } */
+
+/* The internal computation overflows the message doesn't show the object
+ size (but GCC should compute the result and print it anyway). */
+typedef int32_t i32a_s_d2_t[SIZE_MAX / 2]; /* { dg-error "size of array .i32a_s_d2_t. exceeds maximum object size .\[0-9\]+." } */
+typedef int32_t i32a_s_d3_t[SIZE_MAX / 3]; /* { dg-error "size of array .i32a_s_d3_t. exceeds maximum object size .\[0-9\]+." } */
+typedef int32_t i32a_s_d4_t[SIZE_MAX / 4]; /* { dg-error "size .\[0-9\]+. of array .i32a_s_d4_t. exceeds maximum object size .\[0-9\]+." } */
+
+
+/* Verify errors for objects. */
+
+char i8a1_d_m1[DIFF_MAX - 1];
+/* The following should also be diagnosed because the difference between
+ &i8a1_dx[0] and &i8a1_dx[sizeof i8a1_dx] cannot be represented.
+char i8a1_d[DIFF_MAX];
+*/
+
+char i8a_d_p1[(size_t)DIFF_MAX + 1]; /* { dg-error "size .\[0-9\]+. of array .i8a_d_p1. exceeds maximum object size .\[0-9\]+.|is too large" } */
+
+char i8a_s[SIZE_MAX]; /* { dg-error "size .\[0-9\]+. of array .i8a_s. exceeds maximum object size .\[0-9\]+.|is too large" } */
+
+int16_t i16a_s_d2[SIZE_MAX / 2]; /* { dg-error "size .\[0-9\]+. of array .i16a_s_d2. exceeds maximum object size .\[0-9\]+." } */
+int16_t i16a_s_d3[SIZE_MAX / 3]; /* { dg-error "size .\[0-9\]+. of array .i16a_s_d3. exceeds maximum object size .\[0-9\]+." } */
+int16_t i16a_sz_d4_m1[SIZE_MAX / 4 - 1];
+int16_t i16a_sz_d4_p1[SIZE_MAX / 4 + 1]; /* { dg-error "size .\[0-9\]+. of array .i16a_sz_d4_p1. exceeds maximum object size .\[0-9\]+." } */
+
+/* The internal computation overflows the message doesn't show the object
+ size (but GCC should compute the result and print it anyway). */
+int32_t i32a_s_d2[SIZE_MAX / 2]; /* { dg-error "size of array .i32a_s_d2. exceeds maximum object size .\[0-9\]+." } */
+int32_t i32a_s_d3[SIZE_MAX / 3]; /* { dg-error "size of array .i32a_s_d3. exceeds maximum object size .\[0-9\]+." } */
+int32_t i32a_s_d4[SIZE_MAX / 4]; /* { dg-error "size .\[0-9\]+. of array .i32a_s_d4. exceeds maximum object size .\[0-9\]+." } */
Index: gcc/testsuite/c-c++-common/pr68107.c
===================================================================
--- gcc/testsuite/c-c++-common/pr68107.c (revision 268547)
+++ gcc/testsuite/c-c++-common/pr68107.c (working copy)
@@ -3,35 +3,35 @@
#define N ((__SIZE_MAX__ / sizeof (int)) / 2 + 1)
-typedef int (*T1)[N]; /* { dg-error "too large" } */
+typedef int (*T1)[N]; /* { dg-error "exceeds maximum object size" } */
typedef int (*T2)[N - 1];
-typedef int (*T3)[N][N]; /* { dg-error "too large" } */
-typedef int (*T4)[N - 1][N - 1]; /* { dg-error "too large" } */
-typedef int (**T5)[N]; /* { dg-error "too large" } */
+typedef int (*T3)[N][N]; /* { dg-error "exceeds maximum object size" } */
+typedef int (*T4)[N - 1][N - 1]; /* { dg-error "exceeds maximum object size" } */
+typedef int (**T5)[N]; /* { dg-error "exceeds maximum object size" } */
struct S {
- int (*q1)[N]; /* { dg-error "too large" } */
+ int (*q1)[N]; /* { dg-error "exceeds maximum object size" } */
int (*q2)[N - 1];
- int (*q3)[N][N]; /* { dg-error "too large" } */
- int (*q4)[N - 1][N - 1]; /* { dg-error "too large" } */
- int (**q5)[N]; /* { dg-error "too large" } */
+ int (*q3)[N][N]; /* { dg-error "exceeds maximum object size" } */
+ int (*q4)[N - 1][N - 1]; /* { dg-error "exceeds maximum object size" } */
+ int (**q5)[N]; /* { dg-error "exceeds maximum object size" } */
};
-void fn1 (int (*p1)[N]); /* { dg-error "too large" } */
+void fn1 (int (*p1)[N]); /* { dg-error "exceeds maximum object size" } */
void fn2 (int (*p1)[N - 1]);
-void fn3 (int (*p3)[N][N]); /* { dg-error "too large" } */
-void fn4 (int (*p4)[N - 1][N - 1]); /* { dg-error "too large" } */
-void fn5 (int (**p5)[N]); /* { dg-error "too large" } */
+void fn3 (int (*p3)[N][N]); /* { dg-error "exceeds maximum object size" } */
+void fn4 (int (*p4)[N - 1][N - 1]); /* { dg-error "exceeds maximum object size" } */
+void fn5 (int (**p5)[N]); /* { dg-error "exceeds maximum object size" } */
void
fn (void)
{
- int (*n1)[N]; /* { dg-error "too large" } */
+ int (*n1)[N]; /* { dg-error "exceeds maximum object size" } */
int (*n2)[N - 1];
- int (*n3)[N][N]; /* { dg-error "too large" } */
- int (*n4)[N - 1][N - 1]; /* { dg-error "too large" } */
- int (**n5)[N]; /* { dg-error "too large" } */
+ int (*n3)[N][N]; /* { dg-error "exceeds maximum object size" } */
+ int (*n4)[N - 1][N - 1]; /* { dg-error "exceeds maximum object size" } */
+ int (**n5)[N]; /* { dg-error "exceeds maximum object size" } */
- sizeof (int (*)[N]); /* { dg-error "too large" } */
- sizeof (int [N]); /* { dg-error "too large" } */
+ sizeof (int (*)[N]); /* { dg-error "exceeds maximum object size" } */
+ sizeof (int [N]); /* { dg-error "exceeds maximum object size" } */
}
Index: gcc/testsuite/g++.dg/init/new38.C
===================================================================
--- gcc/testsuite/g++.dg/init/new38.C (revision 268547)
+++ gcc/testsuite/g++.dg/init/new38.C (working copy)
@@ -5,7 +5,7 @@ large_array_char(int n)
{
new char[n]
[1ULL << (sizeof(void *) * 4)]
- [1ULL << (sizeof(void *) * 4)]; // { dg-error "size of unnamed array" }
+ [1ULL << (sizeof(void *) * 4)]; // { dg-error "size of array" }
}
template <typename T>
@@ -14,7 +14,7 @@ large_array_char_template(int n)
{
new char[n]
[1ULL << (sizeof(void *) * 4)]
- [1ULL << (sizeof(void *) * 4)]; // { dg-error "size of unnamed array" }
+ [1ULL << (sizeof(void *) * 4)]; // { dg-error "size of array" }
}
@@ -22,7 +22,7 @@ template <typename T>
void
large_array_template1(int n)
{
- new T[n] // { dg-error "size of unnamed array is too large" }
+ new T[n] // { dg-error "size of array exceeds maximum object size" }
[(1ULL << (sizeof(void *) * 4)) / sizeof(T)]
[1ULL << (sizeof(void *) * 4)];
}
@@ -31,7 +31,7 @@ template <typename T>
void
large_array_template2(int n)
{
- new T[n] // { dg-error "size of unnamed array is too large" }
+ new T[n] // { dg-error "size of array exceeds maximum object size" }
[(1ULL << (sizeof(void *) * 4)) / sizeof(T)]
[1ULL << (sizeof(void *) * 4)];
}
@@ -40,7 +40,7 @@ template <typename T>
void
large_array_template3(int n)
{
- new T[n] // { dg-error "size of unnamed array is too large" }
+ new T[n] // { dg-error "size of array exceeds maximum object size" }
[(1ULL << (sizeof(void *) * 4)) / sizeof(T)]
[1ULL << (sizeof(void *) * 4)];
}
Index: gcc/testsuite/g++.dg/init/new43.C
===================================================================
--- gcc/testsuite/g++.dg/init/new43.C (revision 268547)
+++ gcc/testsuite/g++.dg/init/new43.C (working copy)
@@ -30,36 +30,36 @@ void test_literal ()
B b;
// Verify integer literal.
- p = new char [-1]; // { dg-error "size of array is negative" }
- p = new char [2][-3]; // { dg-error "size of array|narrowing conversion" }
- p = new char [-4][5]; // { dg-error "size of array is negative" }
- p = new char [-6][-7]; // { dg-error "size of array|narrowing conversion" }
+ p = new char [-1]; // { dg-error "size .-1. of array is negative" }
+ p = new char [2][-3]; // { dg-error "size .-3. of array|narrowing conversion" }
+ p = new char [-4][5]; // { dg-error "size .-4. of array is negative" }
+ p = new char [-6][-7]; // { dg-error "size .-\[67\]. of array|narrowing conversion" }
- p = new (p) char [-1]; // { dg-error "size of array is negative" }
- p = new (p) char [2][-3]; // { dg-error "size of array|narrowing conversion" }
- p = new (p) char [-4][5]; // { dg-error "size of array is negative" }
- p = new (p) char [-6][-7]; // { dg-error "size of array|narrowing conversion" }
+ p = new (p) char [-1]; // { dg-error "size .-1. of array is negative" }
+ p = new (p) char [2][-3]; // { dg-error "size .-3. of array|narrowing conversion" }
+ p = new (p) char [-4][5]; // { dg-error "size .-4. of array is negative" }
+ p = new (p) char [-6][-7]; // { dg-error "size .-\[67\]. of array|narrowing conversion" }
- p = new (p) A [-1]; // { dg-error "size of array is negative" }
- p = new (p) A [2][-3]; // { dg-error "size of array|narrowing conversion" }
- p = new (p) A [-4][5]; // { dg-error "size of array is negative" }
- p = new (p) A [-6][-7]; // { dg-error "size of array|narrowing conversion" }
+ p = new (p) A [-1]; // { dg-error "size .-1. of array is negative" }
+ p = new (p) A [2][-3]; // { dg-error "size .-3. of array|narrowing conversion" }
+ p = new (p) A [-4][5]; // { dg-error "size .-4. of array is negative" }
+ p = new (p) A [-6][-7]; // { dg-error "size .-\[67\]. of array|narrowing conversion" }
- p = new (p) B [-1]; // { dg-error "size of array is negative" }
- p = new (p) B [2][-3]; // { dg-error "size of array|narrowing conversion" }
- p = new (p) B [-4][5]; // { dg-error "size of array is negative" }
- p = new (p) B [-6][-7]; // { dg-error "size of array|narrowing conversion" }
+ p = new (p) B [-1]; // { dg-error "size .-1. of array is negative" }
+ p = new (p) B [2][-3]; // { dg-error "size .-3. of array|narrowing conversion" }
+ p = new (p) B [-4][5]; // { dg-error "size .-4. of array is negative" }
+ p = new (p) B [-6][-7]; // { dg-error "size .-\[67\]. of array|narrowing conversion" }
- p = new (&b) B [-1]; // { dg-error "size of array is negative" }
- p = new (&b) B [2][-3]; // { dg-error "size of array|narrowing conversion" }
- p = new (&b) B [-4][5]; // { dg-error "size of array is negative" }
- p = new (&b) B [-6][-7]; // { dg-error "size of array|narrowing conversion" }
+ p = new (&b) B [-1]; // { dg-error "size .-1. of array is negative" }
+ p = new (&b) B [2][-3]; // { dg-error "size .-3. of array|narrowing conversion" }
+ p = new (&b) B [-4][5]; // { dg-error "size .-4. of array is negative" }
+ p = new (&b) B [-6][-7]; // { dg-error "size .-\[67\]. of array|narrowing conversion" }
- p = new char [1 - 2]; // { dg-error "size of array is negative" }
- p = new (p) char [2 - 3]; // { dg-error "size of array is negative" }
- p = new A [2 < 1 ? -1 : -2]; // { dg-error "size of array is negative" }
- p = new (p) B [2 - 3 * 2]; // { dg-error "size of array is negative" }
- p = new (&b) B [1][2 - 3 * 2];// { dg-error "size of array|narrowing conversion" }
+ p = new char [1 - 2]; // { dg-error "size .-1. of array is negative" }
+ p = new (p) char [2 - 3]; // { dg-error "size .-1. of array is negative" }
+ p = new A [2 < 1 ? -1 : -2]; // { dg-error "size .-2. of array is negative" }
+ p = new (p) B [2 - 3 * 2]; // { dg-error "size .-4. of array is negative" }
+ p = new (&b) B [1][2 - 3 * 2];// { dg-error "size .-4. of array|narrowing conversion" }
}
void test_constant_expression ()
@@ -78,36 +78,36 @@ void test_constant_expression ()
static const int i7 = -7;
// Verify constant expression.
- p = new char [i1]; // { dg-error "size of array is negative" }
- p = new char [2][i3]; // { dg-error "size of array|narrowing conversion" }
- p = new char [i4][5]; // { dg-error "size of array is negative" }
- p = new char [i6][i7]; // { dg-error "size of array|narrowing conversion" }
+ p = new char [i1]; // { dg-error "size .-1. of array is negative" }
+ p = new char [2][i3]; // { dg-error "size .-3. of array|narrowing conversion" }
+ p = new char [i4][5]; // { dg-error "size .-4. of array is negative" }
+ p = new char [i6][i7]; // { dg-error "size .-\[67\]. of array|narrowing conversion" }
- p = new (p) char [i1]; // { dg-error "size of array is negative" }
- p = new (p) char [2][i3]; // { dg-error "size of array|narrowing conversion" }
- p = new (p) char [i4][5]; // { dg-error "size of array is negative" }
- p = new (p) char [i6][i7]; // { dg-error "size of array|narrowing conversion" }
+ p = new (p) char [i1]; // { dg-error "size .-1. of array is negative" }
+ p = new (p) char [2][i3]; // { dg-error "size .-3. of array|narrowing conversion" }
+ p = new (p) char [i4][5]; // { dg-error "size .-4. of array is negative" }
+ p = new (p) char [i6][i7]; // { dg-error "size .-\[67\]. of array|narrowing conversion" }
- p = new (p) A [i1]; // { dg-error "size of array is negative" }
- p = new (p) A [2][i3]; // { dg-error "size of array|narrowing conversion" }
- p = new (p) A [i4][5]; // { dg-error "size of array is negative" }
- p = new (p) A [i6][i7]; // { dg-error "size of array|narrowing conversion" }
+ p = new (p) A [i1]; // { dg-error "size .-1. of array is negative" }
+ p = new (p) A [2][i3]; // { dg-error "size .-3. of array|narrowing conversion" }
+ p = new (p) A [i4][5]; // { dg-error "size .-4. of array is negative" }
+ p = new (p) A [i6][i7]; // { dg-error "size .-\[67\]. of array|narrowing conversion" }
- p = new (p) B [i1]; // { dg-error "size of array is negative" }
- p = new (p) B [2][i3]; // { dg-error "size of array|narrowing conversion" }
- p = new (p) B [i4][5]; // { dg-error "size of array is negative" }
- p = new (p) B [i6][i7]; // { dg-error "size of array|narrowing conversion" }
+ p = new (p) B [i1]; // { dg-error "size .-1. of array is negative" }
+ p = new (p) B [2][i3]; // { dg-error "size .-3. of array|narrowing conversion" }
+ p = new (p) B [i4][5]; // { dg-error "size .-4. of array is negative" }
+ p = new (p) B [i6][i7]; // { dg-error "size .-\[67\]. of array|narrowing conversion" }
- p = new (&b) B [i1]; // { dg-error "size of array is negative" }
- p = new (&b) B [2][i3]; // { dg-error "size of array|narrowing conversion" }
- p = new (&b) B [i4][5]; // { dg-error "size of array is negative" }
- p = new (&b) B [i6][i7]; // { dg-error "size of array|narrowing conversion" }
+ p = new (&b) B [i1]; // { dg-error "size .-1. of array is negative" }
+ p = new (&b) B [2][i3]; // { dg-error "size .-3. of array|narrowing conversion" }
+ p = new (&b) B [i4][5]; // { dg-error "size .-4. of array is negative" }
+ p = new (&b) B [i6][i7]; // { dg-error "size .-\[67\]. of array|narrowing conversion" }
- p = new short [i1 - 2]; // { dg-error "size of array is negative" }
- p = new (p) bool [i2 - 3]; // { dg-error "size of array is negative" }
- p = new A [2 < 1 ? i1 : i2]; // { dg-error "size of array is negative" }
- p = new (p) B [2 + i3 * 2]; // { dg-error "size of array is negative" }
- p = new (&b) B [1][i1 - 3 * 2];// { dg-error "size of array|narrowing conversion" }
+ p = new short [i1 - 2]; // { dg-error "size .-3. of array is negative" }
+ p = new (p) bool [i2 - 3]; // { dg-error "size .-5. of array is negative" }
+ p = new A [2 < 1 ? i1 : i2]; // { dg-error "size .-2. of array is negative" }
+ p = new (p) B [2 + i3 * 2]; // { dg-error "size .-4. of array is negative" }
+ p = new (&b) B [1][i1 - 3 * 2];// { dg-error "size .-7. of array|narrowing conversion" }
}
void test_constexpr ()
@@ -131,34 +131,37 @@ void test_constexpr ()
#endif
// Verify constant expression.
- p = new char [s1]; // { dg-error "size of array is negative" }
- p = new char [2][s3]; // { dg-error "size of array|narrowing conversion" }
- p = new char [s4][5]; // { dg-error "size of array is negative" }
- p = new char [s6][s7]; // { dg-error "size of array|narrowing conversion" }
+ p = new char [s1]; // { dg-error "size .-1. of array is negative" }
+ p = new char [2][s3]; // { dg-error "size .-3. of array|narrowing conversion" }
+ p = new char [s4][5]; // { dg-error "size .-4. of array is negative" }
+ p = new char [s6][s7]; // { dg-error "size .-\[67\]. of array|narrowing conversion" }
- p = new (p) char [s1]; // { dg-error "size of array is negative" }
- p = new (p) char [2][s3]; // { dg-error "size of array|narrowing conversion" }
- p = new (p) char [s4][5]; // { dg-error "size of array is negative" }
- p = new (p) char [s6][s7]; // { dg-error "size of array|narrowing conversion" }
+ p = new (p) char [s1]; // { dg-error "size .-1. of array is negative" }
+ p = new (p) char [2][s3]; // { dg-error "size .-3. of array|narrowing conversion" }
+ p = new (p) char [s4][5]; // { dg-error "size .-4. of array is negative" }
+ p = new (p) char [s6][s7]; // { dg-error "size .-\[67\]. of array|narrowing conversion" }
- p = new (p) A [s1]; // { dg-error "size of array is negative" }
- p = new (p) A [2][s3]; // { dg-error "size of array|narrowing conversion" }
- p = new (p) A [s4][5]; // { dg-error "size of array is negative" }
- p = new (p) A [s6][s7]; // { dg-error "size of array|narrowing conversion" }
+ p = new (p) A [s1]; // { dg-error "size .-1. of array is negative" }
+ p = new (p) A [2][s3]; // { dg-error "size .-3. of array|narrowing conversion" }
+ p = new (p) A [s4][5]; // { dg-error "size .-4. of array is negative" }
+ p = new (p) A [s6][s7]; // { dg-error "size .-\[67\]. of array|narrowing conversion" }
- p = new (p) B [s1]; // { dg-error "size of array is negative" }
- p = new (p) B [2][s3]; // { dg-error "size of array|narrowing conversion" }
- p = new (p) B [s4][5]; // { dg-error "size of array is negative" }
- p = new (p) B [s6][s7]; // { dg-error "size of array|narrowing conversion" }
+ p = new (p) B [s1]; // { dg-error "size .-1. of array is negative" }
+ p = new (p) B [2][s3]; // { dg-error "size .-3. of array|narrowing conversion" }
+ p = new (p) B [s4][5]; // { dg-error "size .-4. of array is negative" }
+ p = new (p) B [s6][s7]; // { dg-error "size .-\[67\]. of array|narrowing conversion" }
- p = new (&b) B [s1]; // { dg-error "size of array is negative" }
- p = new (&b) B [2][s3]; // { dg-error "size of array|narrowing conversion" }
- p = new (&b) B [s4][5]; // { dg-error "size of array is negative" }
- p = new (&b) B [s6][s7]; // { dg-error "size of array|narrowing conversion" }
+ p = new (&b) B [s1]; // { dg-error "size .-1. of array is negative" }
+ p = new (&b) B [2][s3]; // { dg-error "size .-3. of array|narrowing conversion" }
+ p = new (&b) B [s4][5]; // { dg-error "size .-4. of array is negative" }
+ p = new (&b) B [s6][s7]; // { dg-error "size .-\[67\]. of array|narrowing conversion" }
- p = new int [s1 + s2]; // { dg-error "size of array is negative" }
- p = new (p) long [2 * s3]; // { dg-error "size of array is negative" }
- p = new A [s2 < s1 ? s1 : s2]; // { dg-error "size of array is negative" }
- p = new (p) B [s7 - s2 * 2]; // { dg-error "size of array is negative" }
- p = new (&b) B [9][s4 - s1 * 2]; // { dg-error "size of array|narrowing conversion" }
+ p = new int [s1 + s2]; // { dg-error "size .-3. of array is negative" }
+ p = new (p) long [2 * s3]; // { dg-error "size .-6. of array is negative" }
+ p = new A [s2 < s1 ? s1 : s2]; // { dg-error "size .-1. of array is negative" }
+ p = new (p) B [s7 - s2 * 2]; // { dg-error "size .-3. of array is negative" }
+ p = new (&b) B [9][s4 - s1 * 2]; // { dg-error "size .-2. of array|narrowing conversion" }
}
+
+/* Prune out pedantic warnins (turned into errors via -pedantic-errors).
+ { dg-prune-output "size of array is not an integral constant-expressio" } */
Index: gcc/testsuite/g++.dg/init/new44.C
===================================================================
--- gcc/testsuite/g++.dg/init/new44.C (revision 268547)
+++ gcc/testsuite/g++.dg/init/new44.C (working copy)
@@ -37,13 +37,13 @@ void *p;
static void __attribute__ ((used))
test_one_dim_char_array ()
{
- p = new char [MAX]; // { dg-error "size of array" }
- p = new char [MAX - 1]; // { dg-error "size of array" }
- p = new char [MAX - 2]; // { dg-error "size of array" }
- p = new char [MAX - 99]; // { dg-error "size of array" }
- p = new char [MAX / 2]; // { dg-error "size of array" }
- p = new char [MAX / 2 - 1]; // { dg-error "size of array" }
- p = new char [MAX / 2 - 2]; // { dg-error "size of array" }
+ p = new char [MAX]; // { dg-error "size .\[0-9\]+. of array" }
+ p = new char [MAX - 1]; // { dg-error "size .\[0-9\]+. of array" }
+ p = new char [MAX - 2]; // { dg-error "size .\[0-9\]+. of array" }
+ p = new char [MAX - 99]; // { dg-error "size .\[0-9\]+. of array" }
+ p = new char [MAX / 2]; // { dg-error "size .\[0-9\]+. of array" }
+ p = new char [MAX / 2 - 1]; // { dg-error "size .\[0-9\]+. of array" }
+ p = new char [MAX / 2 - 2]; // { dg-error "size .\[0-9\]+. of array" }
// Avoid testing the expressions below since whether or not they
// are accepted depends on the precision of size_t (which also
@@ -63,20 +63,20 @@ test_one_dim_char_array ()
static void __attribute__ ((used))
test_one_dim_short_array ()
{
- p = new short [MAX]; // { dg-error "size of array" }
- p = new short [MAX - 1]; // { dg-error "size of array" }
- p = new short [MAX - 2]; // { dg-error "size of array" }
- p = new short [MAX - 99]; // { dg-error "size of array" }
- p = new short [MAX / 2]; // { dg-error "size of array" }
- p = new short [MAX / 2 - 1]; // { dg-error "size of array" }
- p = new short [MAX / 2 - 2]; // { dg-error "size of array" }
- p = new short [MAX / 2 - 3]; // { dg-error "size of array" }
- p = new short [MAX / 2 - 4]; // { dg-error "size of array" }
- p = new short [MAX / 2 - 5]; // { dg-error "size of array" }
- p = new short [MAX / 2 - 6]; // { dg-error "size of array" }
- p = new short [MAX / 2 - 7]; // { dg-error "size of array" }
- p = new short [MAX / 2 - 8]; // { dg-error "size of array" }
- p = new short [MAX / 4]; // { dg-error "size of array" }
+ p = new short [MAX]; // { dg-error "size .\[0-9\]+. of array" }
+ p = new short [MAX - 1]; // { dg-error "size .\[0-9\]+. of array" }
+ p = new short [MAX - 2]; // { dg-error "size .\[0-9\]+. of array" }
+ p = new short [MAX - 99]; // { dg-error "size .\[0-9\]+. of array" }
+ p = new short [MAX / 2]; // { dg-error "size .\[0-9\]+. of array" }
+ p = new short [MAX / 2 - 1]; // { dg-error "size .\[0-9\]+. of array" }
+ p = new short [MAX / 2 - 2]; // { dg-error "size .\[0-9\]+. of array" }
+ p = new short [MAX / 2 - 3]; // { dg-error "size .\[0-9\]+. of array" }
+ p = new short [MAX / 2 - 4]; // { dg-error "size .\[0-9\]+. of array" }
+ p = new short [MAX / 2 - 5]; // { dg-error "size .\[0-9\]+. of array" }
+ p = new short [MAX / 2 - 6]; // { dg-error "size .\[0-9\]+. of array" }
+ p = new short [MAX / 2 - 7]; // { dg-error "size .\[0-9\]+. of array" }
+ p = new short [MAX / 2 - 8]; // { dg-error "size .\[0-9\]+. of array" }
+ p = new short [MAX / 4]; // { dg-error "size .\[0-9\]+. of array" }
// Avoid exercising data model-dependent expressions.
// p = new short [MAX / 4 - 1];
@@ -88,13 +88,13 @@ test_one_dim_short_array ()
static void __attribute__ ((used))
test_two_dim_char_array ()
{
- p = new char [1][MAX]; // { dg-error "size of (unnamed )?array" }
- p = new char [1][MAX - 1]; // { dg-error "size of (unnamed )?array" }
- p = new char [1][MAX - 2]; // { dg-error "size of (unnamed )?array" }
- p = new char [1][MAX - 99]; // { dg-error "size of (unnamed )?array" }
- p = new char [1][MAX / 2]; // { dg-error "size of array" }
- p = new char [1][MAX / 2 - 1]; // { dg-error "size of array" }
- p = new char [1][MAX / 2 - 2]; // { dg-error "size of array" }
+ p = new char [1][MAX]; // { dg-error "size .\[0-9\]+. of (unnamed )?array" }
+ p = new char [1][MAX - 1]; // { dg-error "size .\[0-9\]+. of (unnamed )?array" }
+ p = new char [1][MAX - 2]; // { dg-error "size .\[0-9\]+. of (unnamed )?array" }
+ p = new char [1][MAX - 99]; // { dg-error "size .\[0-9\]+. of (unnamed )?array" }
+ p = new char [1][MAX / 2]; // { dg-error "size .\[0-9\]+. of array" }
+ p = new char [1][MAX / 2 - 1]; // { dg-error "size .\[0-9\]+. of array" }
+ p = new char [1][MAX / 2 - 2]; // { dg-error "size .\[0-9\]+. of array" }
// Avoid exercising data model-dependent expressions.
// p = new char [1][MAX / 2 - 3];
@@ -105,28 +105,28 @@ test_two_dim_char_array ()
p = new char [1][MAX / 2 - 7]; // okay
p = new char [1][MAX / 2 - 8]; // okay
- p = new char [2][MAX]; // { dg-error "size of (unnamed )?array" }
- p = new char [2][MAX - 1]; // { dg-error "size of (unnamed )?array" }
- p = new char [2][MAX - 2]; // { dg-error "size of (unnamed )?array" }
- p = new char [2][MAX / 2]; // { dg-error "size of array" }
- p = new char [2][MAX / 2 - 1]; // { dg-error "size of array" }
- p = new char [2][MAX / 2 - 2]; // { dg-error "size of array" }
- p = new char [2][MAX / 2 - 7]; // { dg-error "size of array" }
- p = new char [2][MAX / 2 - 8]; // { dg-error "size of array" }
+ p = new char [2][MAX]; // { dg-error "size .\[0-9\]+. of (unnamed )?array" }
+ p = new char [2][MAX - 1]; // { dg-error "size .\[0-9\]+. of (unnamed )?array" }
+ p = new char [2][MAX - 2]; // { dg-error "size .\[0-9\]+. of (unnamed )?array" }
+ p = new char [2][MAX / 2]; // { dg-error "size .\[0-9\]+. of array" }
+ p = new char [2][MAX / 2 - 1]; // { dg-error "size .\[0-9\]+. of array" }
+ p = new char [2][MAX / 2 - 2]; // { dg-error "size .\[0-9\]+. of array" }
+ p = new char [2][MAX / 2 - 7]; // { dg-error "size .\[0-9\]+. of array" }
+ p = new char [2][MAX / 2 - 8]; // { dg-error "size .\[0-9\]+. of array" }
- p = new char [MAX][MAX]; // { dg-error "size of (unnamed )?array" }
- p = new char [MAX][MAX - 1]; // { dg-error "size of (unnamed )?array" }
- p = new char [MAX][MAX - 2]; // { dg-error "size of (unnamed )?array" }
- p = new char [MAX][MAX / 2]; // { dg-error "size of array" }
- p = new char [MAX][MAX / 2 - 1]; // { dg-error "size of array" }
- p = new char [MAX][MAX / 2 - 2]; // { dg-error "size of array" }
- p = new char [MAX][MAX / 2 - 7]; // { dg-error "size of array" }
- p = new char [MAX][MAX / 2 - 8]; // { dg-error "size of array" }
- p = new char [MAX][2]; // { dg-error "size of array" }
- p = new char [MAX][1]; // { dg-error "size of array" }
- p = new char [MAX / 2][1]; // { dg-error "size of array" }
- p = new char [MAX / 2 - 1][1]; // { dg-error "size of array" }
- p = new char [MAX / 2 - 2][1]; // { dg-error "size of array" }
+ p = new char [MAX][MAX]; // { dg-error "size .\[0-9\]+. of (unnamed )?array" }
+ p = new char [MAX][MAX - 1]; // { dg-error "size .\[0-9\]+. of (unnamed )?array" }
+ p = new char [MAX][MAX - 2]; // { dg-error "size .\[0-9\]+. of (unnamed )?array" }
+ p = new char [MAX][MAX / 2]; // { dg-error "size .\[0-9\]+. of array" }
+ p = new char [MAX][MAX / 2 - 1]; // { dg-error "size .\[0-9\]+. of array" }
+ p = new char [MAX][MAX / 2 - 2]; // { dg-error "size .\[0-9\]+. of array" }
+ p = new char [MAX][MAX / 2 - 7]; // { dg-error "size .\[0-9\]+. of array" }
+ p = new char [MAX][MAX / 2 - 8]; // { dg-error "size .\[0-9\]+. of array" }
+ p = new char [MAX][2]; // { dg-error "size .\[0-9\]+. of array" }
+ p = new char [MAX][1]; // { dg-error "size .\[0-9\]+. of array" }
+ p = new char [MAX / 2][1]; // { dg-error "size .\[0-9\]+. of array" }
+ p = new char [MAX / 2 - 1][1]; // { dg-error "size .\[0-9\]+. of array" }
+ p = new char [MAX / 2 - 2][1]; // { dg-error "size .\[0-9\]+. of array" }
// Avoid exercising data model-dependent expressions.
// p = new char [MAX / 2 - 3][1];
@@ -143,13 +143,13 @@ test_two_dim_char_array ()
static __attribute__ ((used)) void
test_three_dim_char_array ()
{
- p = new char [1][1][MAX]; // { dg-error "size of (unnamed )?array" }
- p = new char [1][1][MAX - 1]; // { dg-error "size of (unnamed )?array" }
- p = new char [1][1][MAX - 2]; // { dg-error "size of (unnamed )?array" }
- p = new char [1][1][MAX - 99]; // { dg-error "size of (unnamed )?array" }
- p = new char [1][1][MAX / 2]; // { dg-error "size of array" }
- p = new char [1][1][MAX / 2 - 1]; // { dg-error "size of array" }
- p = new char [1][1][MAX / 2 - 2]; // { dg-error "size of array" }
+ p = new char [1][1][MAX]; // { dg-error "size .\[0-9\]+. of (unnamed )?array" }
+ p = new char [1][1][MAX - 1]; // { dg-error "size .\[0-9\]+. of (unnamed )?array" }
+ p = new char [1][1][MAX - 2]; // { dg-error "size .\[0-9\]+. of (unnamed )?array" }
+ p = new char [1][1][MAX - 99]; // { dg-error "size .\[0-9\]+. of (unnamed )?array" }
+ p = new char [1][1][MAX / 2]; // { dg-error "size .\[0-9\]+. of array" }
+ p = new char [1][1][MAX / 2 - 1]; // { dg-error "size .\[0-9\]+. of array" }
+ p = new char [1][1][MAX / 2 - 2]; // { dg-error "size .\[0-9\]+. of array" }
// Avoid exercising data model-dependent expressions.
// p = new char [1][1][MAX / 2 - 3];
@@ -160,20 +160,20 @@ test_three_dim_char_array ()
p = new char [1][1][MAX / 2 - 7]; // okay
p = new char [1][1][MAX / 2 - 8]; // okay
- p = new char [1][2][MAX]; // { dg-error "size of (unnamed )?array" }
- p = new char [1][2][MAX - 1]; // { dg-error "size of (unnamed )?array" }
- p = new char [1][2][MAX - 2]; // { dg-error "size of (unnamed )?array" }
- p = new char [1][2][MAX - 99]; // { dg-error "size of (unnamed )?array" }
- p = new char [1][2][MAX / 2]; // { dg-error "size of (unnamed )?array" }
- p = new char [1][2][MAX / 2 - 1]; // { dg-error "size of (unnamed )?array" }
- p = new char [1][2][MAX / 2 - 2]; // { dg-error "size of (unnamed )?array" }
- p = new char [1][2][MAX / 2 - 3]; // { dg-error "size of (unnamed )?array" }
- p = new char [1][2][MAX / 2 - 4]; // { dg-error "size of (unnamed )?array" }
- p = new char [1][2][MAX / 2 - 5]; // { dg-error "size of (unnamed )?array" }
- p = new char [1][2][MAX / 2 - 6]; // { dg-error "size of (unnamed )?array" }
- p = new char [1][2][MAX / 2 - 7]; // { dg-error "size of (unnamed )?array" }
- p = new char [1][2][MAX / 2 - 8]; // { dg-error "size of (unnamed )?array" }
- p = new char [1][2][MAX / 4]; // { dg-error "size of array" }
+ p = new char [1][2][MAX]; // { dg-error "size .\[0-9\]+. of (unnamed )?array" }
+ p = new char [1][2][MAX - 1]; // { dg-error "size .\[0-9\]+. of (unnamed )?array" }
+ p = new char [1][2][MAX - 2]; // { dg-error "size .\[0-9\]+. of (unnamed )?array" }
+ p = new char [1][2][MAX - 99]; // { dg-error "size .\[0-9\]+. of (unnamed )?array" }
+ p = new char [1][2][MAX / 2]; // { dg-error "size .\[0-9\]+. of (unnamed )?array" }
+ p = new char [1][2][MAX / 2 - 1]; // { dg-error "size .\[0-9\]+. of (unnamed )?array" }
+ p = new char [1][2][MAX / 2 - 2]; // { dg-error "size .\[0-9\]+. of (unnamed )?array" }
+ p = new char [1][2][MAX / 2 - 3]; // { dg-error "size .\[0-9\]+. of (unnamed )?array" }
+ p = new char [1][2][MAX / 2 - 4]; // { dg-error "size .\[0-9\]+. of (unnamed )?array" }
+ p = new char [1][2][MAX / 2 - 5]; // { dg-error "size .\[0-9\]+. of (unnamed )?array" }
+ p = new char [1][2][MAX / 2 - 6]; // { dg-error "size .\[0-9\]+. of (unnamed )?array" }
+ p = new char [1][2][MAX / 2 - 7]; // { dg-error "size .\[0-9\]+. of (unnamed )?array" }
+ p = new char [1][2][MAX / 2 - 8]; // { dg-error "size .\[0-9\]+. of (unnamed )?array" }
+ p = new char [1][2][MAX / 4]; // { dg-error "size .\[0-9\]+. of array" }
// Avoid exercising data model-dependent expressions.
// p = new char [1][2][MAX / 4 - 1];
@@ -182,20 +182,20 @@ test_three_dim_char_array ()
p = new char [1][2][MAX / 4 - 3]; // okay
p = new char [1][2][MAX / 4 - 4]; // okay
- p = new char [2][1][MAX]; // { dg-error "size of (unnamed )?array" }
- p = new char [2][1][MAX - 1]; // { dg-error "size of (unnamed )?array" }
- p = new char [2][1][MAX - 2]; // { dg-error "size of (unnamed )?array" }
- p = new char [2][1][MAX - 99]; // { dg-error "size of (unnamed )?array" }
- p = new char [2][1][MAX / 2]; // { dg-error "size of array" }
- p = new char [2][1][MAX / 2 - 1]; // { dg-error "size of array" }
- p = new char [2][1][MAX / 2 - 2]; // { dg-error "size of array" }
- p = new char [2][1][MAX / 2 - 3]; // { dg-error "size of array" }
- p = new char [2][1][MAX / 2 - 4]; // { dg-error "size of array" }
- p = new char [2][1][MAX / 2 - 5]; // { dg-error "size of array" }
- p = new char [2][1][MAX / 2 - 6]; // { dg-error "size of array" }
- p = new char [2][1][MAX / 2 - 7]; // { dg-error "size of array" }
- p = new char [2][1][MAX / 2 - 8]; // { dg-error "size of array" }
- p = new char [2][1][MAX / 4]; // { dg-error "size of array" }
+ p = new char [2][1][MAX]; // { dg-error "size .\[0-9\]+. of (unnamed )?array" }
+ p = new char [2][1][MAX - 1]; // { dg-error "size .\[0-9\]+. of (unnamed )?array" }
+ p = new char [2][1][MAX - 2]; // { dg-error "size .\[0-9\]+. of (unnamed )?array" }
+ p = new char [2][1][MAX - 99]; // { dg-error "size .\[0-9\]+. of (unnamed )?array" }
+ p = new char [2][1][MAX / 2]; // { dg-error "size .\[0-9\]+. of array" }
+ p = new char [2][1][MAX / 2 - 1]; // { dg-error "size .\[0-9\]+. of array" }
+ p = new char [2][1][MAX / 2 - 2]; // { dg-error "size .\[0-9\]+. of array" }
+ p = new char [2][1][MAX / 2 - 3]; // { dg-error "size .\[0-9\]+. of array" }
+ p = new char [2][1][MAX / 2 - 4]; // { dg-error "size .\[0-9\]+. of array" }
+ p = new char [2][1][MAX / 2 - 5]; // { dg-error "size .\[0-9\]+. of array" }
+ p = new char [2][1][MAX / 2 - 6]; // { dg-error "size .\[0-9\]+. of array" }
+ p = new char [2][1][MAX / 2 - 7]; // { dg-error "size .\[0-9\]+. of array" }
+ p = new char [2][1][MAX / 2 - 8]; // { dg-error "size .\[0-9\]+. of array" }
+ p = new char [2][1][MAX / 4]; // { dg-error "size .\[0-9\]+. of array" }
// Avoid exercising data model-dependent expressions.
// p = new char [2][1][MAX / 4 - 1];
@@ -204,22 +204,22 @@ test_three_dim_char_array ()
p = new char [2][1][MAX / 4 - 3]; // okay
p = new char [2][1][MAX / 4 - 4]; // okay
- p = new char [2][2][MAX]; // { dg-error "size of (unnamed )?array" }
- p = new char [2][2][MAX - 1]; // { dg-error "size of (unnamed )?array" }
- p = new char [2][2][MAX - 2]; // { dg-error "size of (unnamed )?array" }
- p = new char [2][2][MAX - 99]; // { dg-error "size of (unnamed )?array" }
- p = new char [2][2][MAX / 2]; // { dg-error "size of (unnamed )?array" }
- p = new char [2][2][MAX / 2 - 1]; // { dg-error "size of (unnamed )?array" }
- p = new char [2][2][MAX / 2 - 2]; // { dg-error "size of (unnamed )?array" }
- p = new char [2][2][MAX / 2 - 3]; // { dg-error "size of (unnamed )?array" }
- p = new char [2][2][MAX / 2 - 4]; // { dg-error "size of (unnamed )?array" }
- p = new char [2][2][MAX / 2 - 5]; // { dg-error "size of (unnamed )?array" }
- p = new char [2][2][MAX / 2 - 6]; // { dg-error "size of (unnamed )?array" }
- p = new char [2][2][MAX / 2 - 7]; // { dg-error "size of (unnamed )?array" }
- p = new char [2][2][MAX / 2 - 8]; // { dg-error "size of (unnamed )?array" }
- p = new char [2][2][MAX / 4]; // { dg-error "size of array" }
- p = new char [2][2][MAX / 4 - 1]; // { dg-error "size of array" }
- p = new char [2][2][MAX / 4 - 2]; // { dg-error "size of array" }
+ p = new char [2][2][MAX]; // { dg-error "size .\[0-9\]+. of (unnamed )?array" }
+ p = new char [2][2][MAX - 1]; // { dg-error "size .\[0-9\]+. of (unnamed )?array" }
+ p = new char [2][2][MAX - 2]; // { dg-error "size .\[0-9\]+. of (unnamed )?array" }
+ p = new char [2][2][MAX - 99]; // { dg-error "size .\[0-9\]+. of (unnamed )?array" }
+ p = new char [2][2][MAX / 2]; // { dg-error "size .\[0-9\]+. of (unnamed )?array" }
+ p = new char [2][2][MAX / 2 - 1]; // { dg-error "size .\[0-9\]+. of (unnamed )?array" }
+ p = new char [2][2][MAX / 2 - 2]; // { dg-error "size .\[0-9\]+. of (unnamed )?array" }
+ p = new char [2][2][MAX / 2 - 3]; // { dg-error "size .\[0-9\]+. of (unnamed )?array" }
+ p = new char [2][2][MAX / 2 - 4]; // { dg-error "size .\[0-9\]+. of (unnamed )?array" }
+ p = new char [2][2][MAX / 2 - 5]; // { dg-error "size .\[0-9\]+. of (unnamed )?array" }
+ p = new char [2][2][MAX / 2 - 6]; // { dg-error "size .\[0-9\]+. of (unnamed )?array" }
+ p = new char [2][2][MAX / 2 - 7]; // { dg-error "size .\[0-9\]+. of (unnamed )?array" }
+ p = new char [2][2][MAX / 2 - 8]; // { dg-error "size .\[0-9\]+. of (unnamed )?array" }
+ p = new char [2][2][MAX / 4]; // { dg-error "size .\[0-9\]+. of array" }
+ p = new char [2][2][MAX / 4 - 1]; // { dg-error "size .\[0-9\]+. of array" }
+ p = new char [2][2][MAX / 4 - 2]; // { dg-error "size .\[0-9\]+. of array" }
// Avoid exercising data model-dependent expressions.
// p = new char [2][2][MAX / 8];
@@ -228,22 +228,22 @@ test_three_dim_char_array ()
p = new char [2][2][MAX / 8 - 2];
p = new char [2][2][MAX / 8 - 3];
- p = new char [2][MAX][2]; // { dg-error "size of (unnamed )?array" }
- p = new char [2][MAX - 1][2]; // { dg-error "size of (unnamed )?array" }
- p = new char [2][MAX - 2][2]; // { dg-error "size of (unnamed )?array" }
- p = new char [2][MAX - 99][2]; // { dg-error "size of (unnamed )?array" }
- p = new char [2][MAX / 2][2]; // { dg-error "size of (unnamed )?array" }
- p = new char [2][MAX / 2 - 1][2]; // { dg-error "size of (unnamed )?array" }
- p = new char [2][MAX / 2 - 2][2]; // { dg-error "size of (unnamed )?array" }
- p = new char [2][MAX / 2 - 3][2]; // { dg-error "size of (unnamed )?array" }
- p = new char [2][MAX / 2 - 4][2]; // { dg-error "size of (unnamed )?array" }
- p = new char [2][MAX / 2 - 5][2]; // { dg-error "size of (unnamed )?array" }
- p = new char [2][MAX / 2 - 6][2]; // { dg-error "size of (unnamed )?array" }
- p = new char [2][MAX / 2 - 7][2]; // { dg-error "size of (unnamed )?array" }
- p = new char [2][MAX / 2 - 8][2]; // { dg-error "size of (unnamed )?array" }
- p = new char [2][MAX / 4][2]; // { dg-error "size of array" }
- p = new char [2][MAX / 4 - 1][2]; // { dg-error "size of array" }
- p = new char [2][MAX / 4 - 2][2]; // { dg-error "size of array" }
+ p = new char [2][MAX][2]; // { dg-error "size .\[0-9\]+. of (unnamed )?array" }
+ p = new char [2][MAX - 1][2]; // { dg-error "size .\[0-9\]+. of (unnamed )?array" }
+ p = new char [2][MAX - 2][2]; // { dg-error "size .\[0-9\]+. of (unnamed )?array" }
+ p = new char [2][MAX - 99][2]; // { dg-error "size .\[0-9\]+. of (unnamed )?array" }
+ p = new char [2][MAX / 2][2]; // { dg-error "size .\[0-9\]+. of (unnamed )?array" }
+ p = new char [2][MAX / 2 - 1][2]; // { dg-error "size .\[0-9\]+. of (unnamed )?array" }
+ p = new char [2][MAX / 2 - 2][2]; // { dg-error "size .\[0-9\]+. of (unnamed )?array" }
+ p = new char [2][MAX / 2 - 3][2]; // { dg-error "size .\[0-9\]+. of (unnamed )?array" }
+ p = new char [2][MAX / 2 - 4][2]; // { dg-error "size .\[0-9\]+. of (unnamed )?array" }
+ p = new char [2][MAX / 2 - 5][2]; // { dg-error "size .\[0-9\]+. of (unnamed )?array" }
+ p = new char [2][MAX / 2 - 6][2]; // { dg-error "size .\[0-9\]+. of (unnamed )?array" }
+ p = new char [2][MAX / 2 - 7][2]; // { dg-error "size .\[0-9\]+. of (unnamed )?array" }
+ p = new char [2][MAX / 2 - 8][2]; // { dg-error "size .\[0-9\]+. of (unnamed )?array" }
+ p = new char [2][MAX / 4][2]; // { dg-error "size .\[0-9\]+. of array" }
+ p = new char [2][MAX / 4 - 1][2]; // { dg-error "size .\[0-9\]+. of array" }
+ p = new char [2][MAX / 4 - 2][2]; // { dg-error "size .\[0-9\]+. of array" }
// Avoid exercising data model-dependent expressions.
// p = new char [2][MAX / 8][2];
@@ -252,22 +252,22 @@ test_three_dim_char_array ()
p = new char [2][MAX / 8 - 2][2];
p = new char [2][MAX / 8 - 3][2];
- p = new char [MAX][2][2]; // { dg-error "size of array" }
- p = new char [MAX - 1][2][2]; // { dg-error "size of array" }
- p = new char [MAX - 2][2][2]; // { dg-error "size of array" }
- p = new char [MAX - 99][2][2]; // { dg-error "size of array" }
- p = new char [MAX / 2][2][2]; // { dg-error "size of array" }
- p = new char [MAX / 2 - 1][2][2]; // { dg-error "size of array" }
- p = new char [MAX / 2 - 2][2][2]; // { dg-error "size of array" }
- p = new char [MAX / 2 - 3][2][2]; // { dg-error "size of array" }
- p = new char [MAX / 2 - 4][2][2]; // { dg-error "size of array" }
- p = new char [MAX / 2 - 5][2][2]; // { dg-error "size of array" }
- p = new char [MAX / 2 - 6][2][2]; // { dg-error "size of array" }
- p = new char [MAX / 2 - 7][2][2]; // { dg-error "size of array" }
- p = new char [MAX / 2 - 8][2][2]; // { dg-error "size of array" }
- p = new char [MAX / 4][2][2]; // { dg-error "size of array" }
- p = new char [MAX / 4 - 1][2][2]; // { dg-error "size of array" }
- p = new char [MAX / 4 - 2][2][2]; // { dg-error "size of array" }
+ p = new char [MAX][2][2]; // { dg-error "size .\[0-9\]+. of array" }
+ p = new char [MAX - 1][2][2]; // { dg-error "size .\[0-9\]+. of array" }
+ p = new char [MAX - 2][2][2]; // { dg-error "size .\[0-9\]+. of array" }
+ p = new char [MAX - 99][2][2]; // { dg-error "size .\[0-9\]+. of array" }
+ p = new char [MAX / 2][2][2]; // { dg-error "size .\[0-9\]+. of array" }
+ p = new char [MAX / 2 - 1][2][2]; // { dg-error "size .\[0-9\]+. of array" }
+ p = new char [MAX / 2 - 2][2][2]; // { dg-error "size .\[0-9\]+. of array" }
+ p = new char [MAX / 2 - 3][2][2]; // { dg-error "size .\[0-9\]+. of array" }
+ p = new char [MAX / 2 - 4][2][2]; // { dg-error "size .\[0-9\]+. of array" }
+ p = new char [MAX / 2 - 5][2][2]; // { dg-error "size .\[0-9\]+. of array" }
+ p = new char [MAX / 2 - 6][2][2]; // { dg-error "size .\[0-9\]+. of array" }
+ p = new char [MAX / 2 - 7][2][2]; // { dg-error "size .\[0-9\]+. of array" }
+ p = new char [MAX / 2 - 8][2][2]; // { dg-error "size .\[0-9\]+. of array" }
+ p = new char [MAX / 4][2][2]; // { dg-error "size .\[0-9\]+. of array" }
+ p = new char [MAX / 4 - 1][2][2]; // { dg-error "size .\[0-9\]+. of array" }
+ p = new char [MAX / 4 - 2][2][2]; // { dg-error "size .\[0-9\]+. of array" }
// Avoid exercising data model-dependent expressions.
// p = new char [MAX / 8][2][2];
@@ -276,9 +276,9 @@ test_three_dim_char_array ()
p = new char [MAX / 8 - 2][2][2];
p = new char [MAX / 8 - 3][2][2];
- p = new char [MAX][MAX][MAX]; // { dg-error "size of (unnamed )?array" }
- p = new char [MAX][MAX][MAX / 2]; // { dg-error "size of (unnamed )?array" }
- p = new char [MAX][MAX / 2][MAX]; // { dg-error "size of (unnamed )?array" }
+ p = new char [MAX][MAX][MAX]; // { dg-error "size .\[0-9\]+. of (unnamed )?array" }
+ p = new char [MAX][MAX][MAX / 2]; // { dg-error "size .\[0-9\]+. of (unnamed )?array" }
+ p = new char [MAX][MAX / 2][MAX]; // { dg-error "size .\[0-9\]+. of (unnamed )?array" }
p = new char [MAX][MAX / 2][MAX / 2]; // { dg-error "size of (unnamed )?array" }
p = new char [MAX / 2][MAX / 2][MAX / 2]; // { dg-error "size of (unnamed )?array" }
}
@@ -297,9 +297,9 @@ test_N_dim_char_array ()
p = new char [N][N][N][N][N][N][N];
p = new char [N / 2][2][N][N][N][N][N][N];
p = new char [N - 1][N / 2][N][N][N][N][N][N];
- p = new char [N / 2][N][N][N][N][N][N][N]; // { dg-error "size of array" }
- p = new char [N - 1][N][N][N][N][N][N][N]; // { dg-error "size of array" }
- p = new char [N] [N][N][N][N][N][N][N]; // { dg-error "size of array" }
+ p = new char [N / 2][N][N][N][N][N][N][N]; // { dg-error "size .\[0-9\]+. of array" }
+ p = new char [N - 1][N][N][N][N][N][N][N]; // { dg-error "size .\[0-9\]+. of array" }
+ p = new char [N] [N][N][N][N][N][N][N]; // { dg-error "size .\[0-9\]+. of array" }
}
typedef struct Byte {
@@ -316,17 +316,17 @@ void* operator new[] (size_t, B*);
static void __attribute__ ((used))
test_one_dim_byte_array (void *p)
{
- p = new (p) B [MAX]; // { dg-error "size of array" }
- p = new (p) B [MAX - 1]; // { dg-error "size of array" }
- p = new (p) B [MAX - 2]; // { dg-error "size of array" }
- p = new (p) B [MAX - 99]; // { dg-error "size of array" }
- p = new (p) B [MAX / 2]; // { dg-error "size of array" }
- p = new (p) B [MAX / 2 - 1]; // { dg-error "size of array" }
- p = new (p) B [MAX / 2 - 2]; // { dg-error "size of array" }
+ p = new (p) B [MAX]; // { dg-error "size .\[0-9\]+. of array" }
+ p = new (p) B [MAX - 1]; // { dg-error "size .\[0-9\]+. of array" }
+ p = new (p) B [MAX - 2]; // { dg-error "size .\[0-9\]+. of array" }
+ p = new (p) B [MAX - 99]; // { dg-error "size .\[0-9\]+. of array" }
+ p = new (p) B [MAX / 2]; // { dg-error "size .\[0-9\]+. of array" }
+ p = new (p) B [MAX / 2 - 1]; // { dg-error "size .\[0-9\]+. of array" }
+ p = new (p) B [MAX / 2 - 2]; // { dg-error "size .\[0-9\]+. of array" }
// Avoid testing the expressions below since whether or not they
// are accepted depends on the precision of size_t (which determines
- // the size of the cookie).
+ // the size .\[0-9\]+. of the cookie).
// p = new (p) B [MAX / 2 - 3];
// p = new (p) B [MAX / 2 - 4];
// p = new (p) B [MAX / 2 - 5];
@@ -343,13 +343,13 @@ test_one_dim_byte_array (void *p)
static void __attribute__ ((used))
test_placement_two_dim_byte_struct_array (void *p)
{
- p = new (p) B [1][MAX]; // { dg-error "size of (unnamed )?array" }
- p = new (p) B [1][MAX - 1]; // { dg-error "size of (unnamed )?array" }
- p = new (p) B [1][MAX - 2]; // { dg-error "size of (unnamed )?array" }
- p = new (p) B [1][MAX - 99]; // { dg-error "size of (unnamed )?array" }
- p = new (p) B [1][MAX / 2]; // { dg-error "size of array" }
- p = new (p) B [1][MAX / 2 - 1]; // { dg-error "size of array" }
- p = new (p) B [1][MAX / 2 - 2]; // { dg-error "size of array" }
+ p = new (p) B [1][MAX]; // { dg-error "size .\[0-9\]+. of (unnamed )?array" }
+ p = new (p) B [1][MAX - 1]; // { dg-error "size .\[0-9\]+. of (unnamed )?array" }
+ p = new (p) B [1][MAX - 2]; // { dg-error "size .\[0-9\]+. of (unnamed )?array" }
+ p = new (p) B [1][MAX - 99]; // { dg-error "size .\[0-9\]+. of (unnamed )?array" }
+ p = new (p) B [1][MAX / 2]; // { dg-error "size .\[0-9\]+. of array" }
+ p = new (p) B [1][MAX / 2 - 1]; // { dg-error "size .\[0-9\]+. of array" }
+ p = new (p) B [1][MAX / 2 - 2]; // { dg-error "size .\[0-9\]+. of array" }
// Avoid exercising data model-dependent expressions.
// p = new (p) B [1][MAX / 2 - 3];
@@ -360,28 +360,28 @@ test_placement_two_dim_byte_struct_array (void *p)
p = new (p) B [1][MAX / 2 - 7]; // okay
p = new (p) B [1][MAX / 2 - 8]; // okay
- p = new (p) B [2][MAX]; // { dg-error "size of (unnamed )?array" }
- p = new (p) B [2][MAX - 1]; // { dg-error "size of (unnamed )?array" }
- p = new (p) B [2][MAX - 2]; // { dg-error "size of (unnamed )?array" }
- p = new (p) B [2][MAX / 2]; // { dg-error "size of array" }
- p = new (p) B [2][MAX / 2 - 1]; // { dg-error "size of array" }
- p = new (p) B [2][MAX / 2 - 2]; // { dg-error "size of array" }
- p = new (p) B [2][MAX / 2 - 7]; // { dg-error "size of array" }
- p = new (p) B [2][MAX / 2 - 8]; // { dg-error "size of array" }
+ p = new (p) B [2][MAX]; // { dg-error "size .\[0-9\]+. of (unnamed )?array" }
+ p = new (p) B [2][MAX - 1]; // { dg-error "size .\[0-9\]+. of (unnamed )?array" }
+ p = new (p) B [2][MAX - 2]; // { dg-error "size .\[0-9\]+. of (unnamed )?array" }
+ p = new (p) B [2][MAX / 2]; // { dg-error "size .\[0-9\]+. of array" }
+ p = new (p) B [2][MAX / 2 - 1]; // { dg-error "size .\[0-9\]+. of array" }
+ p = new (p) B [2][MAX / 2 - 2]; // { dg-error "size .\[0-9\]+. of array" }
+ p = new (p) B [2][MAX / 2 - 7]; // { dg-error "size .\[0-9\]+. of array" }
+ p = new (p) B [2][MAX / 2 - 8]; // { dg-error "size .\[0-9\]+. of array" }
- p = new (p) B [MAX][MAX]; // { dg-error "size of (unnamed )?array" }
- p = new (p) B [MAX][MAX - 1]; // { dg-error "size of (unnamed )?array" }
- p = new (p) B [MAX][MAX - 2]; // { dg-error "size of (unnamed )?array" }
- p = new (p) B [MAX][MAX / 2]; // { dg-error "size of array" }
- p = new (p) B [MAX][MAX / 2 - 1]; // { dg-error "size of array" }
- p = new (p) B [MAX][MAX / 2 - 2]; // { dg-error "size of array" }
- p = new (p) B [MAX][MAX / 2 - 7]; // { dg-error "size of array" }
- p = new (p) B [MAX][MAX / 2 - 8]; // { dg-error "size of array" }
- p = new (p) B [MAX][2]; // { dg-error "size of array" }
- p = new (p) B [MAX][1]; // { dg-error "size of array" }
- p = new (p) B [MAX / 2][1]; // { dg-error "size of array" }
- p = new (p) B [MAX / 2 - 1][1]; // { dg-error "size of array" }
- p = new (p) B [MAX / 2 - 2][1]; // { dg-error "size of array" }
+ p = new (p) B [MAX][MAX]; // { dg-error "size .\[0-9\]+. of (unnamed )?array" }
+ p = new (p) B [MAX][MAX - 1]; // { dg-error "size .\[0-9\]+. of (unnamed )?array" }
+ p = new (p) B [MAX][MAX - 2]; // { dg-error "size .\[0-9\]+. of (unnamed )?array" }
+ p = new (p) B [MAX][MAX / 2]; // { dg-error "size .\[0-9\]+. of array" }
+ p = new (p) B [MAX][MAX / 2 - 1]; // { dg-error "size .\[0-9\]+. of array" }
+ p = new (p) B [MAX][MAX / 2 - 2]; // { dg-error "size .\[0-9\]+. of array" }
+ p = new (p) B [MAX][MAX / 2 - 7]; // { dg-error "size .\[0-9\]+. of array" }
+ p = new (p) B [MAX][MAX / 2 - 8]; // { dg-error "size .\[0-9\]+. of array" }
+ p = new (p) B [MAX][2]; // { dg-error "size .\[0-9\]+. of array" }
+ p = new (p) B [MAX][1]; // { dg-error "size .\[0-9\]+. of array" }
+ p = new (p) B [MAX / 2][1]; // { dg-error "size .\[0-9\]+. of array" }
+ p = new (p) B [MAX / 2 - 1][1]; // { dg-error "size .\[0-9\]+. of array" }
+ p = new (p) B [MAX / 2 - 2][1]; // { dg-error "size .\[0-9\]+. of array" }
// Avoid exercising data model-dependent expressions.
// p = new (p) B [MAX / 2 - 3][1];
@@ -398,13 +398,13 @@ test_placement_two_dim_byte_struct_array (void *p)
static __attribute__ ((used)) void
test_placement_three_dim_byte_struct_array (void *p)
{
- p = new (p) B [1][1][MAX]; // { dg-error "size of (unnamed )?array" }
- p = new (p) B [1][1][MAX - 1]; // { dg-error "size of (unnamed )?array" }
- p = new (p) B [1][1][MAX - 2]; // { dg-error "size of (unnamed )?array" }
- p = new (p) B [1][1][MAX - 99]; // { dg-error "size of (unnamed )?array" }
- p = new (p) B [1][1][MAX / 2]; // { dg-error "size of array" }
- p = new (p) B [1][1][MAX / 2 - 1]; // { dg-error "size of array" }
- p = new (p) B [1][1][MAX / 2 - 2]; // { dg-error "size of array" }
+ p = new (p) B [1][1][MAX]; // { dg-error "size .\[0-9\]+. of (unnamed )?array" }
+ p = new (p) B [1][1][MAX - 1]; // { dg-error "size .\[0-9\]+. of (unnamed )?array" }
+ p = new (p) B [1][1][MAX - 2]; // { dg-error "size .\[0-9\]+. of (unnamed )?array" }
+ p = new (p) B [1][1][MAX - 99]; // { dg-error "size .\[0-9\]+. of (unnamed )?array" }
+ p = new (p) B [1][1][MAX / 2]; // { dg-error "size .\[0-9\]+. of array" }
+ p = new (p) B [1][1][MAX / 2 - 1]; // { dg-error "size .\[0-9\]+. of array" }
+ p = new (p) B [1][1][MAX / 2 - 2]; // { dg-error "size .\[0-9\]+. of array" }
// Avoid exercising data model-dependent expressions.
// p = new (p) B [1][1][MAX / 2 - 3];
@@ -415,20 +415,20 @@ test_placement_three_dim_byte_struct_array (void *
p = new (p) B [1][1][MAX / 2 - 7]; // okay
p = new (p) B [1][1][MAX / 2 - 8]; // okay
- p = new (p) B [1][2][MAX]; // { dg-error "size of (unnamed )?array" }
- p = new (p) B [1][2][MAX - 1]; // { dg-error "size of (unnamed )?array" }
- p = new (p) B [1][2][MAX - 2]; // { dg-error "size of (unnamed )?array" }
- p = new (p) B [1][2][MAX - 99]; // { dg-error "size of (unnamed )?array" }
- p = new (p) B [1][2][MAX / 2]; // { dg-error "size of (unnamed )?array" }
- p = new (p) B [1][2][MAX / 2 - 1]; // { dg-error "size of (unnamed )?array" }
- p = new (p) B [1][2][MAX / 2 - 2]; // { dg-error "size of (unnamed )?array" }
- p = new (p) B [1][2][MAX / 2 - 3]; // { dg-error "size of (unnamed )?array" }
- p = new (p) B [1][2][MAX / 2 - 4]; // { dg-error "size of (unnamed )?array" }
- p = new (p) B [1][2][MAX / 2 - 5]; // { dg-error "size of (unnamed )?array" }
- p = new (p) B [1][2][MAX / 2 - 6]; // { dg-error "size of (unnamed )?array" }
- p = new (p) B [1][2][MAX / 2 - 7]; // { dg-error "size of (unnamed )?array" }
- p = new (p) B [1][2][MAX / 2 - 8]; // { dg-error "size of (unnamed )?array" }
- p = new (p) B [1][2][MAX / 4]; // { dg-error "size of array" }
+ p = new (p) B [1][2][MAX]; // { dg-error "size .\[0-9\]+. of (unnamed )?array" }
+ p = new (p) B [1][2][MAX - 1]; // { dg-error "size .\[0-9\]+. of (unnamed )?array" }
+ p = new (p) B [1][2][MAX - 2]; // { dg-error "size .\[0-9\]+. of (unnamed )?array" }
+ p = new (p) B [1][2][MAX - 99]; // { dg-error "size .\[0-9\]+. of (unnamed )?array" }
+ p = new (p) B [1][2][MAX / 2]; // { dg-error "size .\[0-9\]+. of (unnamed )?array" }
+ p = new (p) B [1][2][MAX / 2 - 1]; // { dg-error "size .\[0-9\]+. of (unnamed )?array" }
+ p = new (p) B [1][2][MAX / 2 - 2]; // { dg-error "size .\[0-9\]+. of (unnamed )?array" }
+ p = new (p) B [1][2][MAX / 2 - 3]; // { dg-error "size .\[0-9\]+. of (unnamed )?array" }
+ p = new (p) B [1][2][MAX / 2 - 4]; // { dg-error "size .\[0-9\]+. of (unnamed )?array" }
+ p = new (p) B [1][2][MAX / 2 - 5]; // { dg-error "size .\[0-9\]+. of (unnamed )?array" }
+ p = new (p) B [1][2][MAX / 2 - 6]; // { dg-error "size .\[0-9\]+. of (unnamed )?array" }
+ p = new (p) B [1][2][MAX / 2 - 7]; // { dg-error "size .\[0-9\]+. of (unnamed )?array" }
+ p = new (p) B [1][2][MAX / 2 - 8]; // { dg-error "size .\[0-9\]+. of (unnamed )?array" }
+ p = new (p) B [1][2][MAX / 4]; // { dg-error "size .\[0-9\]+. of array" }
// Avoid exercising data model-dependent expressions.
// p = new (p) B [1][2][MAX / 4 - 1];
@@ -437,20 +437,20 @@ test_placement_three_dim_byte_struct_array (void *
p = new (p) B [1][2][MAX / 4 - 3]; // okay
p = new (p) B [1][2][MAX / 4 - 4]; // okay
- p = new (p) B [2][1][MAX]; // { dg-error "size of (unnamed )?array" }
- p = new (p) B [2][1][MAX - 1]; // { dg-error "size of (unnamed )?array" }
- p = new (p) B [2][1][MAX - 2]; // { dg-error "size of (unnamed )?array" }
- p = new (p) B [2][1][MAX - 99]; // { dg-error "size of (unnamed )?array" }
- p = new (p) B [2][1][MAX / 2]; // { dg-error "size of array" }
- p = new (p) B [2][1][MAX / 2 - 1]; // { dg-error "size of array" }
- p = new (p) B [2][1][MAX / 2 - 2]; // { dg-error "size of array" }
- p = new (p) B [2][1][MAX / 2 - 3]; // { dg-error "size of array" }
- p = new (p) B [2][1][MAX / 2 - 4]; // { dg-error "size of array" }
- p = new (p) B [2][1][MAX / 2 - 5]; // { dg-error "size of array" }
- p = new (p) B [2][1][MAX / 2 - 6]; // { dg-error "size of array" }
- p = new (p) B [2][1][MAX / 2 - 7]; // { dg-error "size of array" }
- p = new (p) B [2][1][MAX / 2 - 8]; // { dg-error "size of array" }
- p = new (p) B [2][1][MAX / 4]; // { dg-error "size of array" }
+ p = new (p) B [2][1][MAX]; // { dg-error "size .\[0-9\]+. of (unnamed )?array" }
+ p = new (p) B [2][1][MAX - 1]; // { dg-error "size .\[0-9\]+. of (unnamed )?array" }
+ p = new (p) B [2][1][MAX - 2]; // { dg-error "size .\[0-9\]+. of (unnamed )?array" }
+ p = new (p) B [2][1][MAX - 99]; // { dg-error "size .\[0-9\]+. of (unnamed )?array" }
+ p = new (p) B [2][1][MAX / 2]; // { dg-error "size .\[0-9\]+. of array" }
+ p = new (p) B [2][1][MAX / 2 - 1]; // { dg-error "size .\[0-9\]+. of array" }
+ p = new (p) B [2][1][MAX / 2 - 2]; // { dg-error "size .\[0-9\]+. of array" }
+ p = new (p) B [2][1][MAX / 2 - 3]; // { dg-error "size .\[0-9\]+. of array" }
+ p = new (p) B [2][1][MAX / 2 - 4]; // { dg-error "size .\[0-9\]+. of array" }
+ p = new (p) B [2][1][MAX / 2 - 5]; // { dg-error "size .\[0-9\]+. of array" }
+ p = new (p) B [2][1][MAX / 2 - 6]; // { dg-error "size .\[0-9\]+. of array" }
+ p = new (p) B [2][1][MAX / 2 - 7]; // { dg-error "size .\[0-9\]+. of array" }
+ p = new (p) B [2][1][MAX / 2 - 8]; // { dg-error "size .\[0-9\]+. of array" }
+ p = new (p) B [2][1][MAX / 4]; // { dg-error "size .\[0-9\]+. of array" }
// Avoid exercising data model-dependent expressions.
// p = new (p) B [2][1][MAX / 4 - 1];
@@ -459,22 +459,22 @@ test_placement_three_dim_byte_struct_array (void *
p = new (p) B [2][1][MAX / 4 - 3]; // okay
p = new (p) B [2][1][MAX / 4 - 4]; // okay
- p = new (p) B [2][2][MAX]; // { dg-error "size of (unnamed )?array" }
- p = new (p) B [2][2][MAX - 1]; // { dg-error "size of (unnamed )?array" }
- p = new (p) B [2][2][MAX - 2]; // { dg-error "size of (unnamed )?array" }
- p = new (p) B [2][2][MAX - 99]; // { dg-error "size of (unnamed )?array" }
- p = new (p) B [2][2][MAX / 2]; // { dg-error "size of (unnamed )?array" }
- p = new (p) B [2][2][MAX / 2 - 1]; // { dg-error "size of (unnamed )?array" }
- p = new (p) B [2][2][MAX / 2 - 2]; // { dg-error "size of (unnamed )?array" }
- p = new (p) B [2][2][MAX / 2 - 3]; // { dg-error "size of (unnamed )?array" }
- p = new (p) B [2][2][MAX / 2 - 4]; // { dg-error "size of (unnamed )?array" }
- p = new (p) B [2][2][MAX / 2 - 5]; // { dg-error "size of (unnamed )?array" }
- p = new (p) B [2][2][MAX / 2 - 6]; // { dg-error "size of (unnamed )?array" }
- p = new (p) B [2][2][MAX / 2 - 7]; // { dg-error "size of (unnamed )?array" }
- p = new (p) B [2][2][MAX / 2 - 8]; // { dg-error "size of (unnamed )?array" }
- p = new (p) B [2][2][MAX / 4]; // { dg-error "size of array" }
- p = new (p) B [2][2][MAX / 4 - 1]; // { dg-error "size of array" }
- p = new (p) B [2][2][MAX / 4 - 2]; // { dg-error "size of array" }
+ p = new (p) B [2][2][MAX]; // { dg-error "size .\[0-9\]+. of (unnamed )?array" }
+ p = new (p) B [2][2][MAX - 1]; // { dg-error "size .\[0-9\]+. of (unnamed )?array" }
+ p = new (p) B [2][2][MAX - 2]; // { dg-error "size .\[0-9\]+. of (unnamed )?array" }
+ p = new (p) B [2][2][MAX - 99]; // { dg-error "size .\[0-9\]+. of (unnamed )?array" }
+ p = new (p) B [2][2][MAX / 2]; // { dg-error "size .\[0-9\]+. of (unnamed )?array" }
+ p = new (p) B [2][2][MAX / 2 - 1]; // { dg-error "size .\[0-9\]+. of (unnamed )?array" }
+ p = new (p) B [2][2][MAX / 2 - 2]; // { dg-error "size .\[0-9\]+. of (unnamed )?array" }
+ p = new (p) B [2][2][MAX / 2 - 3]; // { dg-error "size .\[0-9\]+. of (unnamed )?array" }
+ p = new (p) B [2][2][MAX / 2 - 4]; // { dg-error "size .\[0-9\]+. of (unnamed )?array" }
+ p = new (p) B [2][2][MAX / 2 - 5]; // { dg-error "size .\[0-9\]+. of (unnamed )?array" }
+ p = new (p) B [2][2][MAX / 2 - 6]; // { dg-error "size .\[0-9\]+. of (unnamed )?array" }
+ p = new (p) B [2][2][MAX / 2 - 7]; // { dg-error "size .\[0-9\]+. of (unnamed )?array" }
+ p = new (p) B [2][2][MAX / 2 - 8]; // { dg-error "size .\[0-9\]+. of (unnamed )?array" }
+ p = new (p) B [2][2][MAX / 4]; // { dg-error "size .\[0-9\]+. of array" }
+ p = new (p) B [2][2][MAX / 4 - 1]; // { dg-error "size .\[0-9\]+. of array" }
+ p = new (p) B [2][2][MAX / 4 - 2]; // { dg-error "size .\[0-9\]+. of array" }
// Avoid exercising data model-dependent expressions.
// p = new (p) B [2][2][MAX / 8];
@@ -483,22 +483,22 @@ test_placement_three_dim_byte_struct_array (void *
p = new (p) B [2][2][MAX / 8 - 2];
p = new (p) B [2][2][MAX / 8 - 3];
- p = new (p) B [2][MAX][2]; // { dg-error "size of (unnamed )?array" }
- p = new (p) B [2][MAX - 1][2]; // { dg-error "size of (unnamed )?array" }
- p = new (p) B [2][MAX - 2][2]; // { dg-error "size of (unnamed )?array" }
- p = new (p) B [2][MAX - 99][2]; // { dg-error "size of (unnamed )?array" }
- p = new (p) B [2][MAX / 2][2]; // { dg-error "size of (unnamed )?array" }
- p = new (p) B [2][MAX / 2 - 1][2]; // { dg-error "size of (unnamed )?array" }
- p = new (p) B [2][MAX / 2 - 2][2]; // { dg-error "size of (unnamed )?array" }
- p = new (p) B [2][MAX / 2 - 3][2]; // { dg-error "size of (unnamed )?array" }
- p = new (p) B [2][MAX / 2 - 4][2]; // { dg-error "size of (unnamed )?array" }
- p = new (p) B [2][MAX / 2 - 5][2]; // { dg-error "size of (unnamed )?array" }
- p = new (p) B [2][MAX / 2 - 6][2]; // { dg-error "size of (unnamed )?array" }
- p = new (p) B [2][MAX / 2 - 7][2]; // { dg-error "size of (unnamed )?array" }
- p = new (p) B [2][MAX / 2 - 8][2]; // { dg-error "size of (unnamed )?array" }
- p = new (p) B [2][MAX / 4][2]; // { dg-error "size of array" }
- p = new (p) B [2][MAX / 4 - 1][2]; // { dg-error "size of array" }
- p = new (p) B [2][MAX / 4 - 2][2]; // { dg-error "size of array" }
+ p = new (p) B [2][MAX][2]; // { dg-error "size .\[0-9\]+. of (unnamed )?array" }
+ p = new (p) B [2][MAX - 1][2]; // { dg-error "size .\[0-9\]+. of (unnamed )?array" }
+ p = new (p) B [2][MAX - 2][2]; // { dg-error "size .\[0-9\]+. of (unnamed )?array" }
+ p = new (p) B [2][MAX - 99][2]; // { dg-error "size .\[0-9\]+. of (unnamed )?array" }
+ p = new (p) B [2][MAX / 2][2]; // { dg-error "size .\[0-9\]+. of (unnamed )?array" }
+ p = new (p) B [2][MAX / 2 - 1][2]; // { dg-error "size .\[0-9\]+. of (unnamed )?array" }
+ p = new (p) B [2][MAX / 2 - 2][2]; // { dg-error "size .\[0-9\]+. of (unnamed )?array" }
+ p = new (p) B [2][MAX / 2 - 3][2]; // { dg-error "size .\[0-9\]+. of (unnamed )?array" }
+ p = new (p) B [2][MAX / 2 - 4][2]; // { dg-error "size .\[0-9\]+. of (unnamed )?array" }
+ p = new (p) B [2][MAX / 2 - 5][2]; // { dg-error "size .\[0-9\]+. of (unnamed )?array" }
+ p = new (p) B [2][MAX / 2 - 6][2]; // { dg-error "size .\[0-9\]+. of (unnamed )?array" }
+ p = new (p) B [2][MAX / 2 - 7][2]; // { dg-error "size .\[0-9\]+. of (unnamed )?array" }
+ p = new (p) B [2][MAX / 2 - 8][2]; // { dg-error "size .\[0-9\]+. of (unnamed )?array" }
+ p = new (p) B [2][MAX / 4][2]; // { dg-error "size .\[0-9\]+. of array" }
+ p = new (p) B [2][MAX / 4 - 1][2]; // { dg-error "size .\[0-9\]+. of array" }
+ p = new (p) B [2][MAX / 4 - 2][2]; // { dg-error "size .\[0-9\]+. of array" }
// Avoid exercising data model-dependent expressions.
// p = new (p) B [2][MAX / 8][2];
@@ -507,22 +507,22 @@ test_placement_three_dim_byte_struct_array (void *
p = new (p) B [2][MAX / 8 - 2][2];
p = new (p) B [2][MAX / 8 - 3][2];
- p = new (p) B [MAX][2][2]; // { dg-error "size of array" }
- p = new (p) B [MAX - 1][2][2]; // { dg-error "size of array" }
- p = new (p) B [MAX - 2][2][2]; // { dg-error "size of array" }
- p = new (p) B [MAX - 99][2][2]; // { dg-error "size of array" }
- p = new (p) B [MAX / 2][2][2]; // { dg-error "size of array" }
- p = new (p) B [MAX / 2 - 1][2][2]; // { dg-error "size of array" }
- p = new (p) B [MAX / 2 - 2][2][2]; // { dg-error "size of array" }
- p = new (p) B [MAX / 2 - 3][2][2]; // { dg-error "size of array" }
- p = new (p) B [MAX / 2 - 4][2][2]; // { dg-error "size of array" }
- p = new (p) B [MAX / 2 - 5][2][2]; // { dg-error "size of array" }
- p = new (p) B [MAX / 2 - 6][2][2]; // { dg-error "size of array" }
- p = new (p) B [MAX / 2 - 7][2][2]; // { dg-error "size of array" }
- p = new (p) B [MAX / 2 - 8][2][2]; // { dg-error "size of array" }
- p = new (p) B [MAX / 4][2][2]; // { dg-error "size of array" }
- p = new (p) B [MAX / 4 - 1][2][2]; // { dg-error "size of array" }
- p = new (p) B [MAX / 4 - 2][2][2]; // { dg-error "size of array" }
+ p = new (p) B [MAX][2][2]; // { dg-error "size .\[0-9\]+. of array" }
+ p = new (p) B [MAX - 1][2][2]; // { dg-error "size .\[0-9\]+. of array" }
+ p = new (p) B [MAX - 2][2][2]; // { dg-error "size .\[0-9\]+. of array" }
+ p = new (p) B [MAX - 99][2][2]; // { dg-error "size .\[0-9\]+. of array" }
+ p = new (p) B [MAX / 2][2][2]; // { dg-error "size .\[0-9\]+. of array" }
+ p = new (p) B [MAX / 2 - 1][2][2]; // { dg-error "size .\[0-9\]+. of array" }
+ p = new (p) B [MAX / 2 - 2][2][2]; // { dg-error "size .\[0-9\]+. of array" }
+ p = new (p) B [MAX / 2 - 3][2][2]; // { dg-error "size .\[0-9\]+. of array" }
+ p = new (p) B [MAX / 2 - 4][2][2]; // { dg-error "size .\[0-9\]+. of array" }
+ p = new (p) B [MAX / 2 - 5][2][2]; // { dg-error "size .\[0-9\]+. of array" }
+ p = new (p) B [MAX / 2 - 6][2][2]; // { dg-error "size .\[0-9\]+. of array" }
+ p = new (p) B [MAX / 2 - 7][2][2]; // { dg-error "size .\[0-9\]+. of array" }
+ p = new (p) B [MAX / 2 - 8][2][2]; // { dg-error "size .\[0-9\]+. of array" }
+ p = new (p) B [MAX / 4][2][2]; // { dg-error "size .\[0-9\]+. of array" }
+ p = new (p) B [MAX / 4 - 1][2][2]; // { dg-error "size .\[0-9\]+. of array" }
+ p = new (p) B [MAX / 4 - 2][2][2]; // { dg-error "size .\[0-9\]+. of array" }
// Avoid exercising data model-dependent expressions.
// p = new (p) B [MAX / 8][2][2];
Index: gcc/testsuite/g++.dg/init/new46.C
===================================================================
--- gcc/testsuite/g++.dg/init/new46.C (revision 268547)
+++ gcc/testsuite/g++.dg/init/new46.C (working copy)
@@ -37,7 +37,7 @@ char* fn2_2_x () {
template <size_t M, size_t N>
char* fn2_2 () {
- return new char [M][N]; // { dg-error "size of array is too large" }
+ return new char [M][N]; // { dg-error "size .\[0-9\]+. of array exceeds maximum object size" }
}
// Not instantiated (must not be diagnosed).
@@ -50,7 +50,7 @@ T* fn3_x () {
template <class T>
T* fn3 () {
const size_t a = sizeof (T);
- return new T [a]; // { dg-error "size of array is too large" }
+ return new T [a]; // { dg-error "size .\[0-9\]+. of array exceeds maximum object size" }
}
Index: gcc/testsuite/g++.dg/other/large-size-array.C
===================================================================
--- gcc/testsuite/g++.dg/other/large-size-array.C (revision 268547)
+++ gcc/testsuite/g++.dg/other/large-size-array.C (working copy)
@@ -20,7 +20,7 @@ sub (int *a)
int
main (void)
{
- int a[DIM][DIM]; /* { dg-error "size of array 'a' is too large" } */
+ int a[DIM][DIM]; /* { dg-error "exceeds maximum object size" } */
return sub (&a[0][0]); /* { dg-error "declared" } */
}
Index: gcc/testsuite/g++.dg/other/new-size-type.C
===================================================================
--- gcc/testsuite/g++.dg/other/new-size-type.C (revision 268547)
+++ gcc/testsuite/g++.dg/other/new-size-type.C (working copy)
@@ -5,5 +5,5 @@
const char*
foo()
{
- return new char[~static_cast<size_t>(0)];// { dg-error "size of array" }
+ return new char[~static_cast<size_t>(0)];// { dg-error "exceeds maximum object size" }
}
Index: gcc/testsuite/g++.dg/template/array30.C
===================================================================
--- gcc/testsuite/g++.dg/template/array30.C (revision 268547)
+++ gcc/testsuite/g++.dg/template/array30.C (working copy)
@@ -1,7 +1,7 @@
template <int I>
struct A
{
- int ar[I][I][I][I][I][I][I][I][I][I]; // { dg-error "too large" }
+ int ar[I][I][I][I][I][I][I][I][I][I]; // { dg-error "exceeds maximum object size" }
};
A<66000> a;
Index: gcc/testsuite/g++.dg/template/array32.C
===================================================================
--- gcc/testsuite/g++.dg/template/array32.C (nonexistent)
+++ gcc/testsuite/g++.dg/template/array32.C (working copy)
@@ -0,0 +1,27 @@
+/* PR c++/87996 - "size of array is negative" error when SIZE_MAX/2 < sizeof(array) <= SIZE_MAX
+ { dg-do compile }
+ { dg-options "-ftrack-macro-expansion=0" } */
+
+#define SIZE_MAX __SIZE_MAX__
+
+typedef __SIZE_TYPE__ size_t;
+
+template <size_t N> struct Aszmax_d2 {
+ char a[N];
+};
+Aszmax_d2<SIZE_MAX / 2> aszmax_d2;
+
+template <size_t N> struct Aszmax_d2_p1 {
+ char a[N]; // { dg-error "exceeds maximum object size" }
+};
+Aszmax_d2_p1<SIZE_MAX / 2 + 1> aszmax_d2_p1;
+
+template <size_t N> struct Aszmax {
+ char a[N]; // { dg-error "exceeds maximum object size" }
+};
+Aszmax<SIZE_MAX> aszmax;
+
+template <size_t M, size_t N> struct Aszmax_d2_szmax_d2 {
+ char a[M][N]; // { dg-error "exceeds maximum object size" }
+};
+Aszmax_d2_szmax_d2<SIZE_MAX / 2, SIZE_MAX / 2> aszmaxd2_szmaxd2;
Index: gcc/testsuite/g++.dg/template/dependent-name3.C
===================================================================
--- gcc/testsuite/g++.dg/template/dependent-name3.C (revision 268547)
+++ gcc/testsuite/g++.dg/template/dependent-name3.C (working copy)
@@ -11,7 +11,7 @@ template<int I> struct A
template<int N> struct B
{
int x[A<N>::zero]; // { dg-error "zero" }
- int y[A<N>::minus_one]; // { dg-error "size of array|narrowing conversion" }
+ int y[A<N>::minus_one]; // { dg-error "size .-1. of array is negative|narrowing conversion|not an integral constant-expression" }
};
B<0> b;
Index: gcc/testsuite/g++.dg/ubsan/pr81530.C
===================================================================
--- gcc/testsuite/g++.dg/ubsan/pr81530.C (revision 268547)
+++ gcc/testsuite/g++.dg/ubsan/pr81530.C (working copy)
@@ -2,4 +2,4 @@
/* { dg-do compile } */
/* { dg-options "-fsanitize=undefined" } */
-int a[(long) 4e20]; /* { dg-error "7:size of array .a. is (too large|negative)" } */
+int a[(long) 4e20]; /* { dg-error "7:size of array .a." } */
Index: gcc/testsuite/g++.old-deja/g++.brendan/array1.C
===================================================================
--- gcc/testsuite/g++.old-deja/g++.brendan/array1.C (revision 268547)
+++ gcc/testsuite/g++.old-deja/g++.brendan/array1.C (working copy)
@@ -2,5 +2,5 @@
// GROUPS passed array-bindings
extern "C" int printf (const char *, ...);
-char array[~(~((__SIZE_TYPE__)0ul)>>1)|~(((__SIZE_TYPE__)0ul)>>3)]; // { dg-error "39:size of array .array. is negative" } overflow in array dimension.*
+char array[~(~((__SIZE_TYPE__)0ul)>>1)|~(((__SIZE_TYPE__)0ul)>>3)]; // { dg-error "39:exceeds maximum object size" } overflow in array dimension.*
int main () { printf ("PASS\n"); return 0; }
Index: gcc/testsuite/g++.old-deja/g++.mike/p6149.C
===================================================================
--- gcc/testsuite/g++.old-deja/g++.mike/p6149.C (revision 268547)
+++ gcc/testsuite/g++.old-deja/g++.mike/p6149.C (working copy)
@@ -1,4 +1,4 @@
// { dg-do assemble }
// prms-id: 6149
-int a[3 - sizeof(double)]; // { dg-error "9:size of array .a. is negative" }
+int a[3 - sizeof(double)]; // { dg-error "9:size .\[0-9\]+. of array .a. exceeds maximum object size" }
Index: gcc/testsuite/gcc.dg/large-size-array-3.c
===================================================================
--- gcc/testsuite/gcc.dg/large-size-array-3.c (revision 268547)
+++ gcc/testsuite/gcc.dg/large-size-array-3.c (working copy)
@@ -16,6 +16,6 @@ sub (int *a)
int
main (void)
{
- int a[DIM][DIM]; /* { dg-error "size of array 'a' is too large" } */
+ int a[DIM][DIM]; /* { dg-error "exceeds maximum object size|size of array 'a' is too large" } */
return sub (&a[0][0]);
}
Index: gcc/testsuite/gcc.dg/large-size-array-5.c
===================================================================
--- gcc/testsuite/gcc.dg/large-size-array-5.c (revision 268547)
+++ gcc/testsuite/gcc.dg/large-size-array-5.c (working copy)
@@ -3,7 +3,7 @@
typedef __SIZE_TYPE__ size_t;
-extern char a[((size_t)-1 >> 1) + 1]; /* { dg-error "too large" } */
+extern char a[((size_t)-1 >> 1) + 1]; /* { dg-error "is too large" } */
extern char b[((size_t)-1 >> 1)];
-extern int c[(((size_t)-1 >> 1) + 1) / sizeof(int)]; /* { dg-error "too large" } */
+extern int c[(((size_t)-1 >> 1) + 1) / sizeof(int)]; /* { dg-error "exceeds maximum object size" } */
extern int d[((size_t)-1 >> 1) / sizeof(int)];
Index: gcc/testsuite/gcc.dg/large-size-array.c
===================================================================
--- gcc/testsuite/gcc.dg/large-size-array.c (revision 268547)
+++ gcc/testsuite/gcc.dg/large-size-array.c (working copy)
@@ -16,6 +16,6 @@ sub (int *a)
int
main (void)
{
- int a[DIM][DIM]; /* { dg-error "size of array 'a' is too large" } */
+ int a[DIM][DIM]; /* { dg-error "exceeds maximum object size" } */
return sub (&a[0][0]);
}
Index: gcc/tree.c
===================================================================
--- gcc/tree.c (revision 268547)
+++ gcc/tree.c (working copy)
@@ -7496,10 +7496,12 @@ compare_tree_int (const_tree t, unsigned HOST_WIDE
/* Return true if SIZE represents a constant size that is in bounds of
what the middle-end and the backend accepts (covering not more than
- half of the address-space). */
+ half of the address-space).
+ When PERR is non-null, set *PERR on failure to the description of
+ why SIZE is not valid. */
bool
-valid_constant_size_p (const_tree size)
+valid_constant_size_p (const_tree size, cst_size_error *perr /* = NULL */)
{
if (POLY_INT_CST_P (size))
{
@@ -7510,10 +7512,33 @@ bool
return false;
return true;
}
- if (! tree_fits_uhwi_p (size)
- || TREE_OVERFLOW (size)
- || tree_int_cst_sign_bit (size) != 0)
- return false;
+
+ cst_size_error error;
+ if (!perr)
+ perr = &error;
+
+ if (TREE_OVERFLOW (size))
+ {
+ *perr = cst_size_overflow;
+ return false;
+ }
+
+ tree type = TREE_TYPE (size);
+ if (TYPE_UNSIGNED (type))
+ {
+ if (!tree_fits_uhwi_p (size)
+ || tree_int_cst_sign_bit (size))
+ {
+ *perr = cst_size_too_big;
+ return false;
+ }
+ }
+ else if (tree_int_cst_sign_bit (size))
+ {
+ *perr = cst_size_negative;
+ return false;
+ }
+
return true;
}
@@ -14999,6 +15024,15 @@ const builtin_structptr_type builtin_structptr_typ
{ const_fexcept_t_ptr_type_node, const_ptr_type_node, "fexcept_t" }
};
+/* Return the maximum object size. */
+
+tree
+max_object_size (void)
+{
+ /* To do: Make this a configurable parameter. */
+ return TYPE_MAX_VALUE (ptrdiff_type_node);
+}
+
#if CHECKING_P
namespace selftest {
Index: gcc/tree.h
===================================================================
--- gcc/tree.h (revision 268547)
+++ gcc/tree.h (working copy)
@@ -4347,8 +4347,19 @@ extern int tree_int_cst_sign_bit (const_tree);
extern unsigned int tree_int_cst_min_precision (tree, signop);
extern tree strip_array_types (tree);
extern tree excess_precision_type (tree);
-extern bool valid_constant_size_p (const_tree);
+/* Desription of the reason why the argument of valid_constant_size_p
+ is not a valid size. */
+enum cst_size_error {
+ cst_size_ok,
+ cst_size_negative,
+ cst_size_too_big,
+ cst_size_overflow
+};
+
+extern bool valid_constant_size_p (const_tree, cst_size_error * = NULL);
+extern tree max_object_size ();
+
/* Return true if T holds a value that can be represented as a poly_int64
without loss of precision. Store the value in *VALUE if so. */