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

--- Comment #8 from CVS 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:644c2cc5f2c09506a7bfef293a7f90efa8d7e5fa

commit r12-1696-g644c2cc5f2c09506a7bfef293a7f90efa8d7e5fa
Author: Jakub Jelinek <ja...@redhat.com>
Date:   Mon Jun 21 13:30:42 2021 +0200

    inline-asm: Fix ICE with bitfields in "m" operands [PR100785]

    Bitfields, while they live in memory, aren't something inline-asm can
easily
    operate on.
    For C and "=m" or "+m", we were diagnosing bitfields in the past in the
    FE, where c_mark_addressable had:
          case COMPONENT_REF:
            if (DECL_C_BIT_FIELD (TREE_OPERAND (x, 1)))
              {
                error
                  ("cannot take address of bit-field %qD", TREE_OPERAND (x,
1));
                return false;
              }
    but that check got moved in GCC 6 to build_unary_op instead and now we
    emit an error during expansion and ICE afterwards (i.e. error-recovery).
    For "m" it used to be diagnosed in c_mark_addressable too, but since
    GCC 6 it is ice-on-invalid.
    For C++, this was never diagnosed in the FE, but used to be diagnosed
    in the gimplifier and/or during expansion before 4.8.

    The following patch does multiple things:
    1) diagnoses it in the FEs
    2) stops emitting a redundant diagnostic in the gimplifier using the
       usual way, if we already see error_mark_node, we assume error has
       been emitted already and only diagnose if it wasn't error_mark_node;
       this helps diagnosing the same bug with multiple different
       errors
    3) simplifies during expansion the inline asm if any errors have been
       reported (similarly how e.g. vregs pass if it detects errors on
       inline-asm either deletes them or simplifies to bare minimum -
       just labels), so that we don't have error-recovery ICEs there

    2021-06-11  Jakub Jelinek  <ja...@redhat.com>

            PR inline-asm/100785
    gcc/
            * gimplify.c (gimplify_asm_expr): Don't diagnose errors if
            output or input operands were already error_mark_node.
            * cfgexpand.c (expand_asm_stmt): If errors are emitted,
            remove all inputs, outputs and clobbers from the asm and
            set template to "".
    gcc/c/
            * c-typeck.c (c_mark_addressable): Diagnose trying to make
            bit-fields addressable.
    gcc/cp/
            * typeck.c (cxx_mark_addressable): Diagnose trying to make
            bit-fields addressable.
    gcc/testsuite/
            * c-c++-common/pr100785.c: New test.
            * gcc.dg/pr48552-1.c: Don't expect invalid lvalue errors.
            * gcc.dg/pr48552-2.c: Likewise.

Reply via email to