1 /* Test -Wsizeof-pointer-div warnings.  */
2 /* { dg-do compile } */
3 /* { dg-options "-Wall" } */
4 
5 int
f1(int * array)6 f1 (int *array)
7 {
8   int i;
9   i = sizeof array / sizeof *array;		/* { dg-warning "does not compute the number of array elements" } */
10   i += sizeof array / sizeof array[0];		/* { dg-warning "does not compute the number of array elements" } */
11   i += sizeof(array) / sizeof(*array);		/* { dg-warning "does not compute the number of array elements" } */
12   i += sizeof(array) / sizeof(array[0]);	/* { dg-warning "does not compute the number of array elements" } */
13   i += (sizeof(array)) / (sizeof(array[0]));	/* { dg-warning "does not compute the number of array elements" } */
14   i += sizeof(array) / sizeof(int);		/* { dg-warning "does not compute the number of array elements" } */
15   i += sizeof(array) / sizeof(char);
16   i += sizeof(*array) / sizeof(char);
17   i += sizeof(array[0]) / sizeof(char);
18   return i;
19 }
20 
21 int
f2(void)22 f2 (void)
23 {
24   int array[10];
25   int i;
26   i = sizeof array / sizeof *array;
27   i += sizeof array / sizeof array[0];
28   i += sizeof(array) / sizeof(*array);
29   i += sizeof(array) / sizeof(array[0]);
30   i += (sizeof(array)) / (sizeof(array[0]));
31   i += sizeof(array) / sizeof(int);
32   i += sizeof(array) / sizeof(char);
33   i += sizeof(*array) / sizeof(char);
34   i += sizeof(array[0]) / sizeof(char);
35   return i;
36 }
37 
38 int
f3(int a[])39 f3 (int a[])
40 {
41   return sizeof a / sizeof *a;			/* { dg-warning "Wsizeof-array-argument" } */
42 }
43