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

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

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

commit r15-7668-ga2f60c1ff5a85497f84dc307301bcbc4bd77082e
Author: Gaius Mulley <gaiusm...@gmail.com>
Date:   Sat Feb 22 16:47:21 2025 +0000

    PR modula2/118978 ICE when attempting to pass an incompatible parameter

    This bugfix is for a an ICE which occurs if an incompatible parameter
    is passed to a procedure.  In particular if a REAL constant actual
    parameter is passed to INTEGER formal parameter then M2Range is invoked
    to check the type and then M2Range is called to check the value range.

    The value range check causes an ICE.  The bug fix introduces range
    dependencies on type checks.  If the type check fails an
    error message is generated and any future range check cancelled.
    These range and type checks are tightly coupled when generating
    parameter quad intermediate code.

    gcc/m2/ChangeLog:

            PR modula2/118978
            * gm2-compiler/M2Check.mod (checkConstMeta): Add check for
            typed constants.
            * gm2-compiler/M2Quads.mod (BoolFrame): New field RangeDep.
            (CheckProcedureParameters): Call PutRangeDep to associate the
            range dependency with the parameter on the quad stack.
            Pass ParamCheckId to CheckParameter.
            (CheckProcTypeAndProcedure): Add ParamCheckId parameter.
            Pass ParamCheckId to BuildRange.
            (CheckParameter): New parameter ParamCheckId.
            Pass ParamCheckId to CheckProcTypeAndProcedure.
            (CheckParameterOrdinals): Add extra range dep parameter to the
            call of InitParameterRangeCheck.
            (ConvertBooleanToVariable): Initialize RangeDep field.
            (PushBacktok): Ditto.
            (OperandRangeDep): New procedure.
            (PutRangeDep): Ditto.
            * gm2-compiler/M2Range.def (InitTypesParameterCheck): Add new
            parameter depRangeId.
            (InitParameterRangeCheck): Add new parameter parentRangeId.
            (FoldRangeCheck): Add new parameter range.
            * gm2-compiler/M2Range.mod (InitTypesParameterCheck): Add new
            parameter depRangeId.
            (InitParameterRangeCheck): Add new parameter parentRangeId.
            (FoldRangeCheck): Add new parameter range and rewrite.
            (FoldRangeCheckLower): New procedure.
            (Range): New field cancelled.
            New field dependantid.
            (PutRangeParam): Initialize dependantid.
            (PutRangeParamAssign): Ditto.
            (CheckCancelled): New procedure.
            (Cancel): Ditto.
            (IsCancelled): New procedure function.
            (FoldTypeParam): Add depRangeId parameter.
            (WriteRangeCheck): Add dependent debugging.

    gcc/testsuite/ChangeLog:

            PR modula2/118978
            * gm2/pim/fail/badparamtype.mod: New test.

    Signed-off-by: Gaius Mulley <gaiusm...@gmail.com>

Reply via email to