Skip to content

Commit 34f8b36

Browse files
committed
tests: lib: cpp: cxx: Add test to verify C++ compilation
When using clang to build for RISC-V with these configs: CONFIG_CPP=y CONFIG_USERSPACE=n CONFIG_SMP=n CONFIG_FPU_SHARING=n we get 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 34f8b36

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

tests/lib/cpp/cxx/testcase.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,3 +78,12 @@ 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+
arch_allow: riscv
85+
build_only: true
86+
extra_configs:
87+
- CONFIG_USERSPACE=n
88+
- CONFIG_SMP=n
89+
- CONFIG_FPU_SHARING=n

0 commit comments

Comments
 (0)