https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125265
--- Comment #3 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Torbjorn Svensson <[email protected]>: https://gcc.gnu.org/g:baea2a0be30d843febce3b40543aa93f91018444 commit r17-4966-gbaea2a0be30d843febce3b40543aa93f91018444 Author: Torbjörn SVENSSON <[email protected]> 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 <[email protected]>
