(root)/
gcc-13.2.0/
gcc/
testsuite/
gcc.dg/
Wrestrict-12.c
       1  /* PR tree-optimization/83456 - -Wrestrict false positive on
       2     a non-overlapping memcpy in an inline function
       3     { dg-do compile }
       4     { dg-options "-O2 -Wrestrict -ftrack-macro-expansion=0" }  */
       5  
       6  extern void* memcpy (void*, const void*, __SIZE_TYPE__);
       7  
       8  /* Test case from comment #0.  */
       9  
      10  inline void pr83456_comment0 (void *d, void *s, unsigned N)
      11  {
      12    if (s != d)
      13      memcpy (d, s, N);
      14  }
      15  
      16  void call_pr83456_comment0 (void* src)
      17  {
      18    pr83456_comment0 (src, src, 1);
      19  }
      20  
      21  
      22  /* Test case from comment #1.  */
      23  
      24  char a[4];
      25  
      26  void pr83456_comment1 (unsigned n)
      27  {
      28    for (int i = 0; i < 1; i++)
      29      {
      30        if (!i)
      31  	continue;
      32  
      33        memcpy (a, a, n);
      34      }
      35  }
      36  
      37  /* Test case from comment #2.  */
      38  
      39  struct netdevice {
      40    void *priv;
      41  };
      42  
      43  struct ip_tunnel {
      44    struct netdevice *dev;
      45    int ip6rd[3];
      46  };
      47  
      48  struct sit_net {
      49    struct netdevice *fb_tunnel_dev;
      50  };
      51  
      52  void ipip6_tunnel_clone_6rd (struct netdevice *dev, struct sit_net *sitn)
      53  {
      54    struct ip_tunnel *t = dev->priv;
      55    if (t->dev == sitn->fb_tunnel_dev)
      56      return;
      57  
      58    struct ip_tunnel *t0 = sitn->fb_tunnel_dev->priv;
      59    memcpy(&t->ip6rd, &t0->ip6rd, sizeof(t->ip6rd));
      60  }
      61  
      62  void sit_init_net (struct sit_net *sitn, struct netdevice *fb_tunnel_dev)
      63  {
      64    sitn->fb_tunnel_dev = fb_tunnel_dev;
      65    ipip6_tunnel_clone_6rd (sitn->fb_tunnel_dev, sitn);
      66  }