aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/cpp2a/new-array2.C
blob: 9fa3f9ea7a3468bd3fcb50b0e5733d7a646a5bbb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// PR c++/93529
// P1009: Array size deduction in new-expressions
// { dg-do compile { target c++11 } }

// Test error cases.
int *p = new double[] = { 1, 2, 3}; // { dg-error "invalid use of array with unspecified bounds" }
int *p2 = new double[] = (1, 2, 3); // { dg-error "invalid use of array with unspecified bounds" }
struct Aggr { int a; int b; int c; };
Aggr *p3 = new Aggr[]( 1, 2, 3 ); // { dg-error "could not convert|parenthesized initializer" }
char *p4 = new char[]("foo", "a"); // { dg-error "invalid conversion|parenthesized initializer" }

template<typename... T>
int *fn(T... t)
{
  return new int[]{t...}; // { dg-error "invalid conversion" }
}

void
g ()
{
  int *p = fn ("a");
}