Re: [PATCH v2 03/34] compiler-capability-analysis: Add test stub

Bart Van Assche
2025-03-04T23:52:45Z

On 3/4/25 1:21 AM, Marco Elver wrote:
> +#include <linux/build_bug.h>
> +
> +/*
> + * Test that helper macros work as expected.
> + */
> +static void __used test_common_helpers(void)
> +{
> + BUILD_BUG_ON(capability_unsafe(3) != 3); /* plain expression */
> + BUILD_BUG_ON(capability_unsafe((void)2; 3;) != 3); /* does not swallow semi-colon */
> + BUILD_BUG_ON(capability_unsafe((void)2, 3) != 3); /* does not swallow commas */
> + capability_unsafe(do { } while (0)); /* works with void statements */
> +}

Is it guaranteed that <linux/build_bug.h> includes the header file that
defines capability_unsafe() or should that header file perhaps be
included explicitly?

Thanks,

Bart.