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/] [builtins/] [fputs.c] - Blame information for rev 338

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 297 jeremybenn
/* Copyright (C) 2000, 2001  Free Software Foundation.
2
 
3
   Ensure all expected transformations of builtin fputs occur and that
4
   we honor side effects in the stream argument.
5
 
6
   Written by Kaveh R. Ghazi, 10/30/2000.  */
7
 
8
#include <stdio.h>
9
extern void abort(void);
10
 
11
int i;
12
 
13
void
14
main_test(void)
15
{
16
  FILE *s_array[] = {stdout, NULL}, **s_ptr = s_array;
17
  const char *const s1 = "hello world";
18
 
19
  fputs ("", *s_ptr);
20
  fputs ("\n", *s_ptr);
21
  fputs ("bye", *s_ptr);
22
  fputs (s1, *s_ptr);
23
  fputs (s1+5, *s_ptr);
24
  fputs (s1+10, *s_ptr);
25
  fputs (s1+11, *s_ptr);
26
 
27
  /* Check side-effects when transforming fputs -> NOP.  */
28
  fputs ("", *s_ptr++);
29
  if (s_ptr != s_array+1 || *s_ptr != 0)
30
    abort();
31
 
32
  /* Check side-effects when transforming fputs -> fputc.  */
33
  s_ptr = s_array;
34
  fputs ("\n", *s_ptr++);
35
  if (s_ptr != s_array+1 || *s_ptr != 0)
36
    abort();
37
 
38
  /* Check side-effects when transforming fputs -> fwrite.  */
39
  s_ptr = s_array;
40
  fputs ("hello\n", *s_ptr++);
41
  if (s_ptr != s_array+1 || *s_ptr != 0)
42
    abort();
43
 
44
  /* Test at least one instance of the __builtin_ style.  We do this
45
     to ensure that it works and that the prototype is correct.  */
46
  s_ptr = s_array;
47
  __builtin_fputs ("", *s_ptr);
48
  /* These builtin stubs are called by __builtin_fputs, ensure their
49
     prototypes are set correctly too.  */
50
  __builtin_fputc ('\n', *s_ptr);
51
  __builtin_fwrite ("hello\n", 1, 6, *s_ptr);
52
  /* Check the unlocked style, these evaluate to nothing to avoid
53
     problems on systems without the unlocked functions.  */
54
  fputs_unlocked ("", *s_ptr);
55
  __builtin_fputs_unlocked ("", *s_ptr);
56
 
57
  /* Check side-effects in conditional expression.  */
58
  s_ptr = s_array;
59
  fputs (i++ ? "f" : "x", *s_ptr++);
60
  if (s_ptr != s_array+1 || *s_ptr != 0 || i != 1)
61
    abort();
62
  fputs (--i ? "\n" : "\n", *--s_ptr);
63
  if (s_ptr != s_array || i != 0)
64
    abort();
65
}

powered by: WebSVN 2.1.0

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