comparison gcc/testsuite/g++.dg/cpp0x/pr83993.C @ 145:1830386684a0

gcc-9.2.0
author anatofuz
date Thu, 13 Feb 2020 11:34:05 +0900
parents 84e7813d76e9
children
comparison
equal deleted inserted replaced
131:84e7813d76e9 145:1830386684a0
5 extern const int a[]; 5 extern const int a[];
6 const int b[5] = { 1, 2, 3, 4, 5 }; 6 const int b[5] = { 1, 2, 3, 4, 5 };
7 extern const int c[4]; 7 extern const int c[4];
8 constexpr const int *d = &a[0]; 8 constexpr const int *d = &a[0];
9 constexpr const int *d2 = a; 9 constexpr const int *d2 = a;
10 constexpr const int *e = &a[1]; // { dg-error "non-zero array subscript '1' is used with array 'a' of type 'const int \\\[\\\]' with unknown bounds" } 10 constexpr const int *e = &a[1]; // { dg-error "nonzero array subscript '1' is used with array 'a' of type 'const int \\\[\\\]' with unknown bounds" }
11 constexpr const int *f = &b[0]; 11 constexpr const int *f = &b[0];
12 constexpr const int *f2 = b; 12 constexpr const int *f2 = b;
13 constexpr const int *g = &b[5]; 13 constexpr const int *g = &b[5];
14 constexpr const int *h = &b[6]; // { dg-error "array subscript value '6' is outside the bounds of array 'b' of type 'const int \\\[5\\\]'" } 14 constexpr const int *h = &b[6]; // { dg-error "array subscript value '6' is outside the bounds of array 'b' of type 'const int \\\[5\\\]'" }
15 constexpr const int *i = &c[0]; 15 constexpr const int *i = &c[0];
28 static_assert (m == m2, ""); 28 static_assert (m == m2, "");
29 } 29 }
30 30
31 constexpr const int *m = &l[0]; 31 constexpr const int *m = &l[0];
32 constexpr const int *m2 = l; 32 constexpr const int *m2 = l;
33 constexpr const int *n = &l[1]; // { dg-error "non-zero array subscript '1' is used with array 'l' of type 'const int \\\[\\\]' with unknown bounds" } 33 constexpr const int *n = &l[1]; // { dg-error "nonzero array subscript '1' is used with array 'l' of type 'const int \\\[\\\]' with unknown bounds" }
34 static_assert (d == d2 && f == f2 && i == i2 && m == m2, ""); 34 static_assert (d == d2 && f == f2 && i == i2 && m == m2, "");
35 const int o[] = { 1, 2 }; 35 const int o[] = { 1, 2 };
36 constexpr const int *p = &o[0]; 36 constexpr const int *p = &o[0];
37 constexpr const int *p2 = o; 37 constexpr const int *p2 = o;
38 constexpr const int *q = &o[2]; 38 constexpr const int *q = &o[2];
39 constexpr const int *r = &o[3]; // { dg-error "array subscript value '3' is outside the bounds of array 'o' of type 'const int \\\[2\\\]'" } 39 constexpr const int *r = &o[3]; // { dg-error "array subscript value '3' is outside the bounds of array 'o' of type 'const int \\\[2\\\]'" }
40 struct S { char a; char b[]; } s; 40 struct S { char a; char b[]; } s;
41 constexpr const char *t = &s.b[0]; 41 constexpr const char *t = &s.b[0];
42 constexpr const char *t2 = s.b; 42 constexpr const char *t2 = s.b;
43 constexpr const char *u = &s.b[1]; // { dg-error "non-zero array subscript '1' is used with array of type 'char \\\[\\\]' with unknown bounds" } 43 constexpr const char *u = &s.b[1]; // { dg-error "nonzero array subscript '1' is used with array of type 'char \\\[\\\]' with unknown bounds" }
44 struct V { int a; }; 44 struct V { int a; };
45 extern V v[]; 45 extern V v[];
46 constexpr V *w = &v[0]; 46 constexpr V *w = &v[0];
47 constexpr V *w2 = v; 47 constexpr V *w2 = v;
48 constexpr int *x = &v[0].a; 48 constexpr int *x = &v[0].a;