1 /* Copyright (C) 2000, 2001 Free Software Foundation.
3 Ensure all expected transformations of builtin fputs occur and that
4 we honor side effects in the stream argument.
6 Written by Kaveh R. Ghazi, 10/30/2000. */
9 extern void abort(void);
16 FILE *s_array
[] = {stdout
, NULL
}, **s_ptr
= s_array
;
17 const char *const s1
= "hello world";
21 fputs ("bye", *s_ptr
);
24 fputs (s1
+10, *s_ptr
);
25 fputs (s1
+11, *s_ptr
);
27 /* Check side-effects when transforming fputs -> NOP. */
29 if (s_ptr
!= s_array
+1 || *s_ptr
!= 0)
32 /* Check side-effects when transforming fputs -> fputc. */
34 fputs ("\n", *s_ptr
++);
35 if (s_ptr
!= s_array
+1 || *s_ptr
!= 0)
38 /* Check side-effects when transforming fputs -> fwrite. */
40 fputs ("hello\n", *s_ptr
++);
41 if (s_ptr
!= s_array
+1 || *s_ptr
!= 0)
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. */
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
);
57 /* Check side-effects in conditional expression. */
59 fputs (i
++ ? "f" : "x", *s_ptr
++);
60 if (s_ptr
!= s_array
+1 || *s_ptr
!= 0 || i
!= 1)
62 fputs (--i
? "\n" : "\n", *--s_ptr
);
63 if (s_ptr
!= s_array
|| i
!= 0)