public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
From: Michael Frysinger <vapier@sourceware.org>
To: gdb-cvs@sourceware.org
Subject: [binutils-gdb] sim: igen: do not reindent literal semantics output
Date: Fri, 15 Dec 2023 03:36:45 +0000 (GMT)	[thread overview]
Message-ID: <20231215033645.EB6343864856@sourceware.org> (raw)

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=880530b71fbbb3e778ee70fe5623f8641e6aceb7

commit 880530b71fbbb3e778ee70fe5623f8641e6aceb7
Author: Mike Frysinger <vapier@gentoo.org>
Date:   Thu Dec 14 22:29:56 2023 -0500

    sim: igen: do not reindent literal semantics output
    
    When generating semantics.c from .igen source files, indenting the code
    makes it more readable, but confuses compiler diagnostics.  The latter
    is a bit more important than the former, so bias towards that.
    
    For example, with an introduced error, we can see w/gcc-13:
    
    (before this change)
      CC       mn10300/semantics.o
    ../../../sim/mn10300/am33-2.igen: In function ‘semantic_dcpf_D1a’:
    ../../../sim/mn10300/am33-2.igen:11:5: error: ‘srcreg’ undeclared (first use in this function)
       11 |   srcreg = translate_rreg (SD_, RN2);
          |     ^~~~~~
    
    (with this change)
      CC       mn10300/semantics.o
    ../../../sim/mn10300/am33-2.igen: In function ‘semantic_dcpf_D1a’:
    ../../../sim/mn10300/am33-2.igen:11:3: error: ‘srcreg’ undeclared (first use in this function)
       11 |   srcreg = translate_rreg (SD_, RN2);
          |   ^~~~~~

Diff:
---
 sim/igen/gen-semantics.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/sim/igen/gen-semantics.c b/sim/igen/gen-semantics.c
index 54d83d61ecc..455702973e4 100644
--- a/sim/igen/gen-semantics.c
+++ b/sim/igen/gen-semantics.c
@@ -262,10 +262,17 @@ print_semantic_body (lf *file,
     {
       /* true code */
       lf_printf (file, "{\n");
-      lf_indent (file, +2);
+      /* NB: Do not indent the code.  If the .igen source files cause a compiler
+	 warning, the diagnostics can read the line from the original source,
+	 but use column offsets from the generated files, causing columns to be
+	 misaligned.  It makes the generated code slightly more difficult to
+	 read, but accurate compiler diagnostics relative to the original source
+	 are more important here.
+      lf_indent (file, +2); */
       lf_print__line_ref (file, instruction->code->line);
       table_print_code (file, instruction->code);
-      lf_indent (file, -2);
+      /* NB: Disabled -- see above.
+      lf_indent (file, -2); */
       lf_printf (file, "}\n");
       lf_print__internal_ref (file);
     }

                 reply	other threads:[~2023-12-15  3:36 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231215033645.EB6343864856@sourceware.org \
    --to=vapier@sourceware.org \
    --cc=gdb-cvs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).