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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.5.1/] [gcc/] [testsuite/] [gcc.c-torture/] [execute/] [fprintf-chk-1.c] - Blame information for rev 414

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

Line No. Rev Author Line
1 297 jeremybenn
#include <stdio.h>
2
#include <stdlib.h>
3
#include <stdarg.h>
4
 
5
volatile int should_optimize;
6
 
7
int
8
__attribute__((noinline))
9
__fprintf_chk (FILE *f, int flag, const char *fmt, ...)
10
{
11
  va_list ap;
12
  int ret;
13
#ifdef __OPTIMIZE__
14
  if (should_optimize)
15
    abort ();
16
#endif
17
  should_optimize = 1;
18
  va_start (ap, fmt);
19
  ret = vfprintf (f, fmt, ap);
20
  va_end (ap);
21
  return ret;
22
}
23
 
24
int
25
main (void)
26
{
27
#define test(ret, opt, args...) \
28
  should_optimize = opt;                        \
29
  __fprintf_chk (stdout, 1, args);              \
30
  if (!should_optimize)                         \
31
    abort ();                                   \
32
  should_optimize = 0;                           \
33
  if (__fprintf_chk (stdout, 1, args) != ret)   \
34
    abort ();                                   \
35
  if (!should_optimize)                         \
36
    abort ();
37
  test (5, 1, "hello");
38
  test (6, 1, "hello\n");
39
  test (1, 1, "a");
40
  test (0, 1, "");
41
  test (5, 1, "%s", "hello");
42
  test (6, 1, "%s", "hello\n");
43
  test (1, 1, "%s", "a");
44
  test (0, 1, "%s", "");
45
  test (1, 1, "%c", 'x');
46
  test (7, 0, "%s\n", "hello\n");
47
  test (2, 0, "%d\n", 0);
48
  return 0;
49
}

powered by: WebSVN 2.1.0

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