(root)/
gcc-13.2.0/
gcc/
testsuite/
c-c++-common/
Wsizeof-array-div1.c
       1  /* PR c++/91741 */
       2  /* { dg-do compile } */
       3  /* { dg-options "-Wall" } */
       4  
       5  typedef int T;
       6  
       7  int
       8  fn (int ap[])
       9  {
      10    int arr[10];
      11    int *arr2[10];
      12    int *p = &arr[0];
      13    int r = 0;
      14  
      15    r += sizeof (arr) / sizeof (*arr);
      16    r += sizeof (arr) / sizeof (p); /* { dg-warning "expression does not compute" "" { target { ! ilp32 } } } */
      17    r += sizeof (arr) / sizeof p; /* { dg-warning "expression does not compute" "" { target { ! ilp32 } } } */
      18    r += sizeof (arr) / (sizeof p);
      19    r += sizeof (arr) / (sizeof (p));
      20    r += sizeof (arr2) / sizeof p;
      21    r += sizeof (arr2) / sizeof (int); /* { dg-warning "expression does not compute" "" { target { ! ilp32 } } } */
      22    r += sizeof (arr2) / sizeof (int *);
      23    r += sizeof (arr2) / sizeof (short *);
      24    r += sizeof (arr) / sizeof (int);
      25    r += sizeof (arr) / sizeof (unsigned int);
      26    r += sizeof (arr) / sizeof (T);
      27    r += sizeof (arr) / sizeof (short); /* { dg-warning "expression does not compute" } */
      28    r += sizeof (arr) / (sizeof (short));
      29  
      30    r += sizeof (ap) / sizeof (char); /* { dg-warning ".sizeof. on array function parameter" } */
      31  
      32    const char arr3[] = "foo";
      33    r += sizeof (arr3) / sizeof(char);
      34    r += sizeof (arr3) / sizeof(int);
      35    r += sizeof (arr3) / sizeof (*arr3);
      36  
      37    int arr4[5][5];
      38    r += sizeof (arr4) / sizeof (arr4[0]);
      39    r += sizeof (arr4) / sizeof (*arr4);
      40    r += sizeof (arr4) / sizeof (**arr4);
      41    r += sizeof (arr4) / sizeof (int *);
      42    r += sizeof (arr4) / sizeof (int);
      43    r += sizeof (arr4) / sizeof (short int);
      44  
      45    T arr5[10];
      46    r += sizeof (arr5) / sizeof (T);
      47    r += sizeof (arr5) / sizeof (int);
      48    r += sizeof (arr5) / sizeof (short); /* { dg-warning "expression does not compute" } */
      49  
      50    double arr6[10];
      51    r += sizeof (arr6) / sizeof (double);
      52    r += sizeof (arr6) / sizeof (float); /* { dg-warning "expression does not compute" } */
      53    r += sizeof (arr6) / sizeof (*arr6);
      54  
      55    return r;
      56  }