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

--- Comment #3 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Martin Uecker <uec...@gcc.gnu.org>:

https://gcc.gnu.org/g:9eae9268e41463927c9383004e58708048ec379f

commit r15-4812-g9eae9268e41463927c9383004e58708048ec379f
Author: Martin Uecker <uec...@tugraz.at>
Date:   Tue Oct 22 23:25:00 2024 +0200

    c: detect variably-modified types [PR117145,PR117245,PR100420]

    This fixes two cases where variably-modified types were not recognized as
    such.  The first is when building composite types and the other when a type
    is reconstructed for the 'vector' attribute.  Construction of types in
    the C FE is reorganized to use c_build_* functions which are responsible
for
    setting C_TYPE_VARIABLE_SIZE, C_TYPE_VARIABLY_MODIFIED and
TYPE_TYPELESS_STORAGE
    based on the properties of the type itself and these replace all other
logic
    elsewhere (e.g. in grokdeclarator).  A new 'c_reconstruct_complex_type'
based
    on these functions is introduced which is called via a language hook when
the
    'vector' attribute is processed (as for C++).

    One problem is are arrays of unspecified size 'T[*]' which were represented
    identically to zero-sized arrays but with C_TYPE_VARIABLE_SIZE set.  To
avoid
    having to create distinct type copies for this, the representation was
changed
    to make it a natural VLA by giving it an upper bound of '(0, 0)'.  This
also
    then allows fixing of PR100420 where such arrays were printed as 'T[0]'.

    Finally, a new function 'c_verify_type' checks consistency of properties
    specific to C FE and is called when checking is on.

            PR c/117145
            PR c/117245
            PR c/100420

    gcc/c/ChangeLog:
            * c-decl.cc (c_build_pointer_type): Move to c-typeck.cc
            (grokdeclarator): Simplify logic.
            (match_builtin_function_types): Adapt.
            (push_decl): Adapt.
            (implicitly_declare): Adapt.
            (c_update_type_canonical): Adapt.
            (c_make_fname_decl): Adapt.
            (start_function): Adapt.
            * c-objc-common.h: Add LANG_HOOKS_RECONSTRUCT_COMPLEX_TYPE.
            * c-tree.h: Add prototypes.
            * c-typeck.cc (c_verify_type): New function.
            (c_set_type_bits). New function.
            (c_build_pointer_type): Moved from c-decl.cc.
            (c_build_pointer_type_for_mode): New function.
            (c_build_function_type): New function.
            (c_build_array_type): New function.
            (c_build_type_attribute_variant): New function.
            (c_reconstruct_complex_type): New function.
            (c_build_functype_attribute_variant): Renamed.
            (array_to_pointer_conversion): Simplify logic.
            (composite_type_internal): Simplify logic..
            (build_unary_op): Simplify logic..
            (comptypes_verify): Add checking assertions.
            (c_build_qualified_type): Add checking assertions.
            (c_build_function_call_vec): Adapt.
            (qualify_type): Adapt.
            (build_functype_attribute_variant): Adapt.
            (common_pointer_type): Adapt.
            (c_common_type): Adapt.
            (convert_for_assignment): Adapt.
            (type_or_builtin_type): Adapt.
            (build_access_with_size_for_counted_by): Adapt.
            (build_conditional_expr): Adapt.
            (build_modify_expr): Adapt.
            (build_binary_op): Adapt.
            (build_omp_array_section): Adapt.
            (handle_omp_array_sections): Adapt.
            (c_finish_omp_clauses): Adapt.
            * c-parser.cc (c_parser_typeof_specifier): Adapt.
            (c_parser_generic_selection): Adapt.

    gcc/c-family/ChangeLog:
            * c-pretty-print.cc (c_pretty_printer::direct_abstract_declarator):
            Detect arrays of unspecified size.

    gcc/testsuite/ChangeLog:
            * gcc.dg/c23-tag-composite-11.c: New test.
            * gcc.dg/Warray-parameter-4.c: Resolve xfails.
            * gcc.dg/Wvla-parameter-2.c: Resolve xfails.
            * gcc.dg/Wvla-parameter-3.c: Resolve xfails.
            * gcc.dg/pr117145-1.c: New test.
            * gcc.dg/pr117145-2.c: New test.
            * gcc.dg/pr117245.c: New test.

Reply via email to