mc-imperial / dredd

Framework for evaluating C/C++ compiler testing tools
Apache License 2.0
11 stars 3 forks source link

Rewrite array's size in `struct`, and argument of `static_assert` and `__builtin_frame_address` #293

Closed JonathanFoo0523 closed 1 month ago

JonathanFoo0523 commented 1 month ago

Enhances the support for rewriting the size expressions of constant-sized arrays in struct fields. Additionally, rewrites the arguments' expressions of static_assert() and __builtin_frame_address(), which need to be compile-time constants, while still allowing the constants that make up the expression— which may also be referred to elsewhere— to be freely mutated.

Fixes #286 , Fixes #289 , Fixes #290

JonathanFoo0523 commented 1 month ago

Failed on window because:

'__builtin_frame_address': identifier not found

The corresponding function for window is _AddressOfReturnAddress and program made use of directive to work on both system. Eg:

void foo() {
#if __GNUC__ || __has_builtin(__builtin_frame_address)
    return __builtin_frame_address(0);
#elif defined(_MSC_VER)
    return _AddressOfReturnAddress();
#endif
}

But this can't be used as test case, because different platform produce different dredd-mutated program.

@afd Any suggestion to solve this?

afd commented 1 month ago

Please see build.sh, under .github/workflows. You'll see there that there are exclusions that remove certain test cases that are known not to work under Windows. I suggest you make this a Linux-only test case, and add it to that exclusion list.

It would be neat to have this tested with the Windows variant too, but it's not a priority so I wouldn't worry about it.

afd commented 1 month ago

After #300 lands, can you rebase this over main and re-generate expectations for single file test (as they may have changed as a result of #220)?

Then let me know when ready for a re-review.