Merge from trunk
[official-gcc.git] / gcc / testsuite / c-c++-common / pr58346-1.c
blob371fcf48454d151f1bdbdd7b31d6a0b0a8d5a707
1 /* PR c/58346 */
2 /* { dg-do compile } */
4 struct U {
5 #ifdef __cplusplus
6 char a[0];
7 #endif
8 };
9 static struct U b[6];
10 static struct U *u1, *u2;
12 int
13 foo (struct U *p, struct U *q)
15 return q - p; /* { dg-error "arithmetic on pointer to an empty aggregate" } */
18 void
19 bar (void)
21 __PTRDIFF_TYPE__ d = u1 - u2; /* { dg-error "arithmetic on pointer to an empty aggregate" } */
22 __asm volatile ("" : "+g" (d));
23 foo (&b[0], &b[4]);