translate_c: fix ternary operator output in C macros
This commit is contained in:
committed by
Alex Rønne Petersen
parent
0795e2b2ef
commit
ab6dbfe1a3
21
test/cases/translate_c/tenary_in_macro.c
Normal file
21
test/cases/translate_c/tenary_in_macro.c
Normal file
@@ -0,0 +1,21 @@
|
||||
#define TERNARY_CHECK(i) check(i)
|
||||
#define TERNARY_CALL(i) (TERNARY_CHECK(i) ? (i+1) : (i-1))
|
||||
|
||||
static inline int check(int obj) {
|
||||
return obj % 2;
|
||||
}
|
||||
int target_func(int a) {
|
||||
return TERNARY_CALL(a);
|
||||
}
|
||||
|
||||
// translate-c
|
||||
// c_frontend=clang
|
||||
//
|
||||
// pub inline fn TERNARY_CHECK(i: anytype) @TypeOf(check(i)) {
|
||||
// _ = &i;
|
||||
// return check(i);
|
||||
// }
|
||||
// pub inline fn TERNARY_CALL(i: anytype) @TypeOf(if (TERNARY_CHECK(i) != 0) i + @as(c_int, 1) else i - @as(c_int, 1)) {
|
||||
// _ = &i;
|
||||
// return if (TERNARY_CHECK(i) != 0) i + @as(c_int, 1) else i - @as(c_int, 1);
|
||||
// }
|
||||
Reference in New Issue
Block a user