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 8 extern int printf (const char *, ...); 9 extern void abort(void); 10 11 int main() 12 { 13 const char *const s1 = "hello world"; 14 const char *const s2[] = { s1, 0 }, *const*s3; 15 16 printf ("%s\n", "hello"); 17 printf ("%s\n", *s2); 18 s3 = s2; 19 printf ("%s\n", *s3++); 20 if (s3 != s2+1 || *s3 != 0) 21 abort(); 22 23 printf ("%c", '\n'); 24 printf ("%c", **s2); 25 s3 = s2; 26 printf ("%c", **s3++); 27 if (s3 != s2+1 || *s3 != 0) 28 abort(); 29 30 printf ("\n"); 31 printf ("hello world\n"); 32 33 /* Test at least one instance of the __builtin_ style. We do this 34 to ensure that it works and that the prototype is correct. */ 35 __builtin_printf ("%s\n", "hello"); 36 /* These builtin stubs are called by __builtin_printf, ensure their 37 prototypes are set correctly too. */ 38 __builtin_putchar ('\n'); 39 __builtin_puts ("hello"); 40 41 return 0; 42 } 43 44 #ifdef __OPTIMIZE__ 45 /* When optimizing, all the above cases should be transformed into 46 something else. So any remaining calls to the original function 47 should abort. */ 48 static int 49 printf (const char *string, ...) 50 { 51 abort(); 52 } 53 #endif 54