(root)/
gcc-13.2.0/
gcc/
testsuite/
gcc.dg/
Wnonnull-3.c
       1  /* PR middle-end/80936 - bcmp, bcopy, and bzero not declared nonnull
       2     Verify that with optimization, -Wnonnull is issued for calls with
       3     non-constant arguments determined to be null.
       4     { dg-do compile }
       5     { dg-options "-O2 -Wall" } */
       6  
       7  #define NOIPA __attribute__ ((noipa))
       8  
       9  NOIPA void zero0 (void *p, unsigned n)
      10  {
      11    if (p == 0)
      12      __builtin_memset (p, 0, n);         // { dg-warning "\\\[-Wnonnull]" }
      13  }
      14  
      15  NOIPA void zero1 (void *p, unsigned n)
      16  {
      17    if (p == 0)
      18      __builtin_bzero (p, n);             // { dg-warning "\\\[-Wnonnull]" }
      19  }
      20  
      21  NOIPA void copy0 (void *p, const void *q, unsigned n)
      22  {
      23    if (p == 0)
      24      __builtin_memcpy (p, q, n);         // { dg-warning "\\\[-Wnonnull]" }
      25  }
      26  
      27  NOIPA void copy1 (void *p, const void *q, unsigned n)
      28  {
      29    if (q == 0)
      30      __builtin_memcpy (p, q, n);         // { dg-warning "\\\[-Wnonnull]" }
      31  }
      32  
      33  NOIPA void copy2 (void *p, const void *q, unsigned n)
      34  {
      35    if (p == 0)
      36      __builtin_bcopy (q, p, n);          // { dg-warning "\\\[-Wnonnull]" }
      37  }
      38  
      39  NOIPA void copy3 (void *p, const void *q, unsigned n)
      40  {
      41    if (q == 0)
      42      __builtin_bcopy (q, p, n);          // { dg-warning "\\\[-Wnonnull]" }
      43  }
      44  
      45  NOIPA int cmp0 (const void *p, const void *q, unsigned n)
      46  {
      47    if (p == 0)
      48      return __builtin_memcmp (p, q, n);  // { dg-warning "\\\[-Wnonnull]" }
      49    return 0;
      50  }
      51  
      52  NOIPA int cmp1 (const void *p, const void *q, unsigned n)
      53  {
      54    if (q == 0)
      55      return __builtin_memcmp (p, q, n);  // { dg-warning "\\\[-Wnonnull]" }
      56    return 0;
      57  }
      58  
      59  NOIPA int cmp2 (const void *p, const void *q, unsigned n)
      60  {
      61    if (p == 0)
      62      return __builtin_bcmp (p, q, n);    // { dg-warning "\\\[-Wnonnull]" }
      63    return 0;
      64  }
      65  
      66  NOIPA int cmp3 (const void *p, const void *q, unsigned n)
      67  {
      68    if (q == 0)
      69      return __builtin_bcmp (p, q, n);    // { dg-warning "\\\[-Wnonnull]" }
      70    return 0;
      71  }