From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1499) id D06DA384AB56; Thu, 25 Apr 2024 14:23:35 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D06DA384AB56 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1714055015; bh=IgTUdn43yCIArUtG55dyzrR8geR6jhPA4rX2nHz/ATo=; h=From:To:Subject:Date:From; b=W6MslRpd2Bqg+JMq9DEy73WwzcFdr2qXgPrA3tsuKVKcs3aUecI1bEB95gVsYNVJ3 F7m5c8XQPrH63eFsEbAHIbZ0OMb8TfwYq64T4qdlHgcDMLM6lGKhMwKgmEiQu/hE1a Xx6PDMznXrTVf4m2lHNQ7ZjhMPoToczqgrGQNTxE= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Gaius Mulley To: gcc-cvs@gcc.gnu.org Subject: [gcc r14-10121] modula2: issue the parameter incompatibility error message based on dialect X-Act-Checkin: gcc X-Git-Author: Gaius Mulley X-Git-Refname: refs/heads/master X-Git-Oldrev: 59ff81835fee22a9d4c9a481a4d1814583aae945 X-Git-Newrev: 070dd5c883ec2c0be542f448bd82d0f7f0ead390 Message-Id: <20240425142335.D06DA384AB56@sourceware.org> Date: Thu, 25 Apr 2024 14:23:35 +0000 (GMT) List-Id: https://gcc.gnu.org/g:070dd5c883ec2c0be542f448bd82d0f7f0ead390 commit r14-10121-g070dd5c883ec2c0be542f448bd82d0f7f0ead390 Author: Gaius Mulley Date: Thu Apr 25 15:19:30 2024 +0100 modula2: issue the parameter incompatibility error message based on dialect This tiny patch improves the parameter incompatibility error message by having a different message for the dialect chosen mentioning the specific violation. PIM uses assignment rules for pass by value and expression rules for pass by reference. ISO uses expression type checking for pass by value and pass by reference. gcc/m2/ChangeLog: * gm2-compiler/M2FileName.def (CalculateFileName): Remove quoted string in comment. * gm2-compiler/M2Range.mod (FoldTypeParam): Generate dialect specific parameter incompatibility error message. Signed-off-by: Gaius Mulley Diff: --- gcc/m2/gm2-compiler/M2FileName.def | 2 +- gcc/m2/gm2-compiler/M2Range.mod | 32 +++++++++++++++++++++++++++----- 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/gcc/m2/gm2-compiler/M2FileName.def b/gcc/m2/gm2-compiler/M2FileName.def index 02413593003..01acb9b48d5 100644 --- a/gcc/m2/gm2-compiler/M2FileName.def +++ b/gcc/m2/gm2-compiler/M2FileName.def @@ -39,7 +39,7 @@ EXPORT QUALIFIED CalculateFileName, CalculateStemName, ExtractExtension ; given a module and an extension. This file name length will be operating system specific. String, Extension, is concatenated onto - Module and thus it is safe to `Mark' the extension + Module and thus it is safe to Mark the extension for garbage collection. *) diff --git a/gcc/m2/gm2-compiler/M2Range.mod b/gcc/m2/gm2-compiler/M2Range.mod index 4b8e5fadfe7..7686620a247 100644 --- a/gcc/m2/gm2-compiler/M2Range.mod +++ b/gcc/m2/gm2-compiler/M2Range.mod @@ -56,7 +56,7 @@ FROM M2Debug IMPORT Assert ; FROM Indexing IMPORT Index, InitIndex, InBounds, PutIndice, GetIndice ; FROM Storage IMPORT ALLOCATE ; FROM M2ALU IMPORT PushIntegerTree, PushInt, ConvertToInt, Equ, Gre, Less, GreEqu ; -FROM M2Options IMPORT VariantValueChecking, CaseEnumChecking ; +FROM M2Options IMPORT VariantValueChecking, CaseEnumChecking, GetPIM ; FROM M2Error IMPORT Error, InternalError, ErrorFormat0, ErrorFormat1, ErrorFormat2, FlushErrors, GetAnnounceScope ; @@ -1693,14 +1693,36 @@ END FoldTypeAssign ; (* - FoldTypeParam - + FoldTypeParam - performs a parameter check between actual and formal. + The quad is removed if the check succeeds. *) PROCEDURE FoldTypeParam (q: CARDINAL; tokenNo: CARDINAL; formal, actual, procedure: CARDINAL; paramNo: CARDINAL) ; +VAR + compatible: BOOLEAN ; BEGIN - IF ParameterTypeCompatible (tokenNo, - '{%4EN} parameter type failure between actual parameter type {%3ad} and the formal type {%2ad}', - procedure, formal, actual, paramNo, IsVarParam (procedure, paramNo)) + compatible := FALSE ; + IF IsVarParam (procedure, paramNo) + THEN + (* Expression type compatibility rules for pass by reference parameters. *) + compatible := ParameterTypeCompatible (tokenNo, + '{%4EN} parameter failure due to expression incompatibility ' + + 'between actual parameter {%3ad} and the {%4N} formal {%2ad} parameter in procedure {%1ad}', + procedure, formal, actual, paramNo, TRUE) + ELSIF GetPIM () + THEN + (* Assignment type compatibility rules for pass by value PIM parameters. *) + compatible := ParameterTypeCompatible (tokenNo, + '{%4EN} parameter failure due to assignment incompatibility ' + + 'between actual parameter {%3ad} and the {%4N} formal {%2ad} parameter in procedure {%1ad}', + procedure, formal, actual, paramNo, FALSE) + ELSE + compatible := ParameterTypeCompatible (tokenNo, + '{%4EN} parameter failure due to parameter incompatibility ' + + 'between actual parameter {%3ad} and the {%4N} formal {%2ad} parameter in procedure {%1ad}', + procedure, formal, actual, paramNo, FALSE) + END ; + IF compatible THEN SubQuad(q) END