summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/Wstringop-overflow-13.c
blob: bd513151cea0ec74fbb0ed51dd148055876b30a8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/* PR middle-end/89957 - ICE calling strnlen with an int128_t bound
   in a known range
   PR middle-end/89911 - ICE on a call with no arguments to strnlen
   declared with no prototype
   { dg-do compile }
   { dg-options "-O2 -Wall" } */

typedef __SIZE_TYPE__ size_t;

extern size_t strnlen ();

size_t f0 (void)
{
  return strnlen ();          /* { dg-warning "too few arguments to built-in function 'strnlen'" } */
}

size_t f1 (const char *s)
{
  return strnlen (s);         /* { dg-warning "too few arguments to built-in function 'strnlen'" } */
}

size_t f2 (const char *s)
{
  return strnlen (s, s);      /* { dg-warning "\\\[-Wint-conversion]" } */
}

#if __SIZEOF_INT128__ == 16

size_t fi128 (const char *s, __int128_t n)
{
 if (n < 0)
   n = 0;

 /* PR middle-end/89957 */
 return strnlen (s, n);       /* { dg-warning "\\\[-Wbuiltin-declaration-mismatch]" "int128" { target int128 } } */
}

#endif

/* { dg-prune-output "\\\[-Wint-conversion]" } */