https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108708

            Bug ID: 108708
           Summary: __analyzer_dump_named_constant fails with derived
                    values
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: analyzer
          Assignee: dmalcolm at gcc dot gnu.org
          Reporter: nightstrike at gmail dot com
  Target Milestone: ---

The analyzer test fd-access-mode-target-headers.c fails on mingw-w64 due to the
following:

FAIL: gcc.dg/analyzer/fd-access-mode-target-headers.c  (test for warnings, line
55)
FAIL: gcc.dg/analyzer/fd-access-mode-target-headers.c  (test for warnings, line
56)
FAIL: gcc.dg/analyzer/fd-access-mode-target-headers.c  (test for warnings, line
57)
FAIL: gcc.dg/analyzer/fd-access-mode-target-headers.c (test for excess errors)
Excess errors:
gcc-git/gcc/testsuite/gcc.dg/analyzer/fd-access-mode-target-headers.c:55:3:
warning: named constant 'O_ACCMODE' has unknown value
gcc-git/gcc/testsuite/gcc.dg/analyzer/fd-access-mode-target-headers.c:56:3:
warning: named constant 'O_RDONLY' has unknown value
gcc-git/gcc/testsuite/gcc.dg/analyzer/fd-access-mode-target-headers.c:57:3:
warning: named constant 'O_WRONLY' has unknown value


This fails, because on mingw-w64, we define these macros indirectly:

#define _O_RDONLY 0x0000
#define _O_WRONLY 0x0001
#define _O_RDWR 0x0002
#define _O_ACCMODE (_O_RDONLY|_O_WRONLY|_O_RDWR)
...
#define O_RDONLY _O_RDONLY
#define O_WRONLY _O_WRONLY
#define O_ACCMODE _O_ACCMODE


If I modify the test to do "#undef O_ACCMODE; #define O_ACCMODE 42", it works
as expected (and the other tests in the testsuite that test this also pass).

I didn't flag this as a testsuite issue, though, because it seems that the
issue is within the ability of __analyzer_dump_named_constant() to handle a
macro value that references another macro or is some other valid expression.  I
also don't think it's specific to Windows.

Perhaps related is that these tests also fail:
FAIL: gcc.dg/analyzer/fd-access-mode-target-headers.c  (test for warnings, line
19)
FAIL: gcc.dg/analyzer/fd-access-mode-target-headers.c  (test for warnings, line
27)
FAIL: gcc.dg/analyzer/fd-access-mode-target-headers.c  (test for warnings, line
32)
FAIL: gcc.dg/analyzer/fd-access-mode-target-headers.c  (test for warnings, line
39)

I assume this is related to the analyzer not being able to deduce the
permissions passed to open().

Reply via email to