1 /* Copyright (C) 2001 Free Software Foundation.
3 Ensure all expected transformations of builtin fprintf occur and
4 that we honor side effects in the arguments.
6 Written by Kaveh R. Ghazi, 1/7/2001. */
9 extern int fprintf_unlocked (FILE *, const char *, ...);
10 extern void abort(void);
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
;
20 fprintf (*s_ptr
, "%s", "");
21 fprintf (*s_ptr
, "%s", "hello");
22 fprintf (*s_ptr
, "%s", "\n");
23 fprintf (*s_ptr
, "%s", *s2
);
25 fprintf (*s_ptr
, "%s", *s3
++);
26 if (s3
!= s2
+1 || *s3
!= 0)
29 fprintf (*s_ptr
++, "%s", *s3
++);
30 if (s3
!= s2
+1 || *s3
!= 0 || s_ptr
!= s_array
+1 || *s_ptr
!= 0)
34 fprintf (*s_ptr
, "%c", '\n');
35 fprintf (*s_ptr
, "%c", **s2
);
37 fprintf (*s_ptr
, "%c", **s3
++);
38 if (s3
!= s2
+1 || *s3
!= 0)
41 fprintf (*s_ptr
++, "%c", **s3
++);
42 if (s3
!= s2
+1 || *s3
!= 0 || s_ptr
!= s_array
+1 || *s_ptr
!= 0)
46 fprintf (*s_ptr
++, "hello world");
47 if (s_ptr
!= s_array
+1 || *s_ptr
!= 0)
50 fprintf (*s_ptr
, "\n");
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", "");