x86: Tune Skylake, Cannonlake and Icelake as Haswell
[official-gcc.git] / gcc / testsuite / gcc.c-torture / execute / builtins / fprintf.c
blobf7db2e0618ee6b48d72fd2f4e4a716e926a36240
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. */
8 #include <stdio.h>
9 extern int fprintf_unlocked (FILE *, const char *, ...);
10 extern void abort(void);
12 void
13 main_test (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;
19 fprintf (*s_ptr, "");
20 fprintf (*s_ptr, "%s", "");
21 fprintf (*s_ptr, "%s", "hello");
22 fprintf (*s_ptr, "%s", "\n");
23 fprintf (*s_ptr, "%s", *s2);
24 s3 = s2;
25 fprintf (*s_ptr, "%s", *s3++);
26 if (s3 != s2+1 || *s3 != 0)
27 abort();
28 s3 = s2;
29 fprintf (*s_ptr++, "%s", *s3++);
30 if (s3 != s2+1 || *s3 != 0 || s_ptr != s_array+1 || *s_ptr != 0)
31 abort();
33 s_ptr = s_array;
34 fprintf (*s_ptr, "%c", '\n');
35 fprintf (*s_ptr, "%c", **s2);
36 s3 = s2;
37 fprintf (*s_ptr, "%c", **s3++);
38 if (s3 != s2+1 || *s3 != 0)
39 abort();
40 s3 = s2;
41 fprintf (*s_ptr++, "%c", **s3++);
42 if (s3 != s2+1 || *s3 != 0 || s_ptr != s_array+1 || *s_ptr != 0)
43 abort();
45 s_ptr = s_array;
46 fprintf (*s_ptr++, "hello world");
47 if (s_ptr != s_array+1 || *s_ptr != 0)
48 abort();
49 s_ptr = s_array;
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", "");