1 /* Copyright (C) 2000 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);
10 /* Declare this without args because that's what gcc does internally.
11 We want to make sure it works without a helpful prototype from us.
12 If stdio.h provides one, that is okay. */
17 FILE *s_array
[] = {stdout
, NULL
}, **s_ptr
= s_array
;
18 const char *const s1
= "hello world";
22 fputs ("bye", *s_ptr
);
25 fputs (s1
+10, *s_ptr
);
26 fputs (s1
+11, *s_ptr
);
28 /* Check side-effects when transforming fputs -> NOP. */
30 if (s_ptr
!= s_array
+1 || *s_ptr
!= 0)
33 /* Check side-effects when transforming fputs -> fputc. */
35 fputs ("\n", *s_ptr
++);
36 if (s_ptr
!= s_array
+1 || *s_ptr
!= 0)
39 /* Check side-effects when transforming fputs -> fwrite. */
41 fputs ("hello\n", *s_ptr
++);
42 if (s_ptr
!= s_array
+1 || *s_ptr
!= 0)
45 /* Test at least one instance of the __builtin_ style. We do this
46 to ensure that it works and that the prototype is correct. */
48 __builtin_fputs ("", *s_ptr
);
54 /* When optimizing, all the above cases should be transformed into
55 something else. So any remaining calls to the original function
58 fputs(const char *string
, FILE *stream
)