aboutsummaryrefslogtreecommitdiff
path: root/gcc/m2
AgeCommit message (Collapse)AuthorFilesLines
2023-06-09Daily bump.GCC Administrator1-0/+48
2023-06-09PR modula2/110126 variables are reported as unused when referenced by ASMGaius Mulley11-181/+280
This patches fixes two problems with the asm statement. gm2 -Wall -c fooasm3.mod generates an incorrect warning and gm2 cannot concatenate strings before an ASM statement. The asm statement now accepts a constant expression (rather than a string) and it updates the variable read/write use lists as appropriate. gcc/m2/ChangeLog: PR modula2/110126 * gm2-compiler/M2GenGCC.mod (BuildTreeFromInterface): Remove tokenno parameter. Use object tok instead of tokenno. (BuildTrashTreeFromInterface): Use object tok instead of GetDeclaredMod. (CodeInline): Remove tokenno from parameter list to BuildTreeFromInterface. * gm2-compiler/M2Quads.def (BuildAsmElement): Exported and defined. * gm2-compiler/M2Quads.mod (BuildOptimizeOff): Reformatted. (BuildInline): Reformatted. (BuildLineNo): Reformatted. (UseLineNote): Reformatted. (BuildAsmElement): New procedure. * gm2-compiler/P0SyntaxCheck.bnf (AsmOperands): Use ConstExpression instead of string. (AsmElement): Use ConstExpression instead of string. (TrashList): Use ConstExpression instead of string. * gm2-compiler/P1Build.bnf (AsmOperands): Use ConstExpression instead of string. (AsmElement): Use ConstExpression instead of string. (TrashList): Use ConstExpression instead of string. * gm2-compiler/P2Build.bnf (AsmOperands): Use ConstExpression instead of string. (AsmElement): Use ConstExpression instead of string. (TrashList): Use ConstExpression instead of string. * gm2-compiler/P3Build.bnf (AsmOperands): Rewrite. (AsmOperandSpec): Rewrite. (AsmOutputList): New rule. (AsmInputList): New rule. (TrashList): Rewrite. * gm2-compiler/PCBuild.bnf (AsmOperands): Use ConstExpression instead of string. (AsmElement): Use ConstExpression instead of string. (TrashList): Use ConstExpression instead of string. * gm2-compiler/PHBuild.bnf (AsmOperands): Use ConstExpression instead of string. (AsmElement): Use ConstExpression instead of string. (TrashList): Use ConstExpression instead of string. * gm2-compiler/SymbolTable.def (PutRegInterface): Rewrite interface. (GetRegInterface): Rewrite interface. * gm2-compiler/SymbolTable.mod (SetFirstUsed): New procedure. (PutFirstUsed): New procedure. (PutRegInterface): Rewrite. (GetRegInterface): Rewrite. gcc/testsuite/ChangeLog: PR modula2/110126 * gm2/pim/pass/fooasm3.mod: New test. Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
2023-06-08Daily bump.GCC Administrator1-0/+14
2023-06-07modula2: Fix bootstrapJakub Jelinek1-0/+2
internal-fn.h since yesterday includes insn-opinit.h, which is a generated header. One of my bootstraps today failed because some m2 sources started compiling before insn-opinit.h has been generated. Normally, gcc/Makefile.in has # In order for parallel make to really start compiling the expensive # objects from $(OBJS) as early as possible, build all their # prerequisites strictly before all objects. $(ALL_HOST_OBJS) : | $(generated_files) rule which ensures that all the generated files are generated before any $(ALL_HOST_OBJS) objects start, but use order-only dependency for this because we don't want to rebuild most of the objects whenever one generated header is regenerated. After the initial build in an empty directory we'll have .deps/ files contain the detailed dependencies. $(ALL_HOST_OBJS) includes even some FE files, I think in the m2 case would be m2_OBJS, but m2/Make-lang.in doesn't define those. The following patch just adds a similar rule to m2/Make-lang.in. Another option would be to set m2_OBJS variable in m2/Make-lang.in to something, but not really sure to which exactly and why it isn't done. 2023-06-07 Jakub Jelinek <jakub@redhat.com> * Make-lang.in: Build $(generated_files) before building all $(GM2_C_OBJS).
2023-06-07PR modula2/110019 Reported line numbers off by 1 when cpp invoked.Gaius Mulley3-10/+14
Fix off by one in m2.flex when the line number is set via cpp. gcc/m2/ChangeLog: PR modula2/110019 * gm2-compiler/SymbolKey.mod (SearchAndDo): Reformatted. (ForeachNodeDo): Reformatted. * gm2-compiler/SymbolTable.mod (AddListify): Join list with "," or "and" if more than one word is in the list. * m2.flex: Remove -1 from atoi(yytext) line number. gcc/testsuite/ChangeLog: PR modula2/110019 * gm2/cpp/fail/cpp-fail.exp: New test. * gm2/cpp/fail/foocpp.mod: New test. Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
2023-06-04Daily bump.GCC Administrator1-0/+7
2023-06-03PR modula2/110003 Wrong source line listed for unused parametersGaius Mulley1-4/+5
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>
2023-05-25Daily bump.GCC Administrator1-0/+11
2023-05-24PR modula2/109952 Inconsistent HIGH values with 'ARRAY OF CHAR'Gaius Mulley5-47/+60
This patch fixes the case when a single character constant literal is passed as a string actual parameter to an ARRAY OF CHAR formal parameter. To be consistent a single character is promoted to a string and nul terminated (and its high value is 1). Previously a single character string would not be nul terminated and the high value was 0. The documentation now includes a section describing the expected behavior and included in this patch is some regression test code matching the table inside the documentation. gcc/ChangeLog: PR modula2/109952 * doc/gm2.texi (High procedure function): New node. (Using): New menu entry for High procedure function. gcc/m2/ChangeLog: PR modula2/109952 * Make-maintainer.in: Change header to include emacs file mode. * gm2-compiler/M2GenGCC.mod (BuildHighFromChar): Check whether operand is a constant string and is nul terminated then return one. * gm2-compiler/PCSymBuild.mod (WalkFunction): Add default return TRUE. Static analysis missing return path fix. * gm2-libs/IO.mod (Init): Rewrite to help static analysis. * target-independent/m2/gm2-libs.texi: Rebuild. gcc/testsuite/ChangeLog: PR modula2/109952 * gm2/pim/run/pass/hightests.mod: New test. Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
2023-05-20Daily bump.GCC Administrator1-0/+5
2023-05-19PR modula2/109908 Delete from m2iso Strings is brokenGaius Mulley1-10/+48
This patch re-implements Strings.Delete and also supplies some runtime test code. gcc/m2/ChangeLog: PR modula2/109908 * gm2-libs-iso/Strings.mod (Delete): Re-implement. gcc/testsuite/ChangeLog: PR modula2/109908 * gm2/isolib/run/pass/testdelete.mod: New test. Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
2023-05-19Daily bump.GCC Administrator1-0/+18
2023-05-18m2: use _P() defines from tree.hBernhard Reutner-Fischer7-19/+19
gcc/m2/ChangeLog: * gm2-gcc/m2builtins.cc (doradix): Use _P defines from tree.h. (doplaces): Ditto. (doexponentmin): Ditto. (doexponentmax): Ditto. (dolarge): Ditto. (dosmall): Ditto. (dogUnderflow): Ditto. * gm2-gcc/m2convert.cc (unsafe_conversion_p): Ditto. * gm2-gcc/m2expr.cc (m2expr_build_unary_op_check): Ditto. (m2expr_build_binary_op_check): Ditto. * gm2-gcc/m2tree.cc (m2tree_is_var): Ditto. * gm2-gcc/m2treelib.cc (build_modify_expr): Ditto. * gm2-gcc/m2type.cc (gm2_finish_decl): Ditto. * m2pp.cc (hextree): Ditto. (m2pp_call_expr): Ditto.
2023-05-18Daily bump.GCC Administrator1-0/+11
2023-05-17WriteInt in the ISO libraries should not emit '+' for positive valuesGaius Mulley4-12/+12
This trivial patch changes the default behaviour for WriteInt so that '+' is not emitted when writing positive values. gcc/m2/ChangeLog: * gm2-libs-iso/LongWholeIO.mod (WriteInt): Only request a sign if the value is < 0. * gm2-libs-iso/ShortWholeIO.mod (WriteInt): Only request a sign if the value is < 0. * gm2-libs-iso/WholeIO.mod (WriteInt): Only request a sign if the value is < 0. * gm2-libs-iso/WholeStr.mod (WriteInt): Only request a sign if the value is < 0. Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
2023-05-17Daily bump.GCC Administrator1-0/+21
2023-05-17PR modula2/109879 WholeIO.ReadCard and ReadInt should consume leading spaceGaius Mulley8-38/+113
The Read{TYPE} procedures in LongIO, LongWholeIO, RealIO, ShortWholeIO and WholeIO all require skip space functionality. A new module TextUtil is supplied with this functionality and the previous modules have been changed to call SkipSpaces. gcc/m2/ChangeLog: PR modula2/109879 * gm2-libs-iso/LongIO.mod (ReadReal): Call SkipSpaces. * gm2-libs-iso/LongWholeIO.mod (ReadInt): Call SkipSpaces. (ReadCard): Call SkipSpaces. * gm2-libs-iso/RealIO.mod (ReadReal): Call SkipSpaces. * gm2-libs-iso/ShortWholeIO.mod: (ReadInt): Call SkipSpaces. (ReadCard): Call SkipSpaces. * gm2-libs-iso/TextIO.mod: Import SkipSpaces. * gm2-libs-iso/WholeIO.mod (ReadInt): Call SkipSpaces. (ReadCard): Call SkipSpaces. * gm2-libs-iso/TextUtil.def: New file. * gm2-libs-iso/TextUtil.mod: New file. libgm2/ChangeLog: PR modula2/109879 * Makefile.in: Regenerate. * aclocal.m4: Regenerate. * libm2cor/Makefile.in: Regenerate. * libm2iso/Makefile.am (M2DEFS): Add TextUtil.def. (M2MODS): Add TextUtil.mod. * libm2iso/Makefile.in: Regenerate. * libm2log/Makefile.in: Regenerate. * libm2min/Makefile.in: Regenerate. * libm2pim/Makefile.in: Regenerate. gcc/testsuite/ChangeLog: PR modula2/109879 * gm2/isolib/run/pass/testreadint.mod: New test. Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
2023-05-16PR modula2/108344 disable default opening of /dev/ttyGaius Mulley1-17/+20
This patch changes removes the static initialisation code for KeyBoardLEDs.cc. The module is only initialised if one of the exported functions is called. This is useful as the module will access /dev/tty which might not be available. TimerHandler.mod has also been changed to disable the scroll lock LED as a sign of life. gcc/m2/ChangeLog: PR modula2/108344 * gm2-libs-coroutines/TimerHandler.mod (EnableLED): New constant. (Timer): Test EnableLED before switching on the scroll LED. libgm2/ChangeLog: PR modula2/108344 * libm2cor/KeyBoardLEDs.cc (initialize_module): New function. (SwitchScroll): Call initialize_module. (SwitchNum): Call initialize_module. (SwitchCaps): Call initialize_module. (SwitchLEDs): Call initialize_module. (M2EXPORT): Remove initialization code. Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
2023-05-13Daily bump.GCC Administrator1-0/+9
2023-05-12PR modula2/109830 m2iso library SeqFile.mod appending to a file overwrites ↵Gaius Mulley1-21/+24
content This patch is for the m2iso library SeqFile.mod to fix a bug when a file is opened using OpenAppend. The patch checks to see if the file exists and it uses FIO.OpenForRandom to ensure the file is not overwritten. gcc/m2/ChangeLog: PR modula2/109830 * gm2-libs-iso/SeqFile.mod (newCid): New parameter toAppend used to select FIO.OpenForRandom. (OpenRead): Pass extra parameter to newCid. (OpenWrite): Pass extra parameter to newCid. (OpenAppend): Pass extra parameter to newCid. gcc/testsuite/ChangeLog: PR modula2/109830 * gm2/isolib/run/pass/seqappend.mod: New test. Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
2023-05-12Daily bump.GCC Administrator1-0/+25
2023-05-12PR modula2/109810 ICE fix when an array is assigned by a larger stringGaius Mulley5-139/+176
This patch fixes an ICE when an array variable is assigned with a string which exceeds the array size. It improves the accuracy of the virtual token used to indicate the error message. gcc/m2/ChangeLog: PR modula2/109810 * gm2-compiler/M2ALU.mod (ConvertConstToType): Use PrepareCopyString in place of DoCopyString. * gm2-compiler/M2GenGCC.def (DoCopyString): Rename to ... (PrepareCopyString): ... this. * gm2-compiler/M2GenGCC.mod (CodeStatement): Call CodeReturnValue with a single parameter. Call CodeXIndr with a single parameter. (CodeReturnValue): Remove parameters and replace with a single quadno. Reimplement using PrepareCopyString. Issue error if the string exceeds designator space. (DoCopyString): Reimplement and rename to ... (PrepareCopyString): ... this. (CodeXIndr): Remove parameters and replace with a single quadno. Reimplement using PrepareCopyString. Issue error if the string exceeds designator space. (CodeBecomes): Remove parameters and replace with a single quadno. Reimplement using PrepareCopyString. Issue error if the string exceeds designator space. * gm2-compiler/M2Quads.def (BuildReturn): Rename parameter to tokreturn. * gm2-compiler/M2Quads.mod (BuildReturn): Rename parameter to tokreturn. Rename tokno to tokcombined. gcc/testsuite/ChangeLog: PR modula2/109810 * gm2/pim/fail/highice.mod: New test. Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
2023-05-10Daily bump.GCC Administrator1-0/+17
2023-05-09PR modula2/109779 isolib SkipLine skips the first character of the ↵Gaius Mulley2-67/+89
successive line This is a patch for the m2iso library to prevent SkipLine from consuming the next character on the next line. gcc/m2/ChangeLog: PR modula2/109779 * gm2-libs-iso/RTgen.mod (doLook): Remove old. Remove re-assignment of result. * gm2-libs-iso/TextIO.mod (CanRead): Rename into ... (CharAvailable): ... this. (DumpState): New procedure. (SetResult): Rename as SetNul. (WasGoodChar): Rename into ... (EofOrEoln): ... this. (SkipLine): Skip over the newline. (ReadString): Flip THEN ELSE statements after testing for EofOrEoln. (ReadRestLine): Flip THEN ELSE statements after testing for EofOrEoln. gcc/testsuite/ChangeLog: PR modula2/109779 * gm2/isolib/run/pass/skiplinetest.mod: New test. Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
2023-05-05Daily bump.GCC Administrator1-0/+127
2023-05-04PR modula2/109729 cannot use a CHAR type as a FOR loop iteratorGaius Mulley3-30/+52
This patch introduces a new quadruple ArithAddOp which is used in the construction of FOR loop to ensure that when constant folding is applied it does not concatenate two constant char operands into a string constant. Overloading only occurs with constant operands. gcc/m2/ChangeLog: PR modula2/109729 * gm2-compiler/M2GenGCC.mod (CodeStatement): Detect ArithAddOp and call CodeAddChecked. (ResolveConstantExpressions): Detect ArithAddOp and call FoldArithAdd. (FoldArithAdd): New procedure. (FoldAdd): Refactor to use FoldArithAdd. * gm2-compiler/M2Quads.def (QuadOperator): Add ArithAddOp. * gm2-compiler/M2Quads.mod: Remove commented imports. (QuadFrame): Changed comments to use GNU coding standards. (ArithPlusTok): New global variable. (BuildForToByDo): Use ArithPlusTok instead of PlusTok. (MakeOp): Detect ArithPlusTok and return ArithAddOp. (WriteQuad): Add ArithAddOp clause. (WriteOperator): Add ArithAddOp clause. (Init): Initialize ArithPlusTok. gcc/testsuite/ChangeLog: PR modula2/109729 * gm2/pim/run/pass/ForChar.mod: New test. Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
2023-05-04PR modula2/109675 implementation of writeAddress is non portableGaius Mulley92-1134/+1139
The implementation of gcc/m2/gm2-libs/DynamicStrings.mod:writeAddress is non portable as it casts a void * into an unsigned long int. This procedure has been re-implemented to use snprintf. As it is a library the support tools 'mc' and 'pge' have been rebuilt. There have been linking changes in the library and the underlying boolean type is now bool since the last rebuild hence the size of the patch. gcc/m2/ChangeLog: PR modula2/109675 * Make-lang.in (MC-LIB-DEFS): Remove M2LINK.def. (BUILD-PGE-O): Remove GM2LINK.o. * Make-maintainer.in (PPG-DEFS): New define. (PPG-LIB-DEFS): Remove M2LINK.def. (BUILD-BOOT-PPG-H): Add PPGDEF .h files. (m2/ppg$(exeext)): Remove M2LINK.o (PGE-DEPS): New define. (m2/pg$(exeext)): Remove M2LINK.o. (m2/gm2-pge-boot/$(SRC_PREFIX)%.o): Add -Im2/gm2-pge-boot. (m2/pge$(exeext)): Remove M2LINK.o. (pge-maintainer): Re-implement. (pge-libs-push): Re-implement. (m2/m2obj3/cc1gm2$(exeext)): Remove M2LINK.o. * gm2-libs/DynamicStrings.mod (writeAddress): Re-implement using snprintf. * gm2-libs/M2Dependent.mod: Remove commented out imports. * mc-boot/GDynamicStrings.cc: Rebuild. * mc-boot/GFIO.cc: Rebuild. * mc-boot/GFormatStrings.cc: Rebuild. * mc-boot/GM2Dependent.cc: Rebuild. * mc-boot/GM2Dependent.h: Rebuild. * mc-boot/GM2RTS.cc: Rebuild. * mc-boot/GM2RTS.h: Rebuild. * mc-boot/GRTExceptions.cc: Rebuild. * mc-boot/GRTint.cc: Rebuild. * mc-boot/GSFIO.cc: Rebuild. * mc-boot/GStringConvert.cc: Rebuild. * mc-boot/Gdecl.cc: Rebuild. * pge-boot/GASCII.cc: Rebuild. * pge-boot/GASCII.h: Rebuild. * pge-boot/GArgs.cc: Rebuild. * pge-boot/GArgs.h: Rebuild. * pge-boot/GAssertion.cc: Rebuild. * pge-boot/GAssertion.h: Rebuild. * pge-boot/GBreak.h: Rebuild. * pge-boot/GCmdArgs.h: Rebuild. * pge-boot/GDebug.cc: Rebuild. * pge-boot/GDebug.h: Rebuild. * pge-boot/GDynamicStrings.cc: Rebuild. * pge-boot/GDynamicStrings.h: Rebuild. * pge-boot/GEnvironment.h: Rebuild. * pge-boot/GFIO.cc: Rebuild. * pge-boot/GFIO.h: Rebuild. * pge-boot/GFormatStrings.h:: Rebuild. * pge-boot/GFpuIO.h:: Rebuild. * pge-boot/GIO.cc: Rebuild. * pge-boot/GIO.h: Rebuild. * pge-boot/GIndexing.cc: Rebuild. * pge-boot/GIndexing.h: Rebuild. * pge-boot/GLists.cc: Rebuild. * pge-boot/GLists.h: Rebuild. * pge-boot/GM2Dependent.cc: Rebuild. * pge-boot/GM2Dependent.h: Rebuild. * pge-boot/GM2EXCEPTION.cc: Rebuild. * pge-boot/GM2EXCEPTION.h: Rebuild. * pge-boot/GM2RTS.cc: Rebuild. * pge-boot/GM2RTS.h: Rebuild. * pge-boot/GNameKey.cc: Rebuild. * pge-boot/GNameKey.h: Rebuild. * pge-boot/GNumberIO.cc: Rebuild. * pge-boot/GNumberIO.h: Rebuild. * pge-boot/GOutput.cc: Rebuild. * pge-boot/GOutput.h: Rebuild. * pge-boot/GPushBackInput.cc: Rebuild. * pge-boot/GPushBackInput.h: Rebuild. * pge-boot/GRTExceptions.cc: Rebuild. * pge-boot/GRTExceptions.h: Rebuild. * pge-boot/GSArgs.h: Rebuild. * pge-boot/GSEnvironment.h: Rebuild. * pge-boot/GSFIO.cc: Rebuild. * pge-boot/GSFIO.h: Rebuild. * pge-boot/GSYSTEM.h: Rebuild. * pge-boot/GScan.h: Rebuild. * pge-boot/GStdIO.cc: Rebuild. * pge-boot/GStdIO.h: Rebuild. * pge-boot/GStorage.cc: Rebuild. * pge-boot/GStorage.h: Rebuild. * pge-boot/GStrCase.cc: Rebuild. * pge-boot/GStrCase.h: Rebuild. * pge-boot/GStrIO.cc: Rebuild. * pge-boot/GStrIO.h: Rebuild. * pge-boot/GStrLib.cc: Rebuild. * pge-boot/GStrLib.h: Rebuild. * pge-boot/GStringConvert.h: Rebuild. * pge-boot/GSymbolKey.cc: Rebuild. * pge-boot/GSymbolKey.h: Rebuild. * pge-boot/GSysExceptions.h: Rebuild. * pge-boot/GSysStorage.cc: Rebuild. * pge-boot/GSysStorage.h: Rebuild. * pge-boot/GTimeString.h: Rebuild. * pge-boot/GUnixArgs.h: Rebuild. * pge-boot/Gbnflex.cc: Rebuild. * pge-boot/Gbnflex.h: Rebuild. * pge-boot/Gdtoa.h: Rebuild. * pge-boot/Gerrno.h: Rebuild. * pge-boot/Gldtoa.h: Rebuild. * pge-boot/Glibc.h: Rebuild. * pge-boot/Glibm.h: Rebuild. * pge-boot/Gpge.cc: Rebuild. * pge-boot/Gtermios.h: Rebuild. * pge-boot/Gwrapc.h: Rebuild. * mc-boot/GM2LINK.h: Removed. * pge-boot/GM2LINK.cc: Removed. * pge-boot/GM2LINK.h: Removed. Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
2023-05-01Daily bump.GCC Administrator1-0/+16
2023-04-30Remove duplicate constants created between passesGaius Mulley2-65/+167
There is no need to re-create constant literals between passes. This patch creates a constant pool and reuses a constant literal providing it is created at the same location. This in turn avoids generating duplicate overflow error messages when encountering an out of range constant literal. gcc/m2/ChangeLog: * gm2-compiler/SymbolTable.mod (ConstLitPoolEntry): New pointer to record. (ConstLitSym): New field RangeError. (ConstLitPoolTree): New SymbolTree representing name to index. (ConstLitArray): New dynamic array containing pointers to a ConstLitPoolEntry. (CreateConstLit): New procedure function. (LookupConstLitPoolEntry): New procedure function. (AddConstLitPoolEntry): New procedure function. (MakeConstLit): Re-implemented to check the constant lit pool before calling CreateConstLit. * m2.flex: Add ability to decode binary constant literals. gcc/testsuite/ChangeLog: * gm2/pim/run/pass/constlitbase.mod: New test. Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
2023-04-27Daily bump.GCC Administrator1-0/+27
2023-04-26PR modula2/108121 Re-implement overflow detection for constant literalsGaius Mulley10-353/+180
This patch fixes the overflow detection for constant literals. The ZTYPE is changed to int128 (or int64) if int128 is unavailable and constant literals are built from widest_int. The widest_int is converted into the tree type and checked for overflow. m2expr_interpret_integer and append_m2_digit are removed. gcc/m2/ChangeLog: PR modula2/108121 * gm2-compiler/M2ALU.mod (Less): Reformatted. * gm2-compiler/SymbolTable.mod (DetermineSizeOfConstant): Remove from import. (ConstantStringExceedsZType): Import. (GetConstLitType): Re-implement using ConstantStringExceedsZType. * gm2-gcc/m2decl.cc (m2decl_DetermineSizeOfConstant): Remove. (m2decl_ConstantStringExceedsZType): New function. (m2decl_BuildConstLiteralNumber): Re-implement. * gm2-gcc/m2decl.def (DetermineSizeOfConstant): Remove. (ConstantStringExceedsZType): New function. * gm2-gcc/m2decl.h (m2decl_DetermineSizeOfConstant): Remove. (m2decl_ConstantStringExceedsZType): New function. * gm2-gcc/m2expr.cc (append_digit): Remove. (m2expr_interpret_integer): Remove. (append_m2_digit): Remove. (m2expr_StrToWideInt): New function. (m2expr_interpret_m2_integer): Remove. * gm2-gcc/m2expr.def (CheckConstStrZtypeRange): New function. * gm2-gcc/m2expr.h (m2expr_StrToWideInt): New function. * gm2-gcc/m2type.cc (build_m2_word64_type_node): New function. (build_m2_ztype_node): New function. (m2type_InitBaseTypes): Call build_m2_ztype_node. * gm2-lang.cc (gm2_type_for_size): Re-write using early returns. gcc/testsuite/ChangeLog: PR modula2/108121 * gm2/pim/fail/largeconst.mod: Increased constant value test to fail now that cc1gm2 uses widest_int to represent a ZTYPE. * gm2/pim/fail/largeconst2.mod: New test. Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
2023-04-22Daily bump.GCC Administrator1-0/+11
2023-04-21gcc/m2: Drop references to $(P)Arsen Arsenović2-3/+3
$(P) seems to have been a workaround for some old, proprietary make implementations that we no longer support. It was removed in r0-31149-gb8dad04b688e9c. gcc/m2/ChangeLog: * Make-lang.in: Remove references to $(P). * Make-maintainer.in: Ditto.
2023-04-21PR modula2/109586 cc1gm2 ICE when compiling large source files.Gaius Mulley1-2/+2
The function m2block_RememberConstant calls m2tree_IsAConstant. However IsAConstant does not recognise TREE_CODE(t) == CONSTRUCTOR as a constant. Without this patch CONSTRUCTOR contants are garbage collected (and not preserved) resulting in a corrupt tree and crash. gcc/m2/ChangeLog: PR modula2/109586 * gm2-gcc/m2tree.cc (m2tree_IsAConstant): Add (TREE_CODE (t) == CONSTRUCTOR) to expression. Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
2023-04-14Daily bump.GCC Administrator1-0/+20
2023-04-13PR modula2/109488 Typo in lang.opt: libraries maybeGaius Mulley1-1/+1
Correct spelling of "maybe" to "may be" in the modula-2 language options. gcc/m2/ChangeLog: PR modula2/109488 * lang.opt: Fix typo "maybe" to "may be". Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
2023-04-13PR modula2/109496 Fix constant char parameter passing to an array of charGaius Mulley8-25/+117
This patch fixes PR modula2/109496 and PR modula2/109497. The fix for PR modula2/109496 promotes a char constant to a string. The PR modula2/109497 allows for constant chars to be added to form a string. The fixes for both PR's occur in M2GenGCC.mod and M2GCCDeclare.mod after the resolving of constant declarations. gcc/m2/ChangeLog: * gm2-compiler/M2ALU.def (PopChar): New procedure function. * gm2-compiler/M2ALU.mod (PopChar): New procedure function. * gm2-compiler/M2GCCDeclare.mod (PromoteToString): Detect a single constant char and build a C string. * gm2-compiler/M2GenGCC.mod (IsConstStr): New procedure function. (GetStr): New procedure function. (FoldAdd): Use IsConstStr. * gm2-compiler/M2Quads.mod: Formatting changes. * gm2-gcc/m2expr.cc (m2expr_GetCstInteger): New function. * gm2-gcc/m2expr.def (GetCstInteger): New procedure function. * gm2-gcc/m2expr.h (m2expr_GetCstInteger): New prototype. gcc/testsuite/ChangeLog: PR modula2/109497 * gm2/pim/run/pass/addcharconst.mod: New test. PR modula2/109496 * gm2/pim/run/pass/singlechar.mod: New test. Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
2023-04-06Daily bump.GCC Administrator1-0/+32
2023-04-05PR modula2/109423 cc1gm2 ICE if an INCL or EXCL is performed on an unknown setGaius Mulley14-32/+14
This patch fixes an ICE if attempting to INCL or EXCL on an unknown set. The fix was to correct an error format string. Also included in the patch are patches to remove unused variables. The patch also marks a variable as written in BuildAdr. gcc/m2/ChangeLog: PR modula2/109423 * gm2-compiler/M2Base.def (Unbounded): Remove. * gm2-compiler/M2Error.def (ErrorAbort0): Add noreturn attribute. * gm2-compiler/M2Quads.mod (BuildInclProcedure): Correct error format string. (BuildExceptProcedure): Correct error format string. (BuildAdrFunction): Call PutWriteQuad when taking the address of a variable. * gm2-libs-ch/SysExceptions.c (_M2_SysExceptions_init): Add parameters. * gm2-libs-ch/wrapc.c (_M2_wrapc_init): Add parameters. * gm2-libs/DynamicStrings.mod (DumpStringInfo): Remove t. (PopAllocationExemption): Remove f. * gm2-libs/FIO.mod (BufferedWrite): Remove result. * gm2-libs/FormatStrings.mod (Copy): Remove endpos and afterperc. (HandlePercent): Remove result. * gm2-libs/Indexing.mod (RemoveIndiceFromIndex): Remove k. * gm2-libs/M2Dependent.mod (CreateModule): Remove p0 and p1. (DumpModuleData): Remove mptr. (ConstructModules): Remove nulp. * gm2-libs/RTExceptions.mod (PopHandler): Remove i. * gm2-libs/RTint.mod (Listen): Remove b4s, b4m, afs and afm. * gm2-libs/SFIO.mod (ReadS): Remove c. * gm2-libs/StringConvert.mod (doDecimalPlaces): Remove whole and fraction. gcc/testsuite/ChangeLog: * gm2/pim/fail/setunknown.mod: New test. PR modula2/109423 * gm2/pim/fail/setunknown2.mod: New test. Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
2023-04-04Daily bump.GCC Administrator1-0/+13
2023-04-03PR modula2/109388 clang warnings related to Modula-2Gaius Mulley2-157/+11
This patch removes an unused parameter 'module' from DoVariableDeclaration in M2GCCDeclare.mod. It also removes unused procedures from PHBuild.bnf. gcc/m2/ChangeLog: PR modula2/109388 * gm2-compiler/M2GCCDeclare.mod (DoVariableDeclaration): Remove second parameter module. Adjust all callers to remove the second parameter. * gm2-compiler/PHBuild.bnf (CheckAndInsert): Remove. (InStopSet): Remove. (PeepToken): Remove. (PushQualident): Remove. (SimpleDes): Remove. (ActualParameters): Remove. Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
2023-04-03Daily bump.GCC Administrator1-0/+19
2023-04-02PR modula2/109336 pass -fmod= though and build m2/stage2/cc1gm2 libsGaius Mulley5-14/+45
This patch enables gm2 to pass -fmod= though to cc1gm2. It also builds the libraries for m2/stage2/cc1gm2 with no named path and full debugging. gcc/m2/ChangeLog: PR modula2/109336 * Make-lang.in (GM2_O): Set to -O0. (GM2_LIBS): Remove target libraries and replace with build libs. (BUILD-LIBS): New declaration. (m2/gm2-libs/libgm2.a): New rule. (m2/gm2-libs/%.o): New rule. (m2/gm2-libs/choosetemp.o): New rule. * gm2-compiler/M2ColorString.mod (append): Use ADR rather than implicit conversion. * gm2-compiler/M2Comp.mod (Compile): Add qprintf messages for when a source file is not found. Improve comments and formatting. * gm2-libs-ch/cgetopt.c (cgetopt_cgetopt_long): Remove ansi-decl.h. Add getopt.h. (cgetopt_cgetopt_long_only): Change cgetopt_ to getopt_. * gm2spec.cc (lang_specific_driver): Do not skip -fmod=. Remove comment. Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
2023-03-30Daily bump.GCC Administrator1-0/+29
2023-03-29PR modula2/109336 - The -fmod= and -fdef= options do not workGaius Mulley6-40/+106
The -fmod= and -fdef= options do not work. After the linking re-implementation and subsequent restructuring the -fmod= amd -fdef= are now broken. This patch adds -fmod= and -fdef= processing into gm2spec.cc. It also reduces the complexity of extension handling within M2Search by storing the preceeding "." in the extension. gcc/m2/ChangeLog: PR modula2/109336 PR modula2/109315 * gm2-compiler/M2FileName.mod (CalculateFileName): Simplified by ensuring the extension contains the ".". (CalculateStemName): Re-formatted. (ExtractExtension): Re-formatted. (ExtractModule): Re-formatted. * gm2-compiler/M2Options.def (setdefextension): Add block comment. (setmodextension): Add block comment. Re-formatted. * gm2-compiler/M2Options.mod (setdefextension): Add block comment. (setmodextension): Add block comment. Re-formatted. * gm2-compiler/M2Search.mod (FindSourceDefFile): Use DefaultDefExt. (DefaultDefExt): New constant. (DefaultModExt): New constant. (FindSourceModFile): Use DefaultModExt. * gm2-gcc/m2decl.cc (m2decl_DeclareKnownVariable): Correct spelling. * gm2spec.cc (M2SOURCE): New constant. (LANGSPEC): New value. (MATHLIB): New value. (WITHLIBC): New value. (SKIPOPT): New value. (lang_specific_driver): Replace seen_module_extension bool with module_extension char *. Detect -fmod= and remember extension. Use the extension to detect modula-2 source and mark it as such. gcc/testsuite/ChangeLog: PR modula2/109336 * gm2/link/nondefaultext/pass/hello.md: New test. * gm2/link/nondefaultext/pass/liba.dm: New test. * gm2/link/nondefaultext/pass/liba.md: New test. * gm2/link/nondefaultext/pass/link-nondefaultext-pass.exp: New test. Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
2023-03-24Daily bump.GCC Administrator1-0/+31
2023-03-23PR modula2/109264 Bugfix resolve opaque types containing setsGaius Mulley6-80/+206
Resolve opaque type handling. The bug is caused by the compiler attempting to resolve the meta types of a constant constructor. It incorrectly attempts to get the type on an enumeration type (resulting in NulSym) which causes the meta resolver to spin. Some PHBuild rules (building records need to be copied from P3Build so that hidden types are resolved in order across the compile. gcc/m2/ChangeLog: PR modula2/109264 * gm2-compiler/M2Quads.mod (BuildConstFunctionCall): Comment out ErrorString in debugging block. (BuildConstructorStart): Replace Assert with a call to MetaErrorT3. Import MetaErrorT3. * gm2-compiler/PCSymBuild.mod (buildConstFunction): Rename local variables. (WalkFunctionParam): Remove test for IsEnumeration when resolving MIN or MAX parameters. * gm2-compiler/PHBuild.bnf (BlockAssert): New procedure. (ErrorArrayat): New procedure. (Expect): Renamed parameter t to tok. (PushQualident): New rule. (ConstSetOrQualidentOrFunction): Force AutoOn. (TypeDeclaration): Add debugging assert. (SimpleType): Add debugging assert. (DefaultRecordAttributes): New rule (and bugfix). (FieldPragmaExpression): New rule (and bugfix). (PragmaConstExpression): New rule (and bugfix). (SetOrDesignatorOrFunction): Add debugging assert. (Block): Add debugging assert. * gm2-gcc/m2expr.cc (m2expr_ConstantExpressionWarning): int to bool. * gm2-gcc/m2expr.h (m2expr_TreeOverflow): int to bool. (m2expr_GetBooleanTrue): Remove. (m2expr_GetBooleanFalse): Remove. * gm2-gcc/m2options.h (M2Options_SetStatistics): Replace int with bool. gcc/testsuite/ChangeLog: PR modula2/109264 * gm2/iso/extended-opaque/pass/iso-extended-opaque-pass.exp: New test. * gm2/iso/extended-opaque/pass/stressset.def: New test. * gm2/iso/extended-opaque/pass/stressset.mod: New test. * gm2/iso/extended-opaque/pass/testset.mod: New test. * gm2/projects/iso/small/run/pass/iso-extended-opaque-run-pass.exp: New test. * gm2/projects/iso/small/run/pass/stressset.def: New test. * gm2/projects/iso/small/run/pass/stressset.mod: New test. * gm2/projects/iso/small/run/pass/test1.mod: New test. * gm2/projects/iso/small/run/pass/testlib.def: New test. * gm2/projects/iso/small/run/pass/testlib.mod: New test. * gm2/projects/iso/small/run/pass/testset.mod: New test. Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
2023-03-23Daily bump.GCC Administrator1-0/+53
2023-03-22modula2: Add cwd to include path. Include m2cor before m2pim.Gaius Mulley2-4/+13
The driver should default to include the current working directory in the module search path. This patch adds . to the search path provided -fm2-pathname has not been specified. The patch also reorders the pim libraries so that the m2cor directory is searched before m2pim. Coroutine support is visible by default for both -fpim and -fiso (from their respective SYSTEM modules). gcc/m2/ChangeLog: PR modula2/109248 * Make-lang.in (m2/pge-boot/%.o): Add CFLAGS and CXXFLAGS for C and C++ compiles. * gm2spec.cc (add_m2_I_path): Indentation. (lang_specific_driver): New variable seen_pathname. Detect -fm2-pathname. If not seen then push_back_Ipath ("."). Change non iso library path to "m2cor,m2log,m2pim,m2iso". Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
2023-03-22PR modula2/107630 Remove M2LINK and remove some cross linkingGaius Mulley14-243/+71
Remove M2LINK.def. Pass the user forced module initialization string as a parameter to M2RTS.ConstructModules. This patch allows -fm2-whole-program to link successfully using dynamic libraries. gcc/m2/ChangeLog: PR modula2/107630 * Make-lang.in (m2/stage2/cc1gm2$(exeext)): Remove m2/gm2-libs-boot/M2LINK.o. (m2/stage1/cc1gm2$(exeext)): Ditto. (GM2-LIBS-BOOT-DEFS): Remove M2LINK.def. (GM2-LIBS-DEFS): Ditto. (m2/mc-boot/$(SRC_PREFIX)%.o): Replace CXX_FLAGS with CXXFLAGS. (m2/mc-boot-ch/$(SRC_PREFIX)%.o): Ditto. (m2/mc-boot/main.o): Ditto. (mcflex.o): Add $(CFLAGS). (m2/gm2-libs-boot/M2LINK.o): Remove rule. * gm2-compiler/M2GCCDeclare.def (DeclareM2linkGlobals): Remove. * gm2-compiler/M2GCCDeclare.mod: (M2LinkEntry): Remove. (M2LinkIndex): Remove. (DoVariableDeclaration): Remove initial and call to AddEntryM2Link. (AddEntryM2Link): Remove. (GetEntryM2Link): Remove. (DeclareM2linkGlobals): Remove. (DetectM2LinkInitial): Remove. (InitM2LinkModule): Remove. * gm2-compiler/M2GenGCC.mod (CodeFinallyEnd): Remove call to DeclareM2linkGlobals. * gm2-compiler/M2Quads.mod (BuildM2InitFunction): Add extra parameter containing runtime module override to ConstructModules. * gm2-compiler/M2Scaffold.mod: Update comment describing ConstructModules. * gm2-gcc/m2decl.cc (m2decl_DeclareM2linkForcedModuleInitOrder): Remove. * gm2-libs-iso/M2RTS.def (ConstructModules): Add overrideliborder parameter. * gm2-libs-iso/M2RTS.mod: Add overrideliborder parameter. * gm2-libs/M2Dependent.def (ConstructModules): Add overrideliborder parameter. * gm2-libs/M2Dependent.mod (ConstructModules): Add overrideliborder parameter. * gm2-libs/M2RTS.def (ConstructModules): Add overrideliborder parameter. * gm2-libs/M2RTS.mod (ConstructModules): Add overrideliborder parameter. * gm2-libs/M2LINK.def: Removed. libgm2/ChangeLog: * libm2pim/Makefile.am (M2DEFS): Remove M2LINK.def. * libm2pim/Makefile.in: Rebuild. Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>