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 (FILE *, const char *, ...);
10 extern void abort(void);
14 FILE *s_array[] = {stdout, NULL}, **s_ptr = s_array;
15 const char *const s1 = "hello world";
16 const char *const s2[] = { s1, 0 }, *const*s3;
18 fprintf (*s_ptr, "%s", "hello");
19 fprintf (*s_ptr, "%s", "\n");
20 fprintf (*s_ptr, "%s", *s2);
22 fprintf (*s_ptr, "%s", *s3++);
23 if (s3 != s2+1 || *s3 != 0)
26 fprintf (*s_ptr++, "%s", *s3++);
27 if (s3 != s2+1 || *s3 != 0 || s_ptr != s_array+1 || *s_ptr != 0)
31 fprintf (*s_ptr, "%c", '\n');
32 fprintf (*s_ptr, "%c", **s2);
34 fprintf (*s_ptr, "%c", **s3++);
35 if (s3 != s2+1 || *s3 != 0)
38 fprintf (*s_ptr++, "%c", **s3++);
39 if (s3 != s2+1 || *s3 != 0 || s_ptr != s_array+1 || *s_ptr != 0)
43 fprintf (*s_ptr++, "hello world");
44 if (s_ptr != s_array+1 || *s_ptr != 0)
47 fprintf (*s_ptr, "\n");
49 /* Test at least one instance of the __builtin_ style. We do this
50 to ensure that it works and that the prototype is correct. */
51 __builtin_fprintf (*s_ptr, "%s", "hello world\n");
57 /* When optimizing, all the above cases should be transformed into
58 something else. So any remaining calls to the original function
60 __attribute__ ((noinline))
62 fprintf (FILE *stream, const char *string, ...)