1/* Copyright (C) 2000  Free Software Foundation.
2
3   Ensure all expected transformations of builtin printf occur and
4   that we honor side effects in the arguments.
5
6   Written by Kaveh R. Ghazi, 12/4/2000.  */
7
8extern int printf (const char *, ...);
9extern int printf_unlocked (const char *, ...);
10extern void abort(void);
11
12void
13main_test (void)
14{
15  const char *const s1 = "hello world";
16  const char *const s2[] = { s1, 0 }, *const*s3;
17
18  printf ("%s\n", "hello");
19  printf ("%s\n", *s2);
20  s3 = s2;
21  printf ("%s\n", *s3++);
22  if (s3 != s2+1 || *s3 != 0)
23    abort();
24
25  printf ("%c", '\n');
26  printf ("%c", **s2);
27  s3 = s2;
28  printf ("%c", **s3++);
29  if (s3 != s2+1 || *s3 != 0)
30    abort();
31
32  printf ("");
33  printf ("%s", "");
34  printf ("\n");
35  printf ("%s", "\n");
36  printf ("hello world\n");
37  printf ("%s", "hello world\n");
38
39  /* Test at least one instance of the __builtin_ style.  We do this
40     to ensure that it works and that the prototype is correct.  */
41  __builtin_printf ("%s\n", "hello");
42  /* These builtin stubs are called by __builtin_printf, ensure their
43     prototypes are set correctly too.  */
44  __builtin_putchar ('\n');
45  __builtin_puts ("hello");
46  /* Check the unlocked style, these evaluate to nothing to avoid
47     problems on systems without the unlocked functions.  */
48  printf_unlocked ("");
49  __builtin_printf_unlocked ("");
50  printf_unlocked ("%s", "");
51  __builtin_printf_unlocked ("%s", "");
52}
53