Skip to content

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

Open
@tyuldashev

Description

@tyuldashev

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

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingwrong generationInadequate or empty test suite generated

Type

No type

Projects

Status

Todo

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions