https://gcc.gnu.org/g:6dbf0d252f69ab2924256e6778ba7dc55d5b6915
commit r14-9483-g6dbf0d252f69ab2924256e6778ba7dc55d5b6915 Author: Gaius Mulley <gaiusm...@gmail.com> Date: Thu Mar 14 19:09:34 2024 +0000 PR modula2/114294 expression causes ICE This patch fixes an ICE when encountering an expression: 1 + HIGH (a[0]). The fix was to assign a type to the constant created by BuildConstHighFromSym in M2Quads.mod. gcc/m2/ChangeLog: PR modula2/114294 * gm2-compiler/M2Quads.mod (BuildConstHighFromSym): Call PutConst to assign the type Cardinal in the result constant. gcc/testsuite/ChangeLog: PR modula2/114294 * gm2/pim/pass/log: Removed. * gm2/pim/pass/highexp.mod: New test. Signed-off-by: Gaius Mulley <gaiusm...@gmail.com> Diff: --- gcc/m2/gm2-compiler/M2Quads.mod | 1 + gcc/testsuite/gm2/pim/pass/highexp.mod | 9 + gcc/testsuite/gm2/pim/pass/log | 457 --------------------------------- 3 files changed, 10 insertions(+), 457 deletions(-) diff --git a/gcc/m2/gm2-compiler/M2Quads.mod b/gcc/m2/gm2-compiler/M2Quads.mod index 0263074d845..1776a09b41f 100644 --- a/gcc/m2/gm2-compiler/M2Quads.mod +++ b/gcc/m2/gm2-compiler/M2Quads.mod @@ -8400,6 +8400,7 @@ VAR BEGIN PopT (NoOfParam) ; ReturnVar := MakeTemporary (tok, ImmediateValue) ; + PutConst (ReturnVar, Cardinal) ; GenHigh (tok, ReturnVar, 1, OperandT (1)) ; PopN (NoOfParam+1) ; PushTtok (ReturnVar, tok) diff --git a/gcc/testsuite/gm2/pim/pass/highexp.mod b/gcc/testsuite/gm2/pim/pass/highexp.mod new file mode 100644 index 00000000000..f98be7df331 --- /dev/null +++ b/gcc/testsuite/gm2/pim/pass/highexp.mod @@ -0,0 +1,9 @@ +MODULE highexp ; + + +VAR + a: ARRAY [0..9] OF CHAR ; + c: CARDINAL ; +BEGIN + c := 1 + HIGH (a) +END highexp. diff --git a/gcc/testsuite/gm2/pim/pass/log b/gcc/testsuite/gm2/pim/pass/log deleted file mode 100644 index 5bbdc50ab6e..00000000000 --- a/gcc/testsuite/gm2/pim/pass/log +++ /dev/null @@ -1,457 +0,0 @@ -===================================================== -Stabs setchar3 -GNU gdb 6.3 -Copyright (C) 2004-2024 Free Software Foundation, Inc. -GDB is free software, covered by the GNU General Public License, and you are -welcome to change it and/or distribute copies of it under certain conditions. -Type "show copying" to see the conditions. -There is absolutely no warranty for GDB. Type "show warranty" for details. -This GDB was configured as "x86_64-unknown-linux-gnu"...Using host libthread_db library "/lib/libthread_db.so.1". - -Breakpoint 1 at 0x421298: file setchar3.mod, line 30. - -Breakpoint 1, _M2_setchar3_init () at setchar3.mod:30 -30 ch := 'z' ; -31 s := smallchar{} ; -$1 = {} -type = SET ['A'..'Z'] -===================================================== -Dwarf2 setchar3 -GNU gdb 6.3 -Copyright (C) 2004-2024 Free Software Foundation, Inc. -GDB is free software, covered by the GNU General Public License, and you are -welcome to change it and/or distribute copies of it under certain conditions. -Type "show copying" to see the conditions. -There is absolutely no warranty for GDB. Type "show warranty" for details. -This GDB was configured as "x86_64-unknown-linux-gnu"...Using host libthread_db library "/lib/libthread_db.so.1". - -Breakpoint 1 at 0x421298: file setchar3.mod, line 30. - -Breakpoint 1, _M2_setchar3_init () at setchar3.mod:30 -30 ch := 'z' ; -31 s := smallchar{} ; -$1 = {} -type = SET ['A'..'Z'] -===================================================== -Stabs subrange15 -GNU gdb 6.3 -Copyright (C) 2004-2024 Free Software Foundation, Inc. -GDB is free software, covered by the GNU General Public License, and you are -welcome to change it and/or distribute copies of it under certain conditions. -Type "show copying" to see the conditions. -There is absolutely no warranty for GDB. Type "show warranty" for details. -This GDB was configured as "x86_64-unknown-linux-gnu"...Using host libthread_db library "/lib/libthread_db.so.1". - -Breakpoint 1 at 0x421298: file subrange15.mod, line 8. - -Breakpoint 1, _M2_subrange15_init () at subrange15.mod:8 -8 s := 20 ; -9 s := 21 ; -$1 = 20 -type = [20..40] -===================================================== -Dwarf2 subrange15 -GNU gdb 6.3 -Copyright (C) 2004-2024 Free Software Foundation, Inc. -GDB is free software, covered by the GNU General Public License, and you are -welcome to change it and/or distribute copies of it under certain conditions. -Type "show copying" to see the conditions. -There is absolutely no warranty for GDB. Type "show warranty" for details. -This GDB was configured as "x86_64-unknown-linux-gnu"...Using host libthread_db library "/lib/libthread_db.so.1". - -Breakpoint 1 at 0x421298: file subrange15.mod, line 8. - -Breakpoint 1, _M2_subrange15_init () at subrange15.mod:8 -8 s := 20 ; -9 s := 21 ; -$1 = 20 -type = [20..40] -===================================================== -Stabs subrange16 -GNU gdb 6.3 -Copyright (C) 2004-2024 Free Software Foundation, Inc. -GDB is free software, covered by the GNU General Public License, and you are -welcome to change it and/or distribute copies of it under certain conditions. -Type "show copying" to see the conditions. -There is absolutely no warranty for GDB. Type "show warranty" for details. -This GDB was configured as "x86_64-unknown-linux-gnu"...Using host libthread_db library "/lib/libthread_db.so.1". - -Breakpoint 1 at 0x421298: file subrange16.mod, line 8. - -Breakpoint 1, _M2_subrange16_init () at subrange16.mod:8 -8 s := 'A' ; -9 s := 'B' ; -$1 = 65 'A' -type = ['A'..'Z'] -===================================================== -Dwarf2 subrange16 -GNU gdb 6.3 -Copyright (C) 2004-2024 Free Software Foundation, Inc. -GDB is free software, covered by the GNU General Public License, and you are -welcome to change it and/or distribute copies of it under certain conditions. -Type "show copying" to see the conditions. -There is absolutely no warranty for GDB. Type "show warranty" for details. -This GDB was configured as "x86_64-unknown-linux-gnu"...Using host libthread_db library "/lib/libthread_db.so.1". - -Breakpoint 1 at 0x421298: file subrange16.mod, line 8. - -Breakpoint 1, _M2_subrange16_init () at subrange16.mod:8 -8 s := 'A' ; -9 s := 'B' ; -$1 = 65 'A' -type = ['A'..'Z'] -===================================================== -Stabs subrange17 -GNU gdb 6.3 -Copyright (C) 2004-2024 Free Software Foundation, Inc. -GDB is free software, covered by the GNU General Public License, and you are -welcome to change it and/or distribute copies of it under certain conditions. -Type "show copying" to see the conditions. -There is absolutely no warranty for GDB. Type "show warranty" for details. -This GDB was configured as "x86_64-unknown-linux-gnu"...Using host libthread_db library "/lib/libthread_db.so.1". - -Breakpoint 1 at 0x421298: file subrange17.mod, line 9. - -Breakpoint 1, _M2_subrange17_init () at subrange17.mod:9 -9 s := blue ; -10 s := red ; -$1 = blue -type = [blue..yellow] -===================================================== -Dwarf2 subrange17 -GNU gdb 6.3 -Copyright (C) 2004-2024 Free Software Foundation, Inc. -GDB is free software, covered by the GNU General Public License, and you are -welcome to change it and/or distribute copies of it under certain conditions. -Type "show copying" to see the conditions. -There is absolutely no warranty for GDB. Type "show warranty" for details. -This GDB was configured as "x86_64-unknown-linux-gnu"...Using host libthread_db library "/lib/libthread_db.so.1". - -Breakpoint 1 at 0x421298: file subrange17.mod, line 9. - -Breakpoint 1, _M2_subrange17_init () at subrange17.mod:9 -9 s := blue ; -10 s := red ; -$1 = blue -type = [blue..yellow] -===================================================== -Stabs array4 -GNU gdb 6.3 -Copyright (C) 2004-2024 Free Software Foundation, Inc. -GDB is free software, covered by the GNU General Public License, and you are -welcome to change it and/or distribute copies of it under certain conditions. -Type "show copying" to see the conditions. -There is absolutely no warranty for GDB. Type "show warranty" for details. -This GDB was configured as "x86_64-unknown-linux-gnu"...Using host libthread_db library "/lib/libthread_db.so.1". - -Breakpoint 1 at 0x421298: file array4.mod, line 6. - -Breakpoint 1, _M2_array4_init () at array4.mod:6 -6 s[1] := 1 ; -7 s[1] := 1 ; -$1 = {1, 0, 0, 0, 0} -type = ARRAY [1..5] OF <invalid type code 7> -===================================================== -Dwarf2 array4 -GNU gdb 6.3 -Copyright (C) 2004-2024 Free Software Foundation, Inc. -GDB is free software, covered by the GNU General Public License, and you are -welcome to change it and/or distribute copies of it under certain conditions. -Type "show copying" to see the conditions. -There is absolutely no warranty for GDB. Type "show warranty" for details. -This GDB was configured as "x86_64-unknown-linux-gnu"...Using host libthread_db library "/lib/libthread_db.so.1". - -Breakpoint 1 at 0x421298: file array4.mod, line 6. - -Breakpoint 1, _M2_array4_init () at array4.mod:6 -6 s[1] := 1 ; -7 s[1] := 1 ; -$1 = {1, 0, 0, 0, 0} -type = ARRAY [1..5] OF CARDINAL -===================================================== -Stabs array5 -GNU gdb 6.3 -Copyright (C) 2004-2024 Free Software Foundation, Inc. -GDB is free software, covered by the GNU General Public License, and you are -welcome to change it and/or distribute copies of it under certain conditions. -Type "show copying" to see the conditions. -There is absolutely no warranty for GDB. Type "show warranty" for details. -This GDB was configured as "x86_64-unknown-linux-gnu"...Using host libthread_db library "/lib/libthread_db.so.1". - -Breakpoint 1 at 0x421298: file array5.mod, line 8. - -Breakpoint 1, _M2_array5_init () at array5.mod:8 -8 NEW(s) ; -9 s^[1] := 1 ; -$1 = 0x536280 -type = POINTER TO ARRAY [1..5] OF <invalid type code 7> -===================================================== -Dwarf2 array5 -GNU gdb 6.3 -Copyright (C) 2004-2024 Free Software Foundation, Inc. -GDB is free software, covered by the GNU General Public License, and you are -welcome to change it and/or distribute copies of it under certain conditions. -Type "show copying" to see the conditions. -There is absolutely no warranty for GDB. Type "show warranty" for details. -This GDB was configured as "x86_64-unknown-linux-gnu"...Using host libthread_db library "/lib/libthread_db.so.1". - -Breakpoint 1 at 0x421298: file array5.mod, line 8. - -Breakpoint 1, _M2_array5_init () at array5.mod:8 -8 NEW(s) ; -9 s^[1] := 1 ; -$1 = 0x536280 -type = POINTER TO ARRAY [1..5] OF CARDINAL -===================================================== -Stabs char -GNU gdb 6.3 -Copyright (C) 2004-2024 Free Software Foundation, Inc. -GDB is free software, covered by the GNU General Public License, and you are -welcome to change it and/or distribute copies of it under certain conditions. -Type "show copying" to see the conditions. -There is absolutely no warranty for GDB. Type "show warranty" for details. -This GDB was configured as "x86_64-unknown-linux-gnu"...Using host libthread_db library "/lib/libthread_db.so.1". - -Breakpoint 1 at 0x421298: file char.mod, line 6. - -Breakpoint 1, _M2_char_init () at char.mod:6 -6 s := 'a' ; -7 s := 'z' ; -$1 = 97 'a' -type = <invalid type code 18> -===================================================== -Dwarf2 char -GNU gdb 6.3 -Copyright (C) 2004-2024 Free Software Foundation, Inc. -GDB is free software, covered by the GNU General Public License, and you are -welcome to change it and/or distribute copies of it under certain conditions. -Type "show copying" to see the conditions. -There is absolutely no warranty for GDB. Type "show warranty" for details. -This GDB was configured as "x86_64-unknown-linux-gnu"...Using host libthread_db library "/lib/libthread_db.so.1". - -Breakpoint 1 at 0x421298: file char.mod, line 6. - -Breakpoint 1, _M2_char_init () at char.mod:6 -6 s := 'a' ; -7 s := 'z' ; -$1 = 97 'a' -type = CHAR -===================================================== -Stabs int -GNU gdb 6.3 -Copyright (C) 2004-2024 Free Software Foundation, Inc. -GDB is free software, covered by the GNU General Public License, and you are -welcome to change it and/or distribute copies of it under certain conditions. -Type "show copying" to see the conditions. -There is absolutely no warranty for GDB. Type "show warranty" for details. -This GDB was configured as "x86_64-unknown-linux-gnu"...Using host libthread_db library "/lib/libthread_db.so.1". - -Breakpoint 1 at 0x421298: file int.mod, line 6. - -Breakpoint 1, _M2_int_init () at int.mod:6 -6 s := 1 ; -7 s := 1 ; -$1 = 1 -type = <invalid type code 7> -===================================================== -Dwarf2 int -GNU gdb 6.3 -Copyright (C) 2004-2024 Free Software Foundation, Inc. -GDB is free software, covered by the GNU General Public License, and you are -welcome to change it and/or distribute copies of it under certain conditions. -Type "show copying" to see the conditions. -There is absolutely no warranty for GDB. Type "show warranty" for details. -This GDB was configured as "x86_64-unknown-linux-gnu"...Using host libthread_db library "/lib/libthread_db.so.1". - -Breakpoint 1 at 0x421298: file int.mod, line 6. - -Breakpoint 1, _M2_int_init () at int.mod:6 -6 s := 1 ; -7 s := 1 ; -$1 = 1 -type = INTEGER -===================================================== -Stabs ptrarray -GNU gdb 6.3 -Copyright (C) 2004-2024 Free Software Foundation, Inc. -GDB is free software, covered by the GNU General Public License, and you are -welcome to change it and/or distribute copies of it under certain conditions. -Type "show copying" to see the conditions. -There is absolutely no warranty for GDB. Type "show warranty" for details. -This GDB was configured as "x86_64-unknown-linux-gnu"...Using host libthread_db library "/lib/libthread_db.so.1". - -Breakpoint 1 at 0x421298: file ptrarray.mod, line 27. - -Breakpoint 1, _M2_ptrarray_init () at ptrarray.mod:27 -27 s := NIL ; -31 END ptrarray. -$1 = 0x0 -type = POINTER TO ARRAY [0..9] OF <invalid type code 18> -===================================================== -Dwarf2 ptrarray -GNU gdb 6.3 -Copyright (C) 2004-2024 Free Software Foundation, Inc. -GDB is free software, covered by the GNU General Public License, and you are -welcome to change it and/or distribute copies of it under certain conditions. -Type "show copying" to see the conditions. -There is absolutely no warranty for GDB. Type "show warranty" for details. -This GDB was configured as "x86_64-unknown-linux-gnu"...Using host libthread_db library "/lib/libthread_db.so.1". - -Breakpoint 1 at 0x421298: file ptrarray.mod, line 27. - -Breakpoint 1, _M2_ptrarray_init () at ptrarray.mod:27 -27 s := NIL ; -31 END ptrarray. -$1 = 0x0 -type = POINTER TO ARRAY [0..9] OF CHAR -===================================================== -Stabs variant9 -GNU gdb 6.3 -Copyright (C) 2004-2024 Free Software Foundation, Inc. -GDB is free software, covered by the GNU General Public License, and you are -welcome to change it and/or distribute copies of it under certain conditions. -Type "show copying" to see the conditions. -There is absolutely no warranty for GDB. Type "show warranty" for details. -This GDB was configured as "x86_64-unknown-linux-gnu"...Using host libthread_db library "/lib/libthread_db.so.1". - -Breakpoint 1 at 0x4212d8: file variant9.mod, line 19. - -Breakpoint 1, _M2_variant9_init () at variant9.mod:19 -19 WITH s DO -20 Data := card; -$1 = {Data = card, <error type>} -type = RcdType = RECORD - Data : DataType; - : <unknown type>; -END -===================================================== -Dwarf2 variant9 -GNU gdb 6.3 -Copyright (C) 2004-2024 Free Software Foundation, Inc. -GDB is free software, covered by the GNU General Public License, and you are -welcome to change it and/or distribute copies of it under certain conditions. -Type "show copying" to see the conditions. -There is absolutely no warranty for GDB. Type "show warranty" for details. -This GDB was configured as "x86_64-unknown-linux-gnu"...Using host libthread_db library "/lib/libthread_db.so.1". - -Breakpoint 1 at 0x4212d8: file variant9.mod, line 19. - -Breakpoint 1, _M2_variant9_init () at variant9.mod:19 -19 WITH s DO -20 Data := card; -$1 = {Data = card, {$$1 = {j = 0, k = 0}, $$2 = {st = 0 C}}} -type = RcdType = RECORD - Data : DataType; - : ; -END -===================================================== -Stabs setenum -GNU gdb 6.3 -Copyright (C) 2004-2024 Free Software Foundation, Inc. -GDB is free software, covered by the GNU General Public License, and you are -welcome to change it and/or distribute copies of it under certain conditions. -Type "show copying" to see the conditions. -There is absolutely no warranty for GDB. Type "show warranty" for details. -This GDB was configured as "x86_64-unknown-linux-gnu"...Using host libthread_db library "/lib/libthread_db.so.1". - -Breakpoint 1 at 0x421298: file setenum.mod, line 30. - -Breakpoint 1, _M2_setenum_init () at setenum.mod:30 -30 s := set{}; -31 s := set{}; -$1 = {} -type = set = SET OF enum -===================================================== -Dwarf2 setenum -GNU gdb 6.3 -Copyright (C) 2004-2024 Free Software Foundation, Inc. -GDB is free software, covered by the GNU General Public License, and you are -welcome to change it and/or distribute copies of it under certain conditions. -Type "show copying" to see the conditions. -There is absolutely no warranty for GDB. Type "show warranty" for details. -This GDB was configured as "x86_64-unknown-linux-gnu"...Using host libthread_db library "/lib/libthread_db.so.1". - -Breakpoint 1 at 0x421298: file setenum.mod, line 30. - -Breakpoint 1, _M2_setenum_init () at setenum.mod:30 -30 s := set{}; -31 s := set{}; -$1 = {} -type = set = SET OF enum -===================================================== -Stabs record7 -GNU gdb 6.3 -Copyright (C) 2004-2024 Free Software Foundation, Inc. -GDB is free software, covered by the GNU General Public License, and you are -welcome to change it and/or distribute copies of it under certain conditions. -Type "show copying" to see the conditions. -There is absolutely no warranty for GDB. Type "show warranty" for details. -This GDB was configured as "x86_64-unknown-linux-gnu"...Using host libthread_db library "/lib/libthread_db.so.1". - -Breakpoint 1 at 0x421298: file record7.mod, line 32. - -Breakpoint 1, _M2_record7_init () at record7.mod:32 -32 s := NIL ; -36 END record7. -$1 = 0x0 -type = POINTER TO ARRAY [-2..2] OF foo = RECORD - f1 : CARDINAL; - f2 : CHAR; - f3 : ARRAY [-2..2] OF CARDINAL; -END -===================================================== -Dwarf2 record7 -GNU gdb 6.3 -Copyright (C) 2004-2024 Free Software Foundation, Inc. -GDB is free software, covered by the GNU General Public License, and you are -welcome to change it and/or distribute copies of it under certain conditions. -Type "show copying" to see the conditions. -There is absolutely no warranty for GDB. Type "show warranty" for details. -This GDB was configured as "x86_64-unknown-linux-gnu"...Using host libthread_db library "/lib/libthread_db.so.1". - -Breakpoint 1 at 0x421298: file record7.mod, line 32. - -Breakpoint 1, _M2_record7_init () at record7.mod:32 -32 s := NIL ; -36 END record7. -$1 = 0x0 -type = POINTER TO ARRAY [-2..2] OF foo = RECORD - f1 : CARDINAL; - f2 : CHAR; - f3 : ARRAY [-2..2] OF CARDINAL; -END -===================================================== -Stabs setchar4 -GNU gdb 6.3 -Copyright (C) 2004-2024 Free Software Foundation, Inc. -GDB is free software, covered by the GNU General Public License, and you are -welcome to change it and/or distribute copies of it under certain conditions. -Type "show copying" to see the conditions. -There is absolutely no warranty for GDB. Type "show warranty" for details. -This GDB was configured as "x86_64-unknown-linux-gnu"...Using host libthread_db library "/lib/libthread_db.so.1". - -Breakpoint 1 at 0x421298: file setchar4.mod, line 29. - -Breakpoint 1, _M2_setchar4_init () at setchar4.mod:29 -29 p := ADR(s) ; -30 p^[0] := -1 ; -$1 = {} -type = charset = SET OF [200C..177C] -===================================================== -Dwarf2 setchar4 -GNU gdb 6.3 -Copyright (C) 2004-2024 Free Software Foundation, Inc. -GDB is free software, covered by the GNU General Public License, and you are -welcome to change it and/or distribute copies of it under certain conditions. -Type "show copying" to see the conditions. -There is absolutely no warranty for GDB. Type "show warranty" for details. -This GDB was configured as "x86_64-unknown-linux-gnu"...Using host libthread_db library "/lib/libthread_db.so.1". - -Breakpoint 1 at 0x421298: file setchar4.mod, line 29. - -Breakpoint 1, _M2_setchar4_init () at setchar4.mod:29 -29 p := ADR(s) ; -30 p^[0] := -1 ; -$1 = {} -type = charset = SET OF CHAR -gdb is hashed (/home/gaius/opt/bin/gdb)