annotate gcc/testsuite/gcc.dg/memset-1.c @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents 04ced10e8804
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 /* { dg-do compile } */
kono
parents:
diff changeset
2 /* { dg-options "-O2" } */
kono
parents:
diff changeset
3
kono
parents:
diff changeset
4 typedef __SIZE_TYPE__ size_t;
kono
parents:
diff changeset
5
kono
parents:
diff changeset
6 extern void warn_memset_zero_len (void)
kono
parents:
diff changeset
7 __attribute__((__warning__ ("memset used with constant zero length parameter;"
kono
parents:
diff changeset
8 " this could be due to transposed parameters")));
kono
parents:
diff changeset
9
kono
parents:
diff changeset
10 extern inline __attribute__((gnu_inline, always_inline, artificial)) void *
kono
parents:
diff changeset
11 memset (void *dest, int ch, size_t len)
kono
parents:
diff changeset
12 {
kono
parents:
diff changeset
13 if (__builtin_constant_p (len) && len == 0)
kono
parents:
diff changeset
14 {
kono
parents:
diff changeset
15 warn_memset_zero_len (); /* { dg-warning "memset used with constant zero" } */
kono
parents:
diff changeset
16 return dest;
kono
parents:
diff changeset
17 }
kono
parents:
diff changeset
18 return __builtin_memset (dest, ch, len);
kono
parents:
diff changeset
19 }
kono
parents:
diff changeset
20
kono
parents:
diff changeset
21 char buf[10];
kono
parents:
diff changeset
22
kono
parents:
diff changeset
23 int
kono
parents:
diff changeset
24 main (void)
kono
parents:
diff changeset
25 {
kono
parents:
diff changeset
26 memset (buf, sizeof (buf), 0);
kono
parents:
diff changeset
27 return 0;
kono
parents:
diff changeset
28 }