public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Martin Liska <marxin@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r13-6713] middle-end: always find a basename for -fdiagnostics-format=*
Date: Thu, 16 Mar 2023 14:50:38 +0000 (GMT)	[thread overview]
Message-ID: <20230316145038.02A413858D35@sourceware.org> (raw)

https://gcc.gnu.org/g:c5e2c3dd6afcf9b152df72b30e205b0180c0afd5

commit r13-6713-gc5e2c3dd6afcf9b152df72b30e205b0180c0afd5
Author: Martin Liska <mliska@suse.cz>
Date:   Tue Jan 10 15:14:05 2023 +0100

    middle-end: always find a basename for -fdiagnostics-format=*
    
    In some situations, x_dump_base_name is NULL and thus we can
    and should use x_main_input_basename which should never be NULL.
    
            PR middle-end/106133
    
    gcc/ChangeLog:
    
            * gcc.cc (driver_handle_option): Use x_main_input_basename
            if x_dump_base_name is null.
            * opts.cc (common_handle_option): Likewise.
    
    gcc/testsuite/ChangeLog:
    
            * c-c++-common/pr106133.c: New test.

Diff:
---
 gcc/gcc.cc                            | 10 +++++++---
 gcc/opts.cc                           | 10 +++++++---
 gcc/testsuite/c-c++-common/pr106133.c |  3 +++
 3 files changed, 17 insertions(+), 6 deletions(-)

diff --git a/gcc/gcc.cc b/gcc/gcc.cc
index becc56051a8..16bb07f2cdc 100644
--- a/gcc/gcc.cc
+++ b/gcc/gcc.cc
@@ -4291,9 +4291,13 @@ driver_handle_option (struct gcc_options *opts,
       break;
 
     case OPT_fdiagnostics_format_:
-      diagnostic_output_format_init (dc, opts->x_dump_base_name,
-				     (enum diagnostics_output_format)value);
-      break;
+	{
+	  const char *basename = (opts->x_dump_base_name ? opts->x_dump_base_name
+				  : opts->x_main_input_basename);
+	  diagnostic_output_format_init (dc, basename,
+					 (enum diagnostics_output_format)value);
+	  break;
+	}
 
     case OPT_Wa_:
       {
diff --git a/gcc/opts.cc b/gcc/opts.cc
index 3bc17a187fe..f102c1328b9 100644
--- a/gcc/opts.cc
+++ b/gcc/opts.cc
@@ -2878,9 +2878,13 @@ common_handle_option (struct gcc_options *opts,
       break;
 
     case OPT_fdiagnostics_format_:
-      diagnostic_output_format_init (dc, opts->x_dump_base_name,
-				     (enum diagnostics_output_format)value);
-      break;
+	{
+	  const char *basename = (opts->x_dump_base_name ? opts->x_dump_base_name
+				  : opts->x_main_input_basename);
+	  diagnostic_output_format_init (dc, basename,
+					 (enum diagnostics_output_format)value);
+	  break;
+	}
 
     case OPT_fdiagnostics_parseable_fixits:
       dc->extra_output_kind = (value
diff --git a/gcc/testsuite/c-c++-common/pr106133.c b/gcc/testsuite/c-c++-common/pr106133.c
new file mode 100644
index 00000000000..7d2c5afe417
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/pr106133.c
@@ -0,0 +1,3 @@
+/* PR middle-end/106133 */
+/* { dg-do compile } */
+/* { dg-options "-fdiagnostics-format=json-file -E" } */

                 reply	other threads:[~2023-03-16 14:50 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=20230316145038.02A413858D35@sourceware.org \
    --to=marxin@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.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).