OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [gcc.dg/] [builtin-strncat-chk-1.c] - Blame information for rev 754

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 689 jeremybenn
/* Test whether buffer overflow warnings for __strncat_chk builtin
2
   are emitted properly.  */
3
/* { dg-do compile } */
4
/* { dg-options "-O2 -std=gnu99" } */
5
 
6
extern void abort (void);
7
 
8
#include "../gcc.c-torture/execute/builtins/chk.h"
9
 
10
char buf1[20];
11
char *q;
12
 
13
void
14
test (int arg, ...)
15
{
16
  char *p = &buf1[10];
17
 
18
  *p = 0;
19
  strncat (p, "abcdefg", 9);
20
  *p = 0;
21
  strncat (p, "abcdefghi", 9);
22
  *p = 0;
23
  strncat (p, "abcdefghij", 9);
24
  *p = 0;
25
  strncat (p, "abcdefghi", 10);
26
  *p = 0;
27
  strncat (p, "abcdefghij", 10); /* { dg-warning "will always overflow" } */
28
  *p = 0;
29
  strncat (p, "abcdefgh", 11);
30
  *p = 0;
31
  strncat (p, "abcdefghijkl", 11); /* { dg-warning "will always overflow" } */
32
  *p = 0;
33
  strncat (p, q, 9);
34
  *p = 0;
35
  strncat (p, q, 10); /* { dg-warning "might overflow" } */
36
  *p = 0;
37
  strncat (p, q, 11); /* { dg-warning "might overflow" } */
38
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.