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

Gaius Mulley <gaius at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  Attachment #60236|0                           |1
        is obsolete|                            |

--- Comment #3 from Gaius Mulley <gaius at gcc dot gnu.org> ---
Created attachment 60285
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=60285&action=edit
PR-118600-Assigning-to-a-record-causes-alignment-exception-v4.patch

PR modula2/118600 Assigning to a record causes alignment exception

This patch recursively tests every assignment (of a constructor
to a designator) to ensure the types are GCC equivalent.  If they
are equivalent then it uses gimple assignment and if not then it
copies a structure by field and uses __builtin_strncpy to copy a
string cst into an array.  Unions are copied by __builtin_memcpy.

gcc/m2/ChangeLog:

        * gm2-compiler/M2GenGCC.mod (PerformCodeBecomes): New procedure.
        (CodeBecomes): Refactor and call PerformCodeBecomes.
        * gm2-gcc/m2builtins.cc (gm2_strncpy_node): New global variable.
        (DoBuiltinStrNCopy): New function.
        (m2builtins_BuiltinStrNCopy): New function.
        (m2builtins_init): Initialize gm2_strncpy_node.
        * gm2-gcc/m2builtins.def (BuiltinStrNCopy): New procedure
        function.
        * gm2-gcc/m2builtins.h (m2builtins_BuiltinStrNCopy): New
        function.
        * gm2-gcc/m2statement.cc (copy_record_fields): New function.
        (copy_array): Ditto.
        (copy_strncpy): Ditto.
        (copy_memcpy): Ditto.
        (CopyByField_Lower): Ditto.
        (m2statement_CopyByField): Ditto.
        * gm2-gcc/m2statement.def (CopyByField): New procedure function.
        * gm2-gcc/m2statement.h (m2statement_CopyByField): New function.
        * gm2-gcc/m2type.cc (check_record_fields): Ditto.
        (check_array_types): Ditto.
        (m2type_IsGccStrictTypeEquivalent): Ditto.
        * gm2-gcc/m2type.def (IsGccStrictTypeEquivalent): New procedure
        function.
        * gm2-gcc/m2type.h (m2type_IsAddress): Replace return type int
        with bool.

Reply via email to