Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions generator/c/c_generator.c2
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ const char*[] builtinType_cnames = {
"double",
"ssize_t",
"size_t",
"_Bool",
"bool",
}
static_assert(elemsof(BuiltinKind), elemsof(builtinType_cnames));

Expand Down Expand Up @@ -1438,6 +1438,11 @@ const char[] Include_guard1 =
const char[] C_types =
```c
// --- internally added ---
#if !defined __STDC_VERSION__ || __STDC_VERSION__ < 202311L
#define bool _Bool
#define true 1
#define false 0
#endif
typedef signed char int8_t;
typedef unsigned char uint8_t;
typedef signed short int16_t;
Expand All @@ -1447,8 +1452,6 @@ const char[] C_types =
```;
const char[] C_defines =
```c
#define true 1
#define false 0

#define NULL ((void*)0)
#define ARRAY_SIZE(x) (sizeof(x)/sizeof((x)[0]))
Expand Down
2 changes: 1 addition & 1 deletion test/c_generator/types/builtins.c2t
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ type S struct {

typedef struct test_S_ test_S;
struct test_S_ {
_Bool b;
bool b;
int8_t i_8;
int16_t i_16;
int32_t i_32;
Expand Down
2 changes: 1 addition & 1 deletion test/c_generator/variables/should_initalize_globals.c2t
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ typedef struct test_Foo_ test_Foo;
struct test_Foo_ {
int32_t i;
int8_t* cp;
_Bool b;
bool b;
};

static test_Foo test_f = { };
Expand Down
14 changes: 7 additions & 7 deletions test/functions/func_param_nested.c2t
Original file line number Diff line number Diff line change
Expand Up @@ -31,25 +31,25 @@ fn void test2() {
}
// @expect{atleast, cgen/build.c}
typedef void (*test_Cb1)(void* _arg0, _arg1, int32_t _arg2);
typedef _Bool (*test_Cb2)(int32_t _arg0, int32_t _arg1);
typedef bool (*test_Cb2)(int32_t _arg0, int32_t _arg1);

static void test_callback1(void* arg, _Bool (*_arg1)(int32_t _arg0, int32_t _arg1), int32_t a);
static void test_callback1(void* arg, bool (*_arg1)(int32_t _arg0, int32_t _arg1), int32_t a);
static test_Cb1 test_cb1 = test_callback1;
static _Bool test_callback2(int32_t a, int32_t b);
static bool test_callback2(int32_t a, int32_t b);
static test_Cb2 test_cb2 = test_callback2;
static void test_test1(void* arg, void (*cb)(void* arg, _Bool (*_arg1)(int32_t _arg0, int32_t _arg1), int32_t a), _Bool (*inner)(int32_t _arg0, int32_t _arg1), int32_t a);
static void test_test1(void* arg, void (*cb)(void* arg, bool (*_arg1)(int32_t _arg0, int32_t _arg1), int32_t a), bool (*inner)(int32_t _arg0, int32_t _arg1), int32_t a);
static void test_test2(void);

static void test_callback1(void* arg, _Bool (*_arg1)(int32_t _arg0, int32_t _arg1), int32_t a)
static void test_callback1(void* arg, bool (*_arg1)(int32_t _arg0, int32_t _arg1), int32_t a)
{
}

static _Bool test_callback2(int32_t a, int32_t b)
static bool test_callback2(int32_t a, int32_t b)
{
return true;
}

static void test_test1(void* arg, void (*cb)(void* arg, _Bool (*_arg1)(int32_t _arg0, int32_t _arg1), int32_t a), _Bool (*inner)(int32_t _arg0, int32_t _arg1), int32_t a)
static void test_test1(void* arg, void (*cb)(void* arg, bool (*_arg1)(int32_t _arg0, int32_t _arg1), int32_t a), bool (*inner)(int32_t _arg0, int32_t _arg1), int32_t a)
{
cb(arg, test_callback2, a);
cb(arg, inner, a);
Expand Down
2 changes: 1 addition & 1 deletion test/functions/func_param_unnamed.c2t
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ fn void test1(void* arg,
}

// @expect{atleast, cgen/build.c}
static void test_test1(void* arg, void (*_arg1)(void* arg, int32_t a), _Bool (*_arg2)(void* _arg0, char _arg1), int32_t a);
static void test_test1(void* arg, void (*_arg1)(void* arg, int32_t a), bool (*_arg2)(void* _arg0, char _arg1), int32_t a);

12 changes: 6 additions & 6 deletions test/functions/named_arg.c2t
Original file line number Diff line number Diff line change
Expand Up @@ -49,27 +49,27 @@ public fn i32 main(i32 argc, char** argv) {
}

// @expect{atleast, cgen/build.c}
static _Bool test_check_case(const char* s, _Bool is_upper);
static void test_fun1(const char* s, _Bool is_upper, _Bool is_lower);
static void test_fun3(const char* s, _Bool _arg1, _Bool is_lower);
static bool test_check_case(const char* s, bool is_upper);
static void test_fun1(const char* s, bool is_upper, bool is_lower);
static void test_fun3(const char* s, bool _arg1, bool is_lower);
static void test_foo1(const char* s);
static void test_foo2(const char* s);
static void test_foo3(const char* s);
static void test_test1(const char* s);
int32_t main(int32_t argc, char** argv);

static _Bool test_check_case(const char* s, _Bool is_upper)
static bool test_check_case(const char* s, bool is_upper)
{
if (is_upper) return isupper(*s);
else return islower(*s);

}

static void test_fun1(const char* s, _Bool is_upper, _Bool is_lower)
static void test_fun1(const char* s, bool is_upper, bool is_lower)
{
}

static void test_fun3(const char* s, _Bool _arg1, _Bool is_lower)
static void test_fun3(const char* s, bool _arg1, bool is_lower)
{
}

Expand Down