From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id ED0BC3858D28 for ; Fri, 6 Jan 2023 13:21:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org ED0BC3858D28 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1673011294; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WfwQiHUuT9ArOKj+kVEFvUsEOu1H9/mOeR76662MMks=; b=ddl83PhwADHX3OAF8A/z9ypxqTrTaSReoCdCb44zwqLF36yhfnSz4lCdMxyGgYh7XhDttx 36pT6hgOVFZ4EfjLQcolnAGwff7BVJ/ZiMkpRbaQr8UhgAtOUBNqCGilNZGZB+EhKEmA6H Y3cov2vY5hfjxzKRLwg+pjhgzJnNyqo= Received: from mail-yb1-f198.google.com (mail-yb1-f198.google.com [209.85.219.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-90-y4qe9YQCNaOoTr6FP-yF6A-1; Fri, 06 Jan 2023 08:21:33 -0500 X-MC-Unique: y4qe9YQCNaOoTr6FP-yF6A-1 Received: by mail-yb1-f198.google.com with SMTP id i17-20020a25bc11000000b007b59a5b74aaso1820142ybh.7 for ; Fri, 06 Jan 2023 05:21:33 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:to:from:subject:message-id:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=WfwQiHUuT9ArOKj+kVEFvUsEOu1H9/mOeR76662MMks=; b=eITHq979xMIssKMhn6b16clu0nIKiw7tPrVU0/8SFKy6oS4C25O0T4Rt80cwWJsqWC uAC69KoQSKqV+0CIVNq3SfuvsaFT29cVSh/SvviyFWm8KU0iBQwFhPMMxkXc0tEGPp3B 3oseX69DPvxwlZMsSTI1pC20xLO/Bc8XJpTvM5ReuJ9PIPVcDvW7X04l0DBKYCdRtgxy GirP/5o/VCPvX1jQ0yqQR9vX5I1gfvUqNC2Qq1w70anGIoccSCbzXgIJFF6Yg4eksT0c 92QaWzHIZkHRvgKbUNrcmrcDsFy8sQQoHeu0cTUFGKe5+50cGTnvoLmg7qzQRNsTkx6h UnPg== X-Gm-Message-State: AFqh2kqwxrfFAM698Gk/I7znZaDXenYcP/d0VnOTEibIiWSXhpJvDGGo pf6QH0AQzqfoZCUzBvG4pA/OtB+hiQV6hQVC5qC/VhmlmgTRgz8Nac2Es0Y6Uel3lKKAg+mXsK1 7iL3LvyTWBiU/esw0ZA== X-Received: by 2002:a05:6902:4c3:b0:6f9:1ae8:a716 with SMTP id v3-20020a05690204c300b006f91ae8a716mr47333800ybs.43.1673011293097; Fri, 06 Jan 2023 05:21:33 -0800 (PST) X-Google-Smtp-Source: AMrXdXvxTesiEf8/ZAwXxGoqv0XII7xYND/nZIDKmr24AN6XMowAN38kfm6xTgh719VC3gmcfZ3wlA== X-Received: by 2002:a05:6902:4c3:b0:6f9:1ae8:a716 with SMTP id v3-20020a05690204c300b006f91ae8a716mr47333786ybs.43.1673011292846; Fri, 06 Jan 2023 05:21:32 -0800 (PST) Received: from t14s.localdomain (c-73-69-212-193.hsd1.ma.comcast.net. [73.69.212.193]) by smtp.gmail.com with ESMTPSA id d136-20020ae9ef8e000000b006ef1a8f1b81sm519821qkg.5.2023.01.06.05.21.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Jan 2023 05:21:32 -0800 (PST) Message-ID: Subject: Re: [PATCH] diagnostics: fix crash with -fdiagnostics-format=json-file From: David Malcolm To: Martin =?UTF-8?Q?Li=C5=A1ka?= , gcc-patches@gcc.gnu.org Date: Fri, 06 Jan 2023 08:21:31 -0500 In-Reply-To: <60f9fd2b-211e-c1d5-e17a-1fab1ee51338@suse.cz> References: <60f9fd2b-211e-c1d5-e17a-1fab1ee51338@suse.cz> User-Agent: Evolution 3.44.4 (3.44.4-1.fc36) MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-10.3 required=5.0 tests=BAYES_00,BODY_8BITS,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Fri, 2023-01-06 at 12:33 +0100, Martin Li=C5=A1ka wrote: > Patch can bootstrap on x86_64-linux-gnu and survives regression > tests. Thanks for the patch. I noticed that you marked PR 108307 as a dup of this, which covers -fdiagnostics-format=3Dsarif-file (and a .S file as input). The patch doesn't add any test coverage (for either of the diagnostic formats). If we try to emit a diagnostic and base_file_name is NULL, and the user requested one of -fdiagnostics-format=3D{json,sarif}-file, where do the diagnostics go? Where should they go? Dave >=20 > Ready to be installed? > Thanks, > Martin >=20 > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0PR middle-end/106133 >=20 > gcc/ChangeLog: >=20 > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0* diagnostic.cc (diagnost= ic_output_format_init): If > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0-fdiagnostics-format=3Djs= on-file and -E is used, then > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0base_file_name is null an= d we should not emit anything. > --- > =C2=A0gcc/diagnostic.cc | 3 +++ > =C2=A01 file changed, 3 insertions(+) >=20 > diff --git a/gcc/diagnostic.cc b/gcc/diagnostic.cc > index c90c14e993e..fe7d121e340 100644 > --- a/gcc/diagnostic.cc > +++ b/gcc/diagnostic.cc > @@ -2277,6 +2277,9 @@ diagnostic_output_format_init > (diagnostic_context *context, > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 const char *base_file_name, > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 enum diagnostics_output_format format) > =C2=A0{ > +=C2=A0 if (base_file_name =3D=3D NULL) > +=C2=A0=C2=A0=C2=A0 return; > + > =C2=A0=C2=A0 switch (format) > =C2=A0=C2=A0=C2=A0=C2=A0 { > =C2=A0=C2=A0=C2=A0=C2=A0 default: