aboutsummaryrefslogtreecommitdiff
path: root/gcc/m2
AgeCommit message (Collapse)AuthorFilesLines
2023-06-19Daily bump.GCC Administrator1-0/+10
2023-06-18PR modula2/110284 Remove stor-layout.o and backend header filesGaius Mulley2-10/+1
This patch removes stor-layout.o from the front end and also removes back end header files from gcc-consolidation.h. gcc/m2/ChangeLog: PR modula2/110284 * Make-lang.in (m2_OBJS): Assign $(GM2_C_OBJS). (GM2_C_OBJS): Remove m2/stor-layout.o. (m2/stor-layout.o): Remove rule. * gm2-gcc/gcc-consolidation.h (rtl.h): Remove include. (df.h): Remove include. (except.h): Remove include. Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
2023-06-16Daily bump.GCC Administrator1-0/+4
2023-06-15configure: Implement --enable-host-pieMarek Polacek1-25/+30
[ This is my third attempt to add this configure option. The first version was approved but it came too late in the development cycle. The second version was also approved, but I had to revert it: <https://gcc.gnu.org/pipermail/gcc-patches/2022-November/607082.html>. I've fixed the problem (by moving $(PICFLAG) from INTERNAL_CFLAGS to ALL_COMPILERFLAGS). Another change is that since r13-4536 I no longer need to touch Makefile.def, so this patch is simplified. ] This patch implements the --enable-host-pie configure option which makes the compiler executables PIE. This can be used to enhance protection against ROP attacks, and can be viewed as part of a wider trend to harden binaries. It is similar to the option --enable-host-shared, except that --e-h-s won't add -shared to the linker flags whereas --e-h-p will add -pie. It is different from --enable-default-pie because that option just adds an implicit -fPIE/-pie when the compiler is invoked, but the compiler itself isn't PIE. Since r12-5768-gfe7c3ecf, PCH works well with PIE, so there are no PCH regressions. When building the compiler, the build process may use various in-tree libraries; these need to be built with -fPIE so that it's possible to use them when building a PIE. For instance, when --with-included-gettext is in effect, intl object files must be compiled with -fPIE. Similarly, when building in-tree gmp, isl, mpfr and mpc, they must be compiled with -fPIE. With this patch and --enable-host-pie used to configure gcc: $ file gcc/cc1{,plus,obj,gm2} gcc/f951 gcc/lto1 gcc/cpp gcc/go1 gcc/rust1 gcc/gnat1 gcc/cc1: ELF 64-bit LSB pie executable, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=98e22cde129d304aa6f33e61b1c39e144aeb135e, for GNU/Linux 3.2.0, with debug_info, not stripped gcc/cc1plus: ELF 64-bit LSB pie executable, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=859d1ea37e43dfe50c18fd4e3dd9a34bb1db8f77, for GNU/Linux 3.2.0, with debug_info, not stripped gcc/cc1obj: ELF 64-bit LSB pie executable, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=1964f8ecee6163182bc26134e2ac1f324816e434, for GNU/Linux 3.2.0, with debug_info, not stripped gcc/cc1gm2: ELF 64-bit LSB pie executable, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=a396672c7ff913d21855829202e7b02ecf42ff4c, for GNU/Linux 3.2.0, with debug_info, not stripped gcc/f951: ELF 64-bit LSB pie executable, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=59c523db893186547ac75c7a71f48be0a461c06b, for GNU/Linux 3.2.0, with debug_info, not stripped gcc/lto1: ELF 64-bit LSB pie executable, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=084a7b77df7be2d63c2d4c655b5bbc3fcdb6038d, for GNU/Linux 3.2.0, with debug_info, not stripped gcc/cpp: ELF 64-bit LSB pie executable, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=3503bf8390d219a10d6653b8560aa21158132168, for GNU/Linux 3.2.0, with debug_info, not stripped gcc/go1: ELF 64-bit LSB pie executable, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=988cc673af4fba5dcb482f4b34957b99050a68c5, for GNU/Linux 3.2.0, with debug_info, not stripped gcc/rust1: ELF 64-bit LSB pie executable, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=b6a5d3d514446c4dcdee0707f086ab9b274a8a3c, for GNU/Linux 3.2.0, with debug_info, not stripped gcc/gnat1: ELF 64-bit LSB pie executable, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=bb11ccdc2c366fe3fe0980476bcd8ca19b67f9dc, for GNU/Linux 3.2.0, with debug_info, not stripped I plan to add an option to link with -Wl,-z,now. Bootstrapped on x86_64-pc-linux-gnu with --with-included-gettext --enable-host-pie as well as without --enable-host-pie. Also tested on a Debian system where the system gcc was configured with --enable-default-pie. Co-Authored by: Iain Sandoe <iain@sandoe.co.uk> ChangeLog: * configure.ac (--enable-host-pie): New check. Set PICFLAG after this check. * configure: Regenerate. c++tools/ChangeLog: * Makefile.in: Rename PIEFLAG to PICFLAG. Set LD_PICFLAG. Use it. Use pic/libiberty.a if PICFLAG is set. * configure.ac (--enable-default-pie): Set PICFLAG instead of PIEFLAG. (--enable-host-pie): New check. * configure: Regenerate. fixincludes/ChangeLog: * Makefile.in: Set and use PICFLAG and LD_PICFLAG. Use the "pic" build of libiberty if PICFLAG is set. * configure.ac: * configure: Regenerate. gcc/ChangeLog: * Makefile.in: Set LD_PICFLAG. Use it. Set enable_host_pie. Remove NO_PIE_CFLAGS and NO_PIE_FLAG. Pass LD_PICFLAG to ALL_LINKERFLAGS. Use the "pic" build of libiberty if --enable-host-pie. * configure.ac (--enable-host-shared): Don't set PICFLAG here. (--enable-host-pie): New check. Set PICFLAG and LD_PICFLAG after this check. * configure: Regenerate. * doc/install.texi: Document --enable-host-pie. gcc/ada/ChangeLog: * gcc-interface/Make-lang.in (ALL_ADAFLAGS): Remove NO_PIE_CFLAGS. Add PICFLAG. Use PICFLAG when building ada/b_gnat1.o and ada/b_gnatb.o. * gcc-interface/Makefile.in: Use pic/libiberty.a if PICFLAG is set. Remove NO_PIE_FLAG. gcc/m2/ChangeLog: * Make-lang.in: New var, GM2_PICFLAGS. Use it. gcc/d/ChangeLog: * Make-lang.in: Remove NO_PIE_CFLAGS. intl/ChangeLog: * Makefile.in: Use @PICFLAG@ in COMPILE as well. * configure.ac (--enable-host-shared): Don't set PICFLAG here. (--enable-host-pie): New check. Set PICFLAG after this check. * configure: Regenerate. libcody/ChangeLog: * Makefile.in: Pass LD_PICFLAG to LDFLAGS. * configure.ac (--enable-host-shared): Don't set PICFLAG here. (--enable-host-pie): New check. Set PICFLAG and LD_PICFLAG after this check. * configure: Regenerate. libcpp/ChangeLog: * configure.ac (--enable-host-shared): Don't set PICFLAG here. (--enable-host-pie): New check. Set PICFLAG after this check. * configure: Regenerate. libdecnumber/ChangeLog: * configure.ac (--enable-host-shared): Don't set PICFLAG here. (--enable-host-pie): New check. Set PICFLAG after this check. * configure: Regenerate. libiberty/ChangeLog: * configure.ac: Also set shared when enable_host_pie. * configure: Regenerate. zlib/ChangeLog: * configure.ac (--enable-host-shared): Don't set PICFLAG here. (--enable-host-pie): New check. Set PICFLAG after this check. * configure: Regenerate.
2023-06-14Daily bump.GCC Administrator1-0/+18
2023-06-13modula2 Fixes to the error format specificationsGaius Mulley4-30/+164
This patch contains a python3 script to check the meta format error specifications. It also includes about 20 fixes to M2Quads.mod format specifications. gcc/m2/ChangeLog: * Make-lang.in (check-format-error): New rule. * gm2-compiler/M2MetaError.mod (op): Add calls InternalError if digits are detected. * gm2-compiler/M2Quads.mod (BuildForToByDo): Bugfix to format specifier. (BuildLengthFunction): Bugfix to format specifiers. (BuildOddFunction): Bugfix to format specifiers. (BuildAbsFunction): Bugfix to format specifiers. (BuildCapFunction): Bugfix to format specifiers. (BuildChrFunction): Bugfix to format specifiers. (BuildOrdFunction): Bugfix to format specifiers. (BuildMakeAdrFunction): Bugfix to format specifiers. (BuildSizeFunction): Bugfix to format specifiers. (BuildBitSizeFunction): Bugfix to format specifiers. * tools-src/checkmeta.py: New file. Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
2023-06-13Daily bump.GCC Administrator1-0/+31
2023-06-13PR modula2/110189 Using an unknown TYPE as argument to VAL gives ICEGaius Mulley2-117/+78
This patch tidies P3Build.bnf and fixes error format specs in M2Quads.mod when encountering unknown symbols. gcc/m2/ChangeLog: PR modula2/110189 * gm2-compiler/M2Quads.mod (BuildAbsFunction): Replace abort format specifier. (BuildValFunction): Replace abort format specifier. (BuildCastFunction): Replace abort format specifier. (BuildMinFunction): Replace abort format specifier. (BuildMaxFunction): Replace abort format specifier. (BuildTruncFunction): Replace abort format specifier. * gm2-compiler/P3Build.bnf (Pass1): Remove. (Pass2): Remove. (Pass3): Remove. (Expect): Add Pass1. (AsmStatement): Remove Pass3. (AsmOperands): Remove Pass3. (AsmOperandSpec): Remove Pass3. (AsmInputElement): Remove Pass3. (AsmOutputElement): Remove Pass3. (AsmTrashList): Remove Pass3. gcc/testsuite/ChangeLog: PR modula2/110189 * gm2/pim/fail/foovaltype.mod: New test. Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
2023-06-12PR modula2/110126 variables are reported as unused when referenced by ASM fixGaius Mulley3-25/+73
This patch fixes the trash list of the asm statement. It introduces a separate build procedure for trashed elements. gcc/m2/ChangeLog: PR modula2/110126 * gm2-compiler/M2Quads.def (BuildAsmElement): Remove trash parameter. (BuildAsmTrash): New procedure. * gm2-compiler/M2Quads.mod (BuildAsmTrash): New procedure. (BuildAsmElement): Remove trash parameter. * gm2-compiler/P3Build.bnf (AsmTrashList): Rewrite. Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
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>