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/] [vprintf-chk-1.c] - Blame information for rev 301

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

Line No. Rev Author Line
1 297 jeremybenn
#ifndef test
2
#include <stdio.h>
3
#include <stdlib.h>
4
#include <stdarg.h>
5
 
6
volatile int should_optimize;
7
 
8
int
9
__attribute__((noinline))
10
__vprintf_chk (int flag, const char *fmt, va_list ap)
11
{
12
#ifdef __OPTIMIZE__
13
  if (should_optimize)
14
    abort ();
15
#endif
16
  should_optimize = 1;
17
  return vprintf (fmt, ap);
18
}
19
 
20
void
21
inner (int x, ...)
22
{
23
  va_list ap, ap2;
24
  va_start (ap, x);
25
  va_start (ap2, x);
26
 
27
  switch (x)
28
    {
29
#define test(n, ret, opt, fmt, args) \
30
    case n:                                     \
31
      should_optimize = opt;                    \
32
      __vprintf_chk (1, fmt, ap);               \
33
      if (! should_optimize)                    \
34
        abort ();                               \
35
      should_optimize = 0;                       \
36
      if (__vprintf_chk (1, fmt, ap2) != ret)   \
37
        abort ();                               \
38
      if (! should_optimize)                    \
39
        abort ();                               \
40
      break;
41
#include "vprintf-chk-1.c"
42
#undef test
43
    default:
44
      abort ();
45
    }
46
 
47
  va_end (ap);
48
  va_end (ap2);
49
}
50
 
51
int
52
main (void)
53
{
54
#define test(n, ret, opt, fmt, args) \
55
  inner args;
56
#include "vprintf-chk-1.c"
57
#undef test
58
  return 0;
59
}
60
 
61
#else
62
  test (0, 5, 0, "hello", (0));
63
  test (1, 6, 1, "hello\n", (1));
64
  test (2, 1, 1, "a", (2));
65
  test (3, 0, 1, "", (3));
66
  test (4, 5, 0, "%s", (4, "hello"));
67
  test (5, 6, 0, "%s", (5, "hello\n"));
68
  test (6, 1, 0, "%s", (6, "a"));
69
  test (7, 0, 0, "%s", (7, ""));
70
  test (8, 1, 0, "%c", (8, 'x'));
71
  test (9, 7, 0, "%s\n", (9, "hello\n"));
72
  test (10, 2, 0, "%d\n", (10, 0));
73
#endif

powered by: WebSVN 2.1.0

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