2 /* { dg-options "-O1 -Wall" } */
4 #define choose __builtin_choose_expr
6 /* Check the type of __builtin_choose_expr between E1 and E2, both
7 ways round and with both 0 and 1 as the condition. */
8 #define ASSERT_COND_TYPE(E1, E2) \
10 typedef __typeof(E1) T1; \
11 typedef __typeof(E2) T2; \
14 typedef __typeof(choose (1, (E1), (E2))) T1a; \
15 typedef __typeof(choose (0, (E2), (E1))) T1b; \
16 typedef __typeof(choose (1, (E2), (E1))) T2a; \
17 typedef __typeof(choose (0, (E1), (E2))) T2b; \
18 typedef T1a **T1app; \
19 typedef T1b **T1bpp; \
20 typedef T2a **T2app; \
21 typedef T2b **T2bpp; \
55 typedef void (*fpt
)(void);
57 struct S
{ int x
, y
; } pour
, some
, sugar
;
58 union u
{ int p
; } united
, nations
;
60 if (__builtin_choose_expr (0, 12, 0)
61 || !__builtin_choose_expr (45, 5, 0)
62 || !__builtin_choose_expr (45, 3, 0))
65 ASSERT_COND_TYPE (sc1
, sc2
);
66 ASSERT_COND_TYPE (v1
, sc1
);
67 ASSERT_COND_TYPE (i
, j
);
68 ASSERT_COND_TYPE (dd
, main
);
69 ASSERT_COND_TYPE ((float)dd
, i
);
70 ASSERT_COND_TYPE (4, f
);
71 ASSERT_COND_TYPE (triple
, some
);
72 ASSERT_COND_TYPE (united
, nations
);
73 ASSERT_COND_TYPE (nations
, main
);
76 __builtin_choose_expr (0, bad (), sugar
) = pour
;
80 __builtin_choose_expr (sizeof (int), f
, bad ()) = 3.5F
;
85 __builtin_choose_expr (1, good
, bad
)();