]> git.ipfire.org Git - thirdparty/gcc.git/commit
PR modula2/114295 Incorrect location if compiling implementation without definition
authorGaius Mulley <gaiusmod2@gmail.com>
Mon, 11 Mar 2024 15:21:42 +0000 (15:21 +0000)
committerGaius Mulley <gaiusmod2@gmail.com>
Mon, 11 Mar 2024 15:21:42 +0000 (15:21 +0000)
commit8410402272038aae7e4b2bd76df38607a78cad95
treeec575c9ca17829a63583aaf39a2250af5059a05c
parent4e1fcf44bdc582e71408175d75e025f5be8b0e55
PR modula2/114295 Incorrect location if compiling implementation without definition

This patch fixes a bug which occurred if gm2 was asked to compile an
implementation module and could not find the definition module.  The error
location would be set to the SYSTEM module.  The bug occurred as the
module sym was created during the peep phase after which the few tokens are
destroyed and recreated during parsing.  The bug fix is to call
PutDeclared when the module is encountered during parsing which updates
the tokenno associated with the module.

gcc/m2/ChangeLog:

PR modula2/114295
* gm2-compiler/M2Batch.mod (MakeProgramSource): Call PutDeclared
if the module is known.
(MakeDefinitionSource): Ditto.
(MakeImplementationSource): Ditto.
* gm2-compiler/M2Comp.mod (ExamineHeader): New procedure.
(ExamineCompilationUnit): Rewrite.
(PeepInto): Rewrite.
* gm2-compiler/M2Error.mod (NewError): Remove default call to
GetTokenNo.
* gm2-compiler/M2Quads.mod (callRequestDependant): Push tokno with
Adr.
(BuildStringAdrParam): Ditto.
(doBuildBinaryOp): Push OperatorPos on the bool stack.
(BuildRelOp): Ditto.
* gm2-compiler/P2Build.bnf (SetType): Pass set token pos to
BuildSetType.
(PointerType): Pass pointer token pos to BuildPointerType.
* gm2-compiler/P2SymBuild.def (BuildPointerType): Add parameter
pointerpos.
(BuildSetType): Add parameter setpos.
* gm2-compiler/P2SymBuild.mod (BuildPointerType): Add parameter
pointerpos.  Build combined token and use it when creating a
pointer type.
(BuildSetType): Add parameter setpos.  Build combined token and
use it when creating a set type.
* gm2-compiler/SymbolTable.mod (DebugUnknownToken): New constant.
(CheckTok): New procedure function.
(MakeProcedure): Call CheckTok.
(MakeRecord): Ditto.
(MakeVarient): Ditto.
(MakeEnumeration): Ditto.
(MakeHiddenType): Ditto.
(MakeConstant): Ditto.
(MakeConstStringCnul): Ditto.
(MakeSubrange): Ditto.
(MakeTemporary): Ditto.
(MakeVariableForParam): Ditto.
(MakeParameterHeapVar): Ditto.
(MakePointer): Ditto.
(MakeSet): Ditto.
(MakeUnbounded): Ditto.
(MakeProcType): Ditto.

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
gcc/m2/gm2-compiler/M2Batch.mod
gcc/m2/gm2-compiler/M2Comp.mod
gcc/m2/gm2-compiler/M2Error.mod
gcc/m2/gm2-compiler/M2Quads.mod
gcc/m2/gm2-compiler/P2Build.bnf
gcc/m2/gm2-compiler/P2SymBuild.def
gcc/m2/gm2-compiler/P2SymBuild.mod
gcc/m2/gm2-compiler/SymbolTable.mod