]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
PR modula2/110003 Wrong source line listed for unused parameters
authorGaius Mulley <gaiusmod2@gmail.com>
Sat, 3 Jun 2023 14:27:58 +0000 (15:27 +0100)
committerGaius Mulley <gaiusmod2@gmail.com>
Sat, 3 Jun 2023 14:27:58 +0000 (15:27 +0100)
Ensure that the parameter token position is recorded for both
definition and implementation modules.  The shadow variable
is created inside BuildFormalParameterSection.  The shadow
variable needs to have the other definition or implementation module
token position set when CheckFormalParameterSection is called.
This allows the MetaError family of procedures to request the
implementation module token position when reporting unused parameters.

gcc/m2/ChangeLog:

PR modula2/110003
* gm2-compiler/P2SymBuild.mod (GetParameterShadowVar): Import.
(CheckFormalParameterSection): Call PutDeclared for the shadow
variable associated with the parameter.

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
gcc/m2/gm2-compiler/P2SymBuild.mod

index de56cc46c5c6b7525b9901c02ad74777b1d56ccf..98a51ea2ca12f4908796954b0f8e28b0e239b148 100644 (file)
@@ -59,7 +59,7 @@ FROM SymbolTable IMPORT NulSym,
                         MakeSubrange,
                         MakeVar, MakeType, PutType,
                         MakeModuleCtor,
-                        PutMode, PutDeclared,
+                        PutMode, PutDeclared, GetParameterShadowVar,
                         PutFieldEnumeration, PutSubrange, PutVar, PutConst,
                         PutConstSet, PutConstructor,
                         IsDefImp, IsType, IsRecord, IsRecordField, IsPointer,
@@ -1820,14 +1820,15 @@ BEGIN
                (* different parameter names *)
                FailParameter('',
                              'the parameter has been declared with a different name',
-                             OperandT(pi), ParamTotal+i, ProcSym)
+                             OperandT (pi), ParamTotal+i, ProcSym)
             END
          ELSE
-            IF GetSymName(ParamI)=NulName
+            IF GetSymName (ParamI) = NulName
             THEN
-               PutParamName (OperandTok (pi), ProcSym, ParamTotal+i, OperandT(pi))
+               PutParamName (OperandTok (pi), ProcSym, ParamTotal+i, OperandT (pi))
             END
          END ;
+         PutDeclared (OperandTok (pi), GetParameterShadowVar (ParamI)) ;
          IF Unbounded
          THEN
             (* GetType(ParamI) yields an UnboundedSym or a PartialUnboundedSym,