view gcc/testsuite/c-c++-common/memset-array.c @ 19:2b5abeee2509 default tip

update gcc11
author anatofuz
date Mon, 25 May 2020 07:50:57 +0900
parents 04ced10e8804
children
line wrap: on
line source

/* { dg-do compile } */
/* { dg-options "-Wmemset-elt-size" } */
enum a {
  a_1,
  a_2,
  a_n
};
int t1[20];
int t2[a_n];

struct s
{
  int t[20];
};

void foo (struct s *s)
{
  __builtin_memset (t1, 0, 20); /* { dg-warning "element size" } */
  __builtin_memset (t2, 0, a_n); /* { dg-warning "element size" } */
  __builtin_memset (s->t, 0, 20); /* { dg-warning "element size" } */
}

char u1[20];
char u2[a_n];

struct s2
{
  char u[20];
};

void bar (struct s2 *s)
{
  __builtin_memset (u1, 0, 20);
  __builtin_memset (u2, 0, a_n);
  __builtin_memset (s->u, 0, 20);
}