c++: Fix ICE with #embed/RAW_DATA_CST after list conversion [PR118671]
[official-gcc.git] / gcc / testsuite / gcc.dg / tree-ssa / pr69196-1.c
blobdfabb483bcd180bca2cc3dcc0f5420b13cddc277
1 /* { dg-do compile { target sparc*-*-* i?86-*-* x86_64-*-* } } */
2 /* { dg-options "-O2 -fdump-tree-thread1-details -fdisable-tree-ethread" } */
4 /* { dg-final { scan-tree-dump "Did not thread around loop and would copy too many statements" "thread1" } } */
7 typedef __builtin_va_list __gnuc_va_list;
8 typedef __gnuc_va_list va_list;
9 extern void rtems_putc(char c);
11 void vprintk(
12 const char *fmt,
13 va_list ap
16 for (; *fmt != '\0'; fmt++) {
17 unsigned base = 0;
18 unsigned width = 0;
19 enum {
20 LFLAG_INT,
21 LFLAG_LONG,
22 LFLAG_LONG_LONG
23 } lflag = LFLAG_INT;
24 _Bool minus = 0;
25 _Bool sign = 0;
26 char lead = ' ';
27 char c = *fmt;
28 long long num;
30 if (c != '%') {
31 rtems_putc(c);
32 continue;
35 ++fmt; c = *fmt;
37 if (c == '0') {
38 lead = '0';
39 ++fmt; c = *fmt;
42 if (c == '-') {
43 minus = 1;
44 ++fmt; c = *fmt;
47 while (c >= '0' && c <= '9' ) {
48 width *= 10;
49 width += ((unsigned) c - '0');
50 ++fmt; c = *fmt;
53 if (c == 'l') {
54 lflag = LFLAG_LONG;
55 ++fmt; c = *fmt;
57 if (c == 'l') {
58 lflag = LFLAG_LONG_LONG;
59 ++fmt; c = *fmt;
63 if ( c == 'c' ) {
65 char chr = (char) __builtin_va_arg(ap,int);
66 rtems_putc(chr);
67 continue;
70 if ( c == 's' ) {
71 unsigned i, len;
72 char *s, *str;
74 str = __builtin_va_arg(ap,char *);
76 if ( str == ((void *)0) ) {
77 str = "";
81 for ( len=0, s=str ; *s ; len++, s++ )
85 if ( !minus )
86 for ( i=len ; i<width ; i++ )
87 rtems_putc(' ');
90 if (width == 0) {
91 width = len;
95 for ( i=0 ; i<width && *str ; str++ )
96 rtems_putc(*str);
99 if ( minus )
100 for ( i=len ; i<width ; i++ )
101 rtems_putc(' ');
103 continue;
107 if ( c == 'o' || c == 'O' ) {
108 base = 8; sign = 0;
109 } else if ( c == 'i' || c == 'I' ||
110 c == 'd' || c == 'D' ) {
111 base = 10; sign = 1;
112 } else if ( c == 'u' || c == 'U' ) {
113 base = 10; sign = 0;
114 } else if ( c == 'x' || c == 'X' ) {
115 base = 16; sign = 0;
116 } else if ( c == 'p' ) {
117 base = 16; sign = 0; lflag = LFLAG_LONG;
118 } else {
119 rtems_putc(c);
120 continue;
123 switch (lflag) {
124 case LFLAG_LONG:
125 num = sign ? (long long) __builtin_va_arg(ap,long)
126 : (long long) __builtin_va_arg(ap,unsigned long);
127 break;
128 case LFLAG_LONG_LONG:
129 num = __builtin_va_arg(ap,long long);
130 break;
131 case LFLAG_INT:
132 default:
133 num = sign ? (long long) __builtin_va_arg(ap,int)
134 : (long long) __builtin_va_arg(ap,unsigned int);
135 break;