This is an automated email from the ASF dual-hosted git repository.

xiaoxiang781216 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx-apps.git

commit bae17b3b1f45894da02e5f3cc63f321d51c188e6
Author: hujun5 <[email protected]>
AuthorDate: Wed Sep 9 18:31:42 2026 +0800

    testing/mm/kasantest: guard GCC-only warning flags
    
    -Wuse-after-free and -Wstringop-overflow exist only in GCC, so clang
    warns about the -Wno- forms.  Apply them only for GCC toolchains;
    -Wno-unknown-warning-option is no fix either, as GCC rejects that flag.
    
    The other part of the original change, printing tv_sec as intmax_t, is
    upstream already as f9f59bd0f8.
    
    Assisted-by: Kiro:claude-opus-5-5
    Signed-off-by: hujun5 <[email protected]>
---
 testing/mm/kasantest/CMakeLists.txt | 12 ++++++++++--
 testing/mm/kasantest/Makefile       | 11 ++++++++++-
 2 files changed, 20 insertions(+), 3 deletions(-)

diff --git a/testing/mm/kasantest/CMakeLists.txt 
b/testing/mm/kasantest/CMakeLists.txt
index d578196c6..3a1d6d7dc 100644
--- a/testing/mm/kasantest/CMakeLists.txt
+++ b/testing/mm/kasantest/CMakeLists.txt
@@ -24,12 +24,20 @@ if(CONFIG_TESTING_KASAN)
   set(CFLAGS
       -fno-builtin
       -Wno-error
-      -Wno-use-after-free
       -Wno-array-bounds
       -Wno-unused-value
       -Wno-unused-variable
       -Wno-free-nonheap-object
-      -Wno-stringop-overflow
       "-O0")
+
+  # -Wuse-after-free and -Wstringop-overflow exist only in GCC; clang rejects
+  # the -Wno- forms with -Wunknown-warning-option.  Passing
+  # -Wno-unknown-warning-option instead is not a fix either, because GCC does
+  # not know that flag and warns about it in turn.
+
+  if(CONFIG_ARCH_TOOLCHAIN_GCC)
+    list(APPEND CFLAGS -Wno-use-after-free -Wno-stringop-overflow)
+  endif()
+
   nuttx_add_application(NAME kasantest COMPILE_FLAGS ${CFLAGS} SRCS 
kasantest.c)
 endif()
diff --git a/testing/mm/kasantest/Makefile b/testing/mm/kasantest/Makefile
index b12d00747..96c685af1 100644
--- a/testing/mm/kasantest/Makefile
+++ b/testing/mm/kasantest/Makefile
@@ -29,9 +29,18 @@ PROGNAME  = kasantest
 PRIORITY  = $(CONFIG_TESTING_KASAN_PRIORITY)
 STACKSIZE = $(CONFIG_TESTING_KASAN_STACKSIZE)
 
-CFLAGS += -Wno-error -Wno-use-after-free -Wno-stringop-overflow
+CFLAGS += -Wno-error
 CFLAGS += -Wno-array-bounds -Wno-free-nonheap-object
 CFLAGS += -Wno-unused-value -Wno-unused-variable
 CFLAGS += -fno-builtin "-O0"
 
+# -Wuse-after-free and -Wstringop-overflow exist only in GCC; clang rejects the
+# -Wno- forms with -Wunknown-warning-option.  Passing
+# -Wno-unknown-warning-option instead is not a fix either, because GCC does not
+# know that flag and warns about it in turn.
+
+ifeq ($(CONFIG_ARCH_TOOLCHAIN_GCC),y)
+CFLAGS += -Wno-use-after-free -Wno-stringop-overflow
+endif
+
 include $(APPDIR)/Application.mk

Reply via email to