Skip to content

Commit 38e5a41

Browse files
committed
tests: riscv: Add test to verify C++ compilation
Using clang to build for RISC-V with these configs: CONFIG_CPP=y CONFIG_USERSPACE=n CONFIG_SMP=n CONFIG_FPU_SHARING=n results in the following warnings: include/zephyr/arch/riscv/structs.h:11:1: error: empty struct has size 0 in C, size 1 in C++ [-Werror,-Wextern-c-compat] 11 | struct _cpu_arch { | ^ include/zephyr/arch/riscv/thread.h:68:1: error: empty struct has size 0 in C, size 1 in C++ [-Werror,-Wextern-c-compat] 68 | struct _thread_arch { | ^ This commit adds a test with those configs to verify compilation succeeds. Although gcc doesn't emit these warnings, we can test with gcc as well with a BUILD_ASSERT in include/zephyr/arch/riscv/thread.h and include/zephyr/arch/riscv/structs.h. Signed-off-by: Tom Hughes <[email protected]>
1 parent 727c15a commit 38e5a41

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

tests/lib/cpp/cxx/testcase.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,3 +78,11 @@ tests:
7878
build_only: true
7979
extra_configs:
8080
- CONFIG_STD_CPP23=y
81+
# Verify struct _cpu_arch struct _thread_arch are compatible with C++ when
82+
# specific configs are enabled.
83+
cpp.main.empty_struct_size:
84+
build_only: true
85+
extra_configs:
86+
- CONFIG_USERSPACE=n
87+
- CONFIG_SMP=n
88+
- CONFIG_FPU_SHARING=n

0 commit comments

Comments
 (0)