OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 297 jeremybenn
/* Copyright (C) 2001  Free Software Foundation.
2
 
3
   Ensure all expected transformations of builtin fprintf occur and
4
   that we honor side effects in the arguments.
5
 
6
   Written by Kaveh R. Ghazi, 1/7/2001.  */
7
 
8
#include <stdio.h>
9
extern int fprintf_unlocked (FILE *, const char *, ...);
10
extern void abort(void);
11
 
12
void
13
main_test (void)
14
{
15
  FILE *s_array[] = {stdout, NULL}, **s_ptr = s_array;
16
  const char *const s1 = "hello world";
17
  const char *const s2[] = { s1, 0 }, *const*s3;
18
 
19
  fprintf (*s_ptr, "");
20
  fprintf (*s_ptr, "%s", "");
21
  fprintf (*s_ptr, "%s", "hello");
22
  fprintf (*s_ptr, "%s", "\n");
23
  fprintf (*s_ptr, "%s", *s2);
24
  s3 = s2;
25
  fprintf (*s_ptr, "%s", *s3++);
26
  if (s3 != s2+1 || *s3 != 0)
27
    abort();
28
  s3 = s2;
29
  fprintf (*s_ptr++, "%s", *s3++);
30
  if (s3 != s2+1 || *s3 != 0 || s_ptr != s_array+1 || *s_ptr != 0)
31
    abort();
32
 
33
  s_ptr = s_array;
34
  fprintf (*s_ptr, "%c", '\n');
35
  fprintf (*s_ptr, "%c", **s2);
36
  s3 = s2;
37
  fprintf (*s_ptr, "%c", **s3++);
38
  if (s3 != s2+1 || *s3 != 0)
39
    abort();
40
  s3 = s2;
41
  fprintf (*s_ptr++, "%c", **s3++);
42
  if (s3 != s2+1 || *s3 != 0 || s_ptr != s_array+1 || *s_ptr != 0)
43
    abort();
44
 
45
  s_ptr = s_array;
46
  fprintf (*s_ptr++, "hello world");
47
  if (s_ptr != s_array+1 || *s_ptr != 0)
48
    abort();
49
  s_ptr = s_array;
50
  fprintf (*s_ptr, "\n");
51
 
52
  /* Test at least one instance of the __builtin_ style.  We do this
53
     to ensure that it works and that the prototype is correct.  */
54
  __builtin_fprintf (*s_ptr, "%s", "hello world\n");
55
  /* Check the unlocked style, these evaluate to nothing to avoid
56
     problems on systems without the unlocked functions.  */
57
  fprintf_unlocked (*s_ptr, "");
58
  __builtin_fprintf_unlocked (*s_ptr, "");
59
  fprintf_unlocked (*s_ptr, "%s", "");
60
  __builtin_fprintf_unlocked (*s_ptr, "%s", "");
61
}

powered by: WebSVN 2.1.0

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