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

--- Comment #13 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jakub Jelinek <[email protected]>:

https://gcc.gnu.org/g:bc615c0d69e5587f7336c55cfb61f51f74429b60

commit r16-7980-gbc615c0d69e5587f7336c55cfb61f51f74429b60
Author: Jakub Jelinek <[email protected]>
Date:   Tue Mar 10 13:26:09 2026 +0100

    testsuite: Fix up gcc.dg/plugin/analyzer_cpython_plugin.cc [PR112520]

    The recent r16-7938 PR112520 fix hasn't changed much in the testsuite
    results for me:
    @@ -154,41 +151,34 @@ FAIL: gcc.dg/plugin/cpython-plugin-test-
     FAIL: gcc.dg/plugin/cpython-plugin-test-PyList_Append.c
-fplugin=./analyzer_cpython_plugin.so  (test for warnings, line 42)
     FAIL: gcc.dg/plugin/cpython-plugin-test-PyList_Append.c
-fplugin=./analyzer_cpython_plugin.so  at line 18 (test for warnings, line 17)
     FAIL: gcc.dg/plugin/cpython-plugin-test-PyList_Append.c
-fplugin=./analyzer_cpython_plugin.so  at line 43 (test for warnings, line 42)
    -FAIL: gcc.dg/plugin/cpython-plugin-test-PyList_Append.c
-fplugin=./analyzer_cpython_plugin.so (internal compiler error: Segmentation
fault)
    +FAIL: gcc.dg/plugin/cpython-plugin-test-PyList_Append.c
-fplugin=./analyzer_cpython_plugin.so (internal compiler error: tree check:
expected record_type or union_type or qual_union_type, have integer_type in
get_field_by_name, at
/home/jakub/src/gcc/gcc/testsuite/gcc.dg/plugin/analyzer_cpython_plugin.cc:62)
     FAIL: gcc.dg/plugin/cpython-plugin-test-PyList_Append.c
-fplugin=./analyzer_cpython_plugin.so (test for excess errors)
     FAIL: gcc.dg/plugin/cpython-plugin-test-PyList_New.c
-fplugin=./analyzer_cpython_plugin.so  (test for warnings, line 17)
     FAIL: gcc.dg/plugin/cpython-plugin-test-PyList_New.c
-fplugin=./analyzer_cpython_plugin.so  (test for warnings, line 18)
     FAIL: gcc.dg/plugin/cpython-plugin-test-PyList_New.c
-fplugin=./analyzer_cpython_plugin.so  (test for warnings, line 21)
     FAIL: gcc.dg/plugin/cpython-plugin-test-PyList_New.c
-fplugin=./analyzer_cpython_plugin.so  (test for warnings, line 29)
     FAIL: gcc.dg/plugin/cpython-plugin-test-PyList_New.c
-fplugin=./analyzer_cpython_plugin.so  at line 37 (test for warnings, line 36)
    -FAIL: gcc.dg/plugin/cpython-plugin-test-PyList_New.c
-fplugin=./analyzer_cpython_plugin.so (internal compiler error: Segmentation
fault)
    +FAIL: gcc.dg/plugin/cpython-plugin-test-PyList_New.c
-fplugin=./analyzer_cpython_plugin.so (internal compiler error: tree check:
expected record_type or union_type or qual_union_type, have integer_type in
get_field_by_name, at
/home/jakub/src/gcc/gcc/testsuite/gcc.dg/plugin/analyzer_cpython_plugin.cc:62)
     FAIL: gcc.dg/plugin/cpython-plugin-test-PyList_New.c
-fplugin=./analyzer_cpython_plugin.so (test for excess errors)
     FAIL: gcc.dg/plugin/cpython-plugin-test-PyLong_FromLong.c
-fplugin=./analyzer_cpython_plugin.so  (test for warnings, line 17)
     FAIL: gcc.dg/plugin/cpython-plugin-test-PyLong_FromLong.c
-fplugin=./analyzer_cpython_plugin.so  (test for warnings, line 18)
     FAIL: gcc.dg/plugin/cpython-plugin-test-PyLong_FromLong.c
-fplugin=./analyzer_cpython_plugin.so  (test for warnings, line 21)
     FAIL: gcc.dg/plugin/cpython-plugin-test-PyLong_FromLong.c
-fplugin=./analyzer_cpython_plugin.so  (test for warnings, line 29)
     FAIL: gcc.dg/plugin/cpython-plugin-test-PyLong_FromLong.c
-fplugin=./analyzer_cpython_plugin.so  at line 37 (test for warnings, line 36)
    -FAIL: gcc.dg/plugin/cpython-plugin-test-PyLong_FromLong.c
-fplugin=./analyzer_cpython_plugin.so (internal compiler error: Segmentation
fault)
    +FAIL: gcc.dg/plugin/cpython-plugin-test-PyLong_FromLong.c
-fplugin=./analyzer_cpython_plugin.so (internal compiler error: tree check:
expected record_type or union_type or qual_union_type, have integer_type in
get_field_by_name, at
/home/jakub/src/gcc/gcc/testsuite/gcc.dg/plugin/analyzer_cpython_plugin.cc:62)
     FAIL: gcc.dg/plugin/cpython-plugin-test-PyLong_FromLong.c
-fplugin=./analyzer_cpython_plugin.so (test for excess errors)
    ...

    The problem is that get_field_by_name now recurses on TREE_TYPE of
    everything in TYPE_FIELDS (which can be FIELD_DECL but many other
    things (though primarily for C++ and other languages)).  More importantly,
    it recurses even for FIELD_DECLs with scalar (e.g. INTEGER_TYPE) types
    and using TYPE_FIELDS on such types results in checking ICE.

    The following patch fixes that by only recursing on anonymous struct/union
    FIELD_DECLs.  For C those have NULL DECL_NAME, for C++ they would have
    IDENTIFIER_ANON_P IDENTIFIER_NODE as DECL_NAME (but it seems this plugin
    is only used for C).

    No FAILs from plugin.exp now:
    Running /usr/src/gcc/gcc/testsuite/gcc.dg/plugin/plugin.exp ...

                    === gcc Summary ===

    2026-03-10  Jakub Jelinek  <[email protected]>

            PR testsuite/112520
            * gcc.dg/plugin/analyzer_cpython_plugin.cc (get_field_by_name):
            If name is "ob_refcnt", recurse only for types of FIELD_DECLs
            with no DECL_NAME and record or union type.

Reply via email to