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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [gcc.dg/] [pr47917.c] - Blame information for rev 801

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

Line No. Rev Author Line
1 689 jeremybenn
/* PR middle-end/47917 */
2
/* { dg-do compile } */
3
/* { dg-options "-O2 -fdump-tree-optimized" } */
4
 
5
extern int snprintf (char *, __SIZE_TYPE__, const char *, ...);
6
extern int memcmp (const void *, const void *, __SIZE_TYPE__);
7
extern void abort (void);
8
 
9
char buf1[6], buf2[6], buf3[4], buf4[4];
10
int i;
11
 
12
int
13
foo (void)
14
{
15
  int ret = snprintf (buf1, sizeof buf1, "abcde");
16
  ret += snprintf (buf2, sizeof buf2, "abcdef") * 16;
17
  ret += snprintf (buf3, sizeof buf3, "%s", i++ < 6 ? "abc" : "def") * 256;
18
  ret += snprintf (buf4, sizeof buf4, "%s", i++ > 10 ? "abcde" : "defgh") * 4096;
19
  return ret;
20
}
21
 
22
int
23
main (void)
24
{
25
  if (foo () != 5 + 6 * 16 + 3 * 256 + 5 * 4096)
26
    abort ();
27
  if (memcmp (buf1, "abcde", 6) != 0
28
      || memcmp (buf2, "abcde", 6) != 0
29
      || memcmp (buf3, "abc", 4) != 0
30
      || memcmp (buf4, "def", 4) != 0
31
      || i != 2)
32
    abort ();
33
  return 0;
34
}
35
 
36
/* { dg-final { scan-tree-dump-times "snprintf" 2 "optimized" } } */
37
/* { dg-final { scan-tree-dump-times "sprintf" 0 "optimized" } } */
38
/* { dg-final { cleanup-tree-dump "optimized" } } */

powered by: WebSVN 2.1.0

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