diff options
| author | Marco Elver <elver@google.com> | 2025-12-19 16:39:52 +0100 |
|---|---|---|
| committer | Peter Zijlstra <peterz@infradead.org> | 2026-01-05 16:43:27 +0100 |
| commit | 9b00c1609deeb7d6f68a61f3ec6988ab7e6f4535 (patch) | |
| tree | 0dc1a17f19a34aeed2e9df1c48407be835a2db4e /lib/test_context-analysis.c | |
| parent | 3269701cb25662ae8a9771a864201116626adb50 (diff) | |
compiler-context-analysis: Add test stub
Add a simple test stub where we will add common supported patterns that
should not generate false positives for each new supported context lock.
Signed-off-by: Marco Elver <elver@google.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://patch.msgid.link/20251219154418.3592607-4-elver@google.com
Diffstat (limited to 'lib/test_context-analysis.c')
| -rw-r--r-- | lib/test_context-analysis.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/test_context-analysis.c b/lib/test_context-analysis.c new file mode 100644 index 000000000000..68f075dec0e0 --- /dev/null +++ b/lib/test_context-analysis.c @@ -0,0 +1,18 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Compile-only tests for common patterns that should not generate false + * positive errors when compiled with Clang's context analysis. + */ + +#include <linux/build_bug.h> + +/* + * Test that helper macros work as expected. + */ +static void __used test_common_helpers(void) +{ + BUILD_BUG_ON(context_unsafe(3) != 3); /* plain expression */ + BUILD_BUG_ON(context_unsafe((void)2; 3) != 3); /* does not swallow semi-colon */ + BUILD_BUG_ON(context_unsafe((void)2, 3) != 3); /* does not swallow commas */ + context_unsafe(do { } while (0)); /* works with void statements */ +} |
