Follows GCC implementation.
Unified · Split
| @@ -4238,6 +4238,35 @@ ST_FUNC void unary(void) · 4237 unmodified lines | ||
| 4238 | 4238 | vpushi(is_compatible_types(&type1, &type2)); |
| 4239 | 4239 | } |
| 4240 | 4240 | break; |
| 4241 | + case TOK_builtin_choose_expr: | |
| 4242 | + { | |
| 4243 | + int saved_nocode_wanted, c; | |
| 4244 | + next(); | |
| 4245 | + skip('('); | |
| 4246 | + c = expr_const(); | |
| 4247 | + skip(','); | |
| 4248 | + if (!c) { | |
| 4249 | + saved_nocode_wanted = nocode_wanted; | |
| 4250 | + nocode_wanted = 1; | |
| 4251 | + } | |
| 4252 | + expr_eq(); | |
| 4253 | + if (!c) { | |
| 4254 | + vpop(); | |
| 4255 | + nocode_wanted = saved_nocode_wanted; | |
| 4256 | + } | |
| 4257 | + skip(','); | |
| 4258 | + if (c) { | |
| 4259 | + saved_nocode_wanted = nocode_wanted; | |
| 4260 | + nocode_wanted = 1; | |
| 4261 | + } | |
| 4262 | + expr_eq(); | |
| 4263 | + if (c) { | |
| 4264 | + vpop(); | |
| 4265 | + nocode_wanted = saved_nocode_wanted; | |
| 4266 | + } | |
| 4267 | + skip(')'); | |
| 4268 | + } | |
| 4269 | + break; | |
| 4241 | 4270 | case TOK_builtin_constant_p: |
| 4242 | 4271 | { |
| 4243 | 4272 | int saved_nocode_wanted, res; |
| @@ -132,6 +132,7 @@ · 131 unmodified lines | ||
| 132 | 132 | DEF(TOK_VISIBILITY1, "visibility") |
| 133 | 133 | DEF(TOK_VISIBILITY2, "__visibility__") |
| 134 | 134 | DEF(TOK_builtin_types_compatible_p, "__builtin_types_compatible_p") |
| 135 | + DEF(TOK_builtin_choose_expr, "__builtin_choose_expr") | |
| 135 | 136 | DEF(TOK_builtin_constant_p, "__builtin_constant_p") |
| 136 | 137 | DEF(TOK_builtin_frame_address, "__builtin_frame_address") |
| 137 | 138 | DEF(TOK_builtin_return_address, "__builtin_return_address") |
| @@ -2685,6 +2685,9 @@ int constant_p_var; · 2684 unmodified lines | ||
| 2685 | 2685 | |
| 2686 | 2686 | void builtin_test(void) |
| 2687 | 2687 | { |
| 2688 | + short s; | |
| 2689 | + int i; | |
| 2690 | + long long ll; | |
| 2688 | 2691 | #if GCC_MAJOR >= 3 |
| 2689 | 2692 | COMPAT_TYPE(int, int); |
| 2690 | 2693 | COMPAT_TYPE(int, unsigned int); |
| @@ -2704,6 +2707,16 @@ void builtin_test(void) · 13 unmodified lines | ||
| 2704 | 2707 | printf("res = %d\n", __builtin_constant_p(1 + 2)); |
| 2705 | 2708 | printf("res = %d\n", __builtin_constant_p(&constant_p_var)); |
| 2706 | 2709 | printf("res = %d\n", __builtin_constant_p(constant_p_var)); |
| 2710 | + s = 1; | |
| 2711 | + ll = 2; | |
| 2712 | + i = __builtin_choose_expr (1 != 0, ll, s); | |
| 2713 | + printf("bce: %d\n", i); | |
| 2714 | + i = __builtin_choose_expr (1 != 1, ll, s); | |
| 2715 | + printf("bce: %d\n", i); | |
| 2716 | + i = sizeof (__builtin_choose_expr (1, ll, s)); | |
| 2717 | + printf("bce: %d\n", i); | |
| 2718 | + i = sizeof (__builtin_choose_expr (0, ll, s)); | |
| 2719 | + printf("bce: %d\n", i); | |
| 2707 | 2720 | } |
| 2708 | 2721 | |
| 2709 | 2722 | #ifndef _WIN32 |