]> git.ipfire.org Git - thirdparty/gcc.git/commit
PR-107959 bugfix ICE detect attempt to create aggregate constant using bad type
authorGaius Mulley <gaiusmod2@gmail.com>
Sat, 3 Dec 2022 16:59:52 +0000 (16:59 +0000)
committerGaius Mulley <gaiusmod2@gmail.com>
Sat, 3 Dec 2022 16:59:52 +0000 (16:59 +0000)
commite171e6b291b5852e5802eefeb5f955419413b94e
tree910ae9d68fa8ef3df119c2f6be9caf2ab26d9fbb
parent2ed9ad9b914d96eb717a69dace7c9b4461cb0662
PR-107959 bugfix ICE detect attempt to create aggregate constant using bad type

The module below causes an ICE.

MODULE badipv4 ;
TYPE
  IPV4 = ARRAY [1..4] OF CHAR ;
CONST
  Loopback = IPV4 {127, 0, 0, 1} ;
END badipv4.

The fix was to replace the internal error with a failure boolean and
issue error messages based on the constructor.  It also required changes
propagating tokenno into the range checking code which is then passed
to M2ALU which generates the aggregate constant.

gcc/m2/ChangeLog:

* gm2-compiler/M2ALU.mod (CheckGetCharFromString): Return TRUE if
successful otherwise return FALSE and issue an error message.
Add extra parameter baseType.
(InitialiseArrayOfCharWith) Use CheckGetCharFromString and pass
baseType.
* gm2-compiler/M2Quads.def (StartBuildDefFile):
Add parameter tok.  (StartBuildModFile) Add parameter tok.
(EndBuildFile) Add parameter tok.
(StartBuildInit) Add parameter tok.
(EndBuildInit) Add parameter tok.
(StartBuildFinally) Add parameter tok.
(EndBuildFinally) Add parameter tok.
(BuildExceptInitial) Add parameter tok.
(BuildExceptInitial) Add parameter tok.
(BuildExceptFinally) Add parameter tok.
(BuildExceptProcedure) Add parameter tok.
(BuildReThrow) Add parameter tok.
(StartBuildInnerInit) Add parameter tok.
(EndBuildInnerInit) Add parameter tok.
(BuildModuleStart) Add parameter tok.
(BuildModuleStart) Add parameter tok.
* gm2-compiler/M2Quads.mod (ForLoopInfo): Redefined as a pointer
to record.  (ForInfo) Redefined as an Index.
(EndBuildFile) Add parameter tok.
(StartBuildInit) Add parameter tok.
(EndBuildInit) Add parameter tok.
(StartBuildFinally) Add parameter tok.
(EndBuildFinally) Add parameter tok.
(BuildExceptInitial) Add parameter tok.
(BuildExceptInitial) Add parameter tok.
(BuildExceptFinally) Add parameter tok.
(BuildExceptProcedure) Add parameter tok.
(BuildReThrow) Add parameter tok.
(StartBuildInnerInit) Add parameter tok.
(EndBuildInnerInit) Add parameter tok.
(BuildModuleStart) Add parameter tok.
(BuildModuleStart) Add parameter tok.
        (ForLoopAnalysis): Use ForInfo Indexing
procedures and ForLoopInfo to check for loops.
(AddForInfo): Reimplemented using ForInfo and
Indexing procedures.
(CheckForIndex): Pass ForLoopInfo parameter.
Reimplemented.
(BuildEndFor): Add parameter to AddForInfo.
* gm2-compiler/M2Range.mod (FoldAssignment):
Use tokenNo in the Range when declaring constant.
(FoldParameterAssign) Use tokenNo in the Range
when declaring constant.  (FoldReturn) Use tokenNo
in the Range when declaring constant.
        (FoldReturn) Use tokenNo
in the Range when declaring constant.
* gm2-compiler/P3Build.bnf (ProgramModule) pass module
token and end token to respective build procedures.
(ImplementationModule) pass module
token and end token to respective build procedures.
(Block) Pass token to build routines.
(InitialBlockBody) Pass token to build routines.
(FinalBlockBody) Pass token to build routines.
(ProcedureBlockBody) Pass token to build routines.
(ModuleDeclaration) Pass token to build routines.
(DefinitionModule) Pass token to build routines.
* gm2-compiler/PHBuild.bnf (ProgramModule) pass module
token and end token to respective build procedures.
(ImplementationModule) pass module
token and end token to respective build procedures.
(Block) Pass token to build routines.
(InitialBlockBody) Pass token to build routines.
(FinalBlockBody) Pass token to build routines.
(ProcedureBlockBody) Pass token to build routines.
(ModuleDeclaration) Pass token to build routines.
(DefinitionModule) Pass token to build routines.

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
gcc/m2/gm2-compiler/M2ALU.mod
gcc/m2/gm2-compiler/M2Quads.def
gcc/m2/gm2-compiler/M2Quads.mod
gcc/m2/gm2-compiler/M2Range.mod
gcc/m2/gm2-compiler/P3Build.bnf
gcc/m2/gm2-compiler/PHBuild.bnf
gcc/testsuite/gm2/iso/fail/badipv4.mod [new file with mode: 0644]