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

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

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

commit r15-7243-gefd21533974e260c6864b8f546cfa5abc55ceefa
Author: Jakub Jelinek <ja...@redhat.com>
Date:   Tue Jan 28 09:31:27 2025 +0100

    c: For array element type drop qualifiers but keep other properties of the
element type [PR116357]

    In the following testcase we error on the first case because it is
    trying to construct an array from overaligned type, but if there are
    qualifiers, we accept it silently (unlike in C++ which diagnoses all 3).

    The problem is that grokdeclarator if TYPE_QUALS (element_type) is
    non-zero just uses TYPE_MAIN_VARIANT; that loses not just the qualifiers
    but also attributes, alignment etc.

    The following patch uses c_build_qualified_type with TYPE_UNQUALIFIED
instead,
    which will be in the common case the same as TYPE_MAIN_VARIANT if the
    checks are satisfied for it, but if not, will look up different unqualified
    type or even create it if there is none.

    2025-01-28  Jakub Jelinek  <ja...@redhat.com>

            PR c/116357
            * c-decl.cc (grokdeclarator): Use c_build_qualified_type with
            TYPE_UNQUALIFIED instead of TYPE_MAIN_VARIANT.

            * gcc.dg/pr116357.c: New test.

Reply via email to