1 /* Copyright (C) 2003 Free Software Foundation.
3 Test strlen optimizations on conditional expressions.
5 Written by Jakub Jelinek, June 23, 2003. */
7 typedef __SIZE_TYPE__
size_t;
8 extern size_t strlen (const char *);
9 extern char *strcpy (char *, const char *);
10 extern int memcmp (const void *, const void *, size_t);
11 extern void abort (void);
12 extern int inside_main
;
14 size_t g
, h
, i
, j
, k
, l
;
27 if (strlen (i
? "foo" + 1 : j
? "bar" + 1 : "baz" + 1) != 2)
29 if (strlen (g
++ ? "foo" : "bar") != 3 || g
!= 1)
31 if (strlen (h
++ ? "xfoo" + 1 : "bar") != 3 || h
!= 1)
33 if (strlen ((i
++, "baz")) != 3 || i
!= 1)
35 /* The following calls might not optimize strlen call away. */
37 if (strlen (j
? "foo" + k
++ : "bar" + k
++) != 3 || k
!= 1)
39 if (strlen (foo () ? "foo" : "bar") != 3 || l
!= 1)