UTBotCpp icon indicating copy to clipboard operation
UTBotCpp copied to clipboard

Cannot run test generated for structures named after C++ keyword

Open tyuldashev opened this issue 3 years ago • 1 comments

Description It seems that some C++ keywords cannot be used as structure names in C code, because generated tests cannot be run. For instance and and probably others.

To Reproduce

Generate tests for following function and try to run them:

struct and {
    _Bool flag;
};

_Bool get_flag_and(struct and clazz) {
    return clazz.flag;
}

Expected behavior Tests are generated and executed.

Actual behavior Tests are generated but execution fails. Following error could be found in the logs:

In file included from /home/utbot/remote/SampleDocker2/tests/makefiles/src/../../../tests/src/struct_name_dot_c_test.cpp:5:
/home/utbot/remote/SampleDocker2/tests/makefiles/src/../../../tests/src/struct_name_dot_c_test.h:67:48: error: declaration of anonymous struct must be a definition
extern "C" bool get_flag_and_src_struct_name_c(struct and clazz);

struct_name_dot_c_test.h

...
extern "C" bool get_flag_and_src_struct_name_c(struct and clazz);
static bool get_flag_and(struct and clazz) {
return get_flag_and_src_struct_name_c(clazz);
}
...

Additional context To verify other keywords please use attached file, rename extension to c and probably comment out get_flag_wchar_t function as it seems separate problem. Then generate and run tests.

struct_name.txt

tyuldashev avatar Nov 11 '22 14:11 tyuldashev

similar #534

ladisgin avatar Feb 20 '23 16:02 ladisgin