In r17-409-g8376a674e3564f, 2 out of the 4 redundant tests fail when testing for arm-none-eabi: 105 │ void test_redundant_o_creat (void) 106 │ { 107 │ char tmpl[] = "/tmp/testXXXXXX"; 108 │ mkostemp (tmpl, O_CREAT); /* { dg-warning "'mkostemp' flags argument should not include 'O_RDWR', 'O_CREAT', or 'O_EXCL' as these are already implied" } */ 109 │ } 110 │ 111 │ void test_redundant_o_excl (void) 112 │ { 113 │ char tmpl[] = "/tmp/testXXXXXX"; 114 │ mkostemp (tmpl, O_EXCL); /* { dg-warning "'mkostemp' flags argument should not include 'O_RDWR', 'O_CREAT', or 'O_EXCL' as these are already implied" } */ 115 │ } Testing analyzer/mkostemp-1.c doing compile Executing on host: /build/r17-409-g8376a674e3564f/bin/arm-none-eabi-gcc /build/gcc_src/gcc/testsuite/gcc.dg/analyzer/mkostemp-1.c -mthumb -march=armv6s-m -mtune=cortex-m0 -mfloat-abi=soft -mfpu=auto -fdiagnostics-plain-output -fanalyzer -Wanalyzer-too-complex -Wanalyzer-symbol-too-complex -Wno-analyzer-null-argument -S -o mkostemp-1.s (timeout = 800) ... /build/gcc_src/gcc/testsuite/gcc.dg/analyzer/mkostemp-1.c: In function 'test_redundant_o_rdwr': /build/gcc_src/gcc/testsuite/gcc.dg/analyzer/mkostemp-1.c:102:3: warning: 'mkostemp' flags argument should not include 'O_RDWR', 'O_CREAT', or 'O_EXCL' as these are already implied [-Wanalyzer-mkostemp-redundant-flags] /build/gcc_src/gcc/testsuite/gcc.dg/analyzer/mkostemp-1.c:102:3: note: (1) 'mkostemp' flags argument should not include 'O_RDWR', 'O_CREAT', or 'O_EXCL' as these are already implied /build/gcc_src/gcc/testsuite/gcc.dg/analyzer/mkostemp-1.c:103:1: warning: leak of file descriptor [CWE-775] [-Wanalyzer-fd-leak] /build/gcc_src/gcc/testsuite/gcc.dg/analyzer/mkostemp-1.c:102:3: note: (1) opened here as read-write /build/gcc_src/gcc/testsuite/gcc.dg/analyzer/mkostemp-1.c:102:3: note: (2) when 'mkostemp' succeeds /build/gcc_src/gcc/testsuite/gcc.dg/analyzer/mkostemp-1.c:103:1: note: (3) leaks here /build/gcc_src/gcc/testsuite/gcc.dg/analyzer/mkostemp-1.c: In function 'test_redundant_o_creat': /build/gcc_src/gcc/testsuite/gcc.dg/analyzer/mkostemp-1.c:109:1: warning: leak of file descriptor [CWE-775] [-Wanalyzer-fd-leak] /build/gcc_src/gcc/testsuite/gcc.dg/analyzer/mkostemp-1.c:108:3: note: (1) opened here as read-write /build/gcc_src/gcc/testsuite/gcc.dg/analyzer/mkostemp-1.c:108:3: note: (2) when 'mkostemp' succeeds /build/gcc_src/gcc/testsuite/gcc.dg/analyzer/mkostemp-1.c:109:1: note: (3) leaks here /build/gcc_src/gcc/testsuite/gcc.dg/analyzer/mkostemp-1.c: In function 'test_redundant_o_excl': /build/gcc_src/gcc/testsuite/gcc.dg/analyzer/mkostemp-1.c:115:1: warning: leak of file descriptor [CWE-775] [-Wanalyzer-fd-leak] /build/gcc_src/gcc/testsuite/gcc.dg/analyzer/mkostemp-1.c:114:3: note: (1) opened here as read-write /build/gcc_src/gcc/testsuite/gcc.dg/analyzer/mkostemp-1.c:114:3: note: (2) when 'mkostemp' succeeds /build/gcc_src/gcc/testsuite/gcc.dg/analyzer/mkostemp-1.c:115:1: note: (3) leaks here /build/gcc_src/gcc/testsuite/gcc.dg/analyzer/mkostemp-1.c: In function 'test_redundant_combined': /build/gcc_src/gcc/testsuite/gcc.dg/analyzer/mkostemp-1.c:120:3: warning: 'mkostemp' flags argument should not include 'O_RDWR', 'O_CREAT', or 'O_EXCL' as these are already implied [-Wanalyzer-mkostemp-redundant-flags] /build/gcc_src/gcc/testsuite/gcc.dg/analyzer/mkostemp-1.c:120:3: note: (1) 'mkostemp' flags argument should not include 'O_RDWR', 'O_CREAT', or 'O_EXCL' as these are already implied /build/gcc_src/gcc/testsuite/gcc.dg/analyzer/mkostemp-1.c:121:1: warning: leak of file descriptor [CWE-775] [-Wanalyzer-fd-leak] /build/gcc_src/gcc/testsuite/gcc.dg/analyzer/mkostemp-1.c:120:3: note: (1) opened here as read-write /build/gcc_src/gcc/testsuite/gcc.dg/analyzer/mkostemp-1.c:120:3: note: (2) when 'mkostemp' succeeds /build/gcc_src/gcc/testsuite/gcc.dg/analyzer/mkostemp-1.c:121:1: note: (3) leaks here ... PASS: gcc.dg/analyzer/mkostemp-1.c (test for warnings, line 18) PASS: gcc.dg/analyzer/mkostemp-1.c fix suggestion at line 19 (test for warnings, line 18) PASS: gcc.dg/analyzer/mkostemp-1.c (test for warnings, line 24) PASS: gcc.dg/analyzer/mkostemp-1.c (test for warnings, line 29) PASS: gcc.dg/analyzer/mkostemp-1.c (test for warnings, line 53) PASS: gcc.dg/analyzer/mkostemp-1.c (test for warnings, line 59) PASS: gcc.dg/analyzer/mkostemp-1.c (test for warnings, line 65) PASS: gcc.dg/analyzer/mkostemp-1.c (test for warnings, line 71) PASS: gcc.dg/analyzer/mkostemp-1.c (test for warnings, line 77) PASS: gcc.dg/analyzer/mkostemp-1.c (test for warnings, line 102) FAIL: gcc.dg/analyzer/mkostemp-1.c (test for warnings, line 108) FAIL: gcc.dg/analyzer/mkostemp-1.c (test for warnings, line 114) PASS: gcc.dg/analyzer/mkostemp-1.c (test for warnings, line 120) PASS: gcc.dg/analyzer/mkostemp-1.c (test for excess errors) The same test pass when testing for x86_64-pc-linux-gnu.
I think it is the same root cause for the 2 failures in gcc.dg/analyzer/mkostemps-1.c as well. 111 │ void test_redundant_o_creat (void) 112 │ { 113 │ char tmpl[] = "/tmp/dataXXXXXX.db"; 114 │ mkostemps (tmpl, 3, O_CREAT); /* { dg-warning "'mkostemps' flags argument should not include 'O_RDWR', 'O_CREAT', or 'O_EXCL' as these are already implied" } */ 115 │ } 116 │ 117 │ void test_redundant_o_excl (void) 118 │ { 119 │ char tmpl[] = "/tmp/dataXXXXXX.db"; 120 │ mkostemps (tmpl, 3, O_EXCL); /* { dg-warning "'mkostemps' flags argument should not include 'O_RDWR', 'O_CREAT', or 'O_EXCL' as these are already implied" } */ 121 │ } Testing analyzer/mkostemps-1.c doing compile Executing on host: /build/r17-409-g8376a674e3564f/bin/arm-none-eabi-gcc /build/gcc_src/gcc/testsuite/gcc.dg/analyzer/mkostemps-1.c -mthumb -march=armv6s-m -mtune=cortex-m0 -mfloat-abi=soft -mfpu=auto -fdiagnostics-plain-output -fanalyzer -Wanalyzer-too-complex -Wanalyzer-symbol-too-complex -Wno-analyzer-null-argument -S -o mkostemps-1.s (timeout = 800) ... /build/gcc_src/gcc/testsuite/gcc.dg/analyzer/mkostemps-1.c: In function 'test_redundant_o_rdwr': /build/gcc_src/gcc/testsuite/gcc.dg/analyzer/mkostemps-1.c:108:3: warning: 'mkostemps' flags argument should not include 'O_RDWR', 'O_CREAT', or 'O_EXCL' as these are already implied [-Wanalyzer-mkostemp-redundant-flags] /build/gcc_src/gcc/testsuite/gcc.dg/analyzer/mkostemps-1.c:108:3: note: (1) 'mkostemps' flags argument should not include 'O_RDWR', 'O_CREAT', or 'O_EXCL' as these are already implied /build/gcc_src/gcc/testsuite/gcc.dg/analyzer/mkostemps-1.c:109:1: warning: leak of file descriptor [CWE-775] [-Wanalyzer-fd-leak] /build/gcc_src/gcc/testsuite/gcc.dg/analyzer/mkostemps-1.c:108:3: note: (1) opened here as read-write /build/gcc_src/gcc/testsuite/gcc.dg/analyzer/mkostemps-1.c:108:3: note: (2) when 'mkostemps' succeeds /build/gcc_src/gcc/testsuite/gcc.dg/analyzer/mkostemps-1.c:109:1: note: (3) leaks here /build/gcc_src/gcc/testsuite/gcc.dg/analyzer/mkostemps-1.c: In function 'test_redundant_o_creat': /build/gcc_src/gcc/testsuite/gcc.dg/analyzer/mkostemps-1.c:115:1: warning: leak of file descriptor [CWE-775] [-Wanalyzer-fd-leak] /build/gcc_src/gcc/testsuite/gcc.dg/analyzer/mkostemps-1.c:114:3: note: (1) opened here as read-write /build/gcc_src/gcc/testsuite/gcc.dg/analyzer/mkostemps-1.c:114:3: note: (2) when 'mkostemps' succeeds /build/gcc_src/gcc/testsuite/gcc.dg/analyzer/mkostemps-1.c:115:1: note: (3) leaks here /build/gcc_src/gcc/testsuite/gcc.dg/analyzer/mkostemps-1.c: In function 'test_redundant_o_excl': /build/gcc_src/gcc/testsuite/gcc.dg/analyzer/mkostemps-1.c:121:1: warning: leak of file descriptor [CWE-775] [-Wanalyzer-fd-leak] /build/gcc_src/gcc/testsuite/gcc.dg/analyzer/mkostemps-1.c:120:3: note: (1) opened here as read-write /build/gcc_src/gcc/testsuite/gcc.dg/analyzer/mkostemps-1.c:120:3: note: (2) when 'mkostemps' succeeds /build/gcc_src/gcc/testsuite/gcc.dg/analyzer/mkostemps-1.c:121:1: note: (3) leaks here /build/gcc_src/gcc/testsuite/gcc.dg/analyzer/mkostemps-1.c: In function 'test_redundant_combined': /build/gcc_src/gcc/testsuite/gcc.dg/analyzer/mkostemps-1.c:126:3: warning: 'mkostemps' flags argument should not include 'O_RDWR', 'O_CREAT', or 'O_EXCL' as these are already implied [-Wanalyzer-mkostemp-redundant-flags] /build/gcc_src/gcc/testsuite/gcc.dg/analyzer/mkostemps-1.c:126:3: note: (1) 'mkostemps' flags argument should not include 'O_RDWR', 'O_CREAT', or 'O_EXCL' as these are already implied /build/gcc_src/gcc/testsuite/gcc.dg/analyzer/mkostemps-1.c:127:1: warning: leak of file descriptor [CWE-775] [-Wanalyzer-fd-leak] /build/gcc_src/gcc/testsuite/gcc.dg/analyzer/mkostemps-1.c:126:3: note: (1) opened here as read-write /build/gcc_src/gcc/testsuite/gcc.dg/analyzer/mkostemps-1.c:126:3: note: (2) when 'mkostemps' succeeds /build/gcc_src/gcc/testsuite/gcc.dg/analyzer/mkostemps-1.c:127:1: note: (3) leaks here ... PASS: gcc.dg/analyzer/mkostemps-1.c (test for warnings, line 18) PASS: gcc.dg/analyzer/mkostemps-1.c fix suggestion at line 19 (test for warnings, line 18) PASS: gcc.dg/analyzer/mkostemps-1.c (test for warnings, line 24) PASS: gcc.dg/analyzer/mkostemps-1.c (test for warnings, line 29) PASS: gcc.dg/analyzer/mkostemps-1.c (test for warnings, line 34) PASS: gcc.dg/analyzer/mkostemps-1.c (test for warnings, line 58) PASS: gcc.dg/analyzer/mkostemps-1.c (test for warnings, line 65) PASS: gcc.dg/analyzer/mkostemps-1.c (test for warnings, line 71) PASS: gcc.dg/analyzer/mkostemps-1.c (test for warnings, line 77) PASS: gcc.dg/analyzer/mkostemps-1.c (test for warnings, line 83) PASS: gcc.dg/analyzer/mkostemps-1.c (test for warnings, line 108) FAIL: gcc.dg/analyzer/mkostemps-1.c (test for warnings, line 114) FAIL: gcc.dg/analyzer/mkostemps-1.c (test for warnings, line 120) PASS: gcc.dg/analyzer/mkostemps-1.c (test for warnings, line 126) PASS: gcc.dg/analyzer/mkostemps-1.c (test for excess errors)
Patch available in https://gcc.gnu.org/pipermail/gcc-patches/2026-August/729408.html
The master branch has been updated by Torbjorn Svensson <azoff@gcc.gnu.org>: https://gcc.gnu.org/g:baea2a0be30d843febce3b40543aa93f91018444 commit r17-4966-gbaea2a0be30d843febce3b40543aa93f91018444 Author: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com> Date: Mon Aug 31 07:38:51 2026 +0200 analyzer: follow macro aliases for named constant [PR125265] Newlib, picolibc, and probably other libc implementations, use #define O_CREAT _FCREAT #define O_TRUNC _FTRUNC #define O_EXCL _FEXCL In r17-177-g9a5f89005dc49d, support was added to identify redundant flags, but the implementation requires that the value of the macros O_CREAT, O_EXCL, O_RDWR to be a number. This patch extends the support to also allow macro aliases. The maximum followed levels is by default 8 levels, but can be tuned via --param=analyzer-max-macro-alias-depth=n. This change fixes FAIL: gcc.dg/analyzer/mkostemp-1.c (test for warnings, line 109) FAIL: gcc.dg/analyzer/mkostemp-1.c (test for warnings, line 115) FAIL: gcc.dg/analyzer/mkostemps-1.c (test for warnings, line 115) FAIL: gcc.dg/analyzer/mkostemps-1.c (test for warnings, line 121) Regtested with arm-none-eabi (with newlib) on r17-3738-gaaa0f6b1e87bc6. PR analyzer/125265 gcc/ChangeLog: * doc/params.texi (analyzer-max-macro-alias-depth): Document. * params.opt (-param=analyzer-max-macro-alias-depth=): New. gcc/c/ChangeLog: * c-parser.cc: Follow macro alias to get the value for a named constant. gcc/testsuite/ChangeLog: * gcc.dg/analyzer/named-constants-via-macros-alias.c: New test. Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
The master branch has been updated by Torbjorn Svensson <azoff@gcc.gnu.org>: https://gcc.gnu.org/g:1f01624b68fbf9eb8ca82ba0dde7d8ceee9a19dd commit r17-5075-g1f01624b68fbf9eb8ca82ba0dde7d8ceee9a19dd Author: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com> Date: Fri Oct 9 06:43:26 2026 +0200 analyzer: Move max-macro-alias-depth to analyzer.opt [PR125265] In r17-4966-gbaea2a0be30d84, I added --param=analyzer-max-macro-alias-depth= to gcc/params.opt, but I've since then learned that the analyzer params should have been defined in gcc/analyzer/analyzer.opt. This patch rectifies my misstake. I've also aligned the definition of --param=analyzer-max-macro-alias-depth= with other analyzer params (adding "Param" and removing "IntegerRange"). PR analyzer/125265 gcc/ChangeLog: * params.opt (analyzer-max-macro-alias-depth): Move to... gcc/analyzer/ChangeLog: * analyzer.opt: ...here. Align parameter definition. Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
Thanks!