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; \
57 typedef void (*fpt
)(void);
59 struct S
{ int x
, y
; } pour
, some
, sugar
;
60 union u
{ int p
; } united
, nations
;
62 if (__builtin_choose_expr (0, 12, 0)
63 || !__builtin_choose_expr (45, 5, 0)
64 || !__builtin_choose_expr (45, 3, 0))
67 ASSERT_COND_TYPE (sc1
, sc2
);
68 ASSERT_COND_TYPE (v1
, sc1
);
69 ASSERT_COND_TYPE (i
, j
);
70 ASSERT_COND_TYPE (dd
, main
);
71 ASSERT_COND_TYPE ((float)dd
, i
);
72 ASSERT_COND_TYPE (4, f
);
73 ASSERT_COND_TYPE (triple
, some
);
74 ASSERT_COND_TYPE (united
, nations
);
75 ASSERT_COND_TYPE (nations
, main
);
78 __builtin_choose_expr (0, bad (), sugar
) = pour
;
82 __builtin_choose_expr (sizeof (int), f
, bad ()) = 3.5F
;
87 __builtin_choose_expr (1, good
, bad
)();