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

Subversion Repositories openrisc

[/] [openrisc/] [tags/] [gnu-src/] [gcc-4.5.1/] [gcc-4.5.1-or32-1.0rc1/] [gcc/] [testsuite/] [gcc.c-torture/] [execute/] [fprintf-chk-1.c] - Diff between revs 297 and 338

Only display areas with differences | Details | Blame | View Log

Rev 297 Rev 338
#include <stdio.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdlib.h>
#include <stdarg.h>
#include <stdarg.h>
 
 
volatile int should_optimize;
volatile int should_optimize;
 
 
int
int
__attribute__((noinline))
__attribute__((noinline))
__fprintf_chk (FILE *f, int flag, const char *fmt, ...)
__fprintf_chk (FILE *f, int flag, const char *fmt, ...)
{
{
  va_list ap;
  va_list ap;
  int ret;
  int ret;
#ifdef __OPTIMIZE__
#ifdef __OPTIMIZE__
  if (should_optimize)
  if (should_optimize)
    abort ();
    abort ();
#endif
#endif
  should_optimize = 1;
  should_optimize = 1;
  va_start (ap, fmt);
  va_start (ap, fmt);
  ret = vfprintf (f, fmt, ap);
  ret = vfprintf (f, fmt, ap);
  va_end (ap);
  va_end (ap);
  return ret;
  return ret;
}
}
 
 
int
int
main (void)
main (void)
{
{
#define test(ret, opt, args...) \
#define test(ret, opt, args...) \
  should_optimize = opt;                        \
  should_optimize = opt;                        \
  __fprintf_chk (stdout, 1, args);              \
  __fprintf_chk (stdout, 1, args);              \
  if (!should_optimize)                         \
  if (!should_optimize)                         \
    abort ();                                   \
    abort ();                                   \
  should_optimize = 0;                           \
  should_optimize = 0;                           \
  if (__fprintf_chk (stdout, 1, args) != ret)   \
  if (__fprintf_chk (stdout, 1, args) != ret)   \
    abort ();                                   \
    abort ();                                   \
  if (!should_optimize)                         \
  if (!should_optimize)                         \
    abort ();
    abort ();
  test (5, 1, "hello");
  test (5, 1, "hello");
  test (6, 1, "hello\n");
  test (6, 1, "hello\n");
  test (1, 1, "a");
  test (1, 1, "a");
  test (0, 1, "");
  test (0, 1, "");
  test (5, 1, "%s", "hello");
  test (5, 1, "%s", "hello");
  test (6, 1, "%s", "hello\n");
  test (6, 1, "%s", "hello\n");
  test (1, 1, "%s", "a");
  test (1, 1, "%s", "a");
  test (0, 1, "%s", "");
  test (0, 1, "%s", "");
  test (1, 1, "%c", 'x');
  test (1, 1, "%c", 'x');
  test (7, 0, "%s\n", "hello\n");
  test (7, 0, "%s\n", "hello\n");
  test (2, 0, "%d\n", 0);
  test (2, 0, "%d\n", 0);
  return 0;
  return 0;
}
}
 
 

powered by: WebSVN 2.1.0

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