diff options
author | Gaius Mulley <gaiusmod2@gmail.com> | 2025-03-16 15:56:48 +0000 |
---|---|---|
committer | Gaius Mulley <gaiusmod2@gmail.com> | 2025-03-16 15:56:48 +0000 |
commit | 5ed0564f2879db35106272556ba91f028177c5cd (patch) | |
tree | 97e135ec3974f65403bd08a96245e2db39e09392 /gcc/m2/gm2-gcc | |
parent | 952e17223d3a9809a32be23f86f77166b5860b36 (diff) | |
download | gcc-5ed0564f2879db35106272556ba91f028177c5cd.zip gcc-5ed0564f2879db35106272556ba91f028177c5cd.tar.gz gcc-5ed0564f2879db35106272556ba91f028177c5cd.tar.bz2 |
PR modula2/115111 Incorrect line debugging locations at the end of the WHILE loop
This fix corrects the END token position used during the GotoOp at the
bottom of the WHILE loop. The fix is to pass the relative token position
down to M2Quads. This method should be replicated for the other loops
END or UNTIL keywords and possibly the END statements for
conditional statements.
gcc/m2/ChangeLog:
PR modula2/115111
* gm2-compiler/M2GenGCC.mod (CodeStatementNote): Add debugging.
* gm2-compiler/M2Quads.def (BuildEndWhile): New parameter reltokpos.
* gm2-compiler/M2Quads.mod (BuildEndWhile): Reimplement using new parameter.
* gm2-compiler/P3Build.bnf (WhileStatement): Call BuildEndWhile
with -1 relative position.
* gm2-gcc/m2block.cc (do_add_stmt): Tidy comment.
(GetGlobals): Ditto.
(flush_pending_note): Remove #if 0 code.
* gm2-gcc/m2pp.cc (m2pp_nop_expr): New function.
(m2pp_statement): New case clause call m2pp_nop_expr.
gcc/testsuite/ChangeLog:
PR modula2/115111
* gm2/pim/pass/whilestep.mod: New test.
Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
Diffstat (limited to 'gcc/m2/gm2-gcc')
-rw-r--r-- | gcc/m2/gm2-gcc/m2block.cc | 21 | ||||
-rw-r--r-- | gcc/m2/gm2-gcc/m2pp.cc | 15 |
2 files changed, 19 insertions, 17 deletions
diff --git a/gcc/m2/gm2-gcc/m2block.cc b/gcc/m2/gm2-gcc/m2block.cc index 40ab96b..c4877d1 100644 --- a/gcc/m2/gm2-gcc/m2block.cc +++ b/gcc/m2/gm2-gcc/m2block.cc @@ -28,6 +28,7 @@ along with GNU Modula-2; see the file COPYING3. If not see #include "m2options.h" #include "m2tree.h" #include "m2treelib.h" +#include "m2pp.h" /* For each binding contour we allocate a binding_level structure which records the entities defined or declared in that contour. @@ -667,8 +668,7 @@ m2block_GetErrorNode (void) return error_mark_node; } -/* GetGlobals - returns a list of global variables, functions, - constants. */ +/* GetGlobals returns a list of global variables, functions and constants. */ tree m2block_GetGlobals (void) @@ -685,7 +685,7 @@ m2block_GetGlobalContext (void) return global_binding_level->context; } -/* do_add_stmt - t is a statement. Add it to the statement-tree. */ +/* do_add_stmt t is a statement. Add it to the statement-tree. */ static tree do_add_stmt (tree t) @@ -695,27 +695,14 @@ do_add_stmt (tree t) return t; } -/* flush_pending_note - flushes a pending_statement note if - necessary. */ +/* flush_pending_note flushes a pending_statement note if necessary. */ static void flush_pending_note (void) { if (pending_statement && (M2Options_GetM2g ())) { -#if 0 - /* --fixme-- we need a machine independant way to generate a nop. */ - tree instr = m2decl_BuildStringConstant ("nop", 3); - tree string - = resolve_asm_operand_names (instr, NULL_TREE, NULL_TREE, NULL_TREE); - tree note = build_stmt (pending_location, ASM_EXPR, string, NULL_TREE, - NULL_TREE, NULL_TREE, NULL_TREE); - - ASM_BASIC_P (note) = false; - ASM_VOLATILE_P (note) = false; -#else tree note = build_empty_stmt (pending_location); -#endif pending_statement = false; do_add_stmt (note); } diff --git a/gcc/m2/gm2-gcc/m2pp.cc b/gcc/m2/gm2-gcc/m2pp.cc index d7f5a41..6ec8aaa 100644 --- a/gcc/m2/gm2-gcc/m2pp.cc +++ b/gcc/m2/gm2-gcc/m2pp.cc @@ -2362,6 +2362,18 @@ m2pp_asm_expr (pretty *state, tree node) m2pp_print (state, ");\n"); } +/* m2pp_nop_expr display the nop_expr node. */ + +static void +m2pp_nop_expr (pretty *state, tree t) +{ + enum tree_code code = TREE_CODE (t); + m2pp_begin (state); + m2pp_print (state, "(* NOP for debug location *)"); + m2pp_needspace (state); + m2pp_loc (state, t); +} + /* m2pp_statement attempts to reconstruct a statement. */ static void @@ -2430,6 +2442,9 @@ m2pp_statement (pretty *s, tree t) case IF_STMT: m2pp_if_stmt (s, t); break; + case NOP_EXPR: + m2pp_nop_expr (s, t); + break; case ERROR_MARK: m2pp_print (s, "<ERROR CODE>\n"); break; |