From patchwork Fri Jan 6 11:33:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Martin_Li=C5=A1ka?= X-Patchwork-Id: 40093 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp773984wrt; Fri, 6 Jan 2023 03:34:29 -0800 (PST) X-Google-Smtp-Source: AMrXdXvWOOaoF3SUoWwG4oeRZLjGTuhBuPVHg6X+60vQ/+Gzi4vTK3sjd324Gb+YA8TRYHDAu3lF X-Received: by 2002:a17:907:8c81:b0:7c0:7d35:e9db with SMTP id td1-20020a1709078c8100b007c07d35e9dbmr63829132ejc.15.1673004869137; Fri, 06 Jan 2023 03:34:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673004869; cv=none; d=google.com; s=arc-20160816; b=X7qP4PvHGsLuMiC0hBG5ao6htE7ltQB2SBI179q8cyi3LWm24q7CCOwCLiV3WLrJxW fTgGmiGW518ey8EiVhJnQ01nhBDAls5qTQIfedei41ElJE9PbI2IjNc8jk+daKTcVXsR J3BqNTwd8tqVdVFzNZoYGV4yDgiWZdXyf3XF3G6up3TQdw5C9HcNCMa3Dwmv0ZwT6xVr vagtCBvCGVj8dDjJMNR2bnMkD5IT58ptgn812Cz8oj5maIiaIA+yr07VDqEns/Hy1uKa B3HckqTuK2qXV+E86nU74oqvSTC7EXpu4aJMKm7jKuH7K+QT8oT84SwPS4zkiE/l8mX5 NhBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding:cc :content-language:to:subject:from:user-agent:mime-version:date :message-id:dkim-signature:dkim-signature:dmarc-filter:delivered-to; bh=X5sZf1Ab2IigYpyrf/3tZmjBCO1i7g1ukxJrrb5LNLg=; b=NsekWK8rTG9Q2Pu/lPnANa0QBCXXpfOglu0mOgSiVZAQFlvB/8Cw2/p8RanVGd/Ic4 5EGdEgHGAIXSdmL3WTAB/5akjX0lQN6pSkiVNO3WyYCfLfBHO3lvrJqXuk3UehN2tbzB FHTV10Nmxv/T60v+hV+4eiuYSbs1QlvS/2R+TS8lma1U08oBaTH/vXJWBKu0zfHkjIhE Arv2WTZwP1uoqfdSU138XnY9M0E8aL5zMrXd9y4w3BjDb6u/Cx/MZOjX+aPvTIrw8laD OBkj5DCG8ALsrUKG703B+rVJXTAESOS8S/mIZHj3aDhkcCdD4E+adSqp37WTuxr9hn4q Be2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=zExKpaMt; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b=F07Uyotx; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id ne19-20020a1709077b9300b007bf9de4fe91si1360588ejc.53.2023.01.06.03.34.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Jan 2023 03:34:29 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=zExKpaMt; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b=F07Uyotx; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D80C63858C66 for ; Fri, 6 Jan 2023 11:34:19 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by sourceware.org (Postfix) with ESMTPS id E006C3858D28 for ; Fri, 6 Jan 2023 11:33:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E006C3858D28 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.cz Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id B10B0250B9; Fri, 6 Jan 2023 11:33:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1673004834; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=X5sZf1Ab2IigYpyrf/3tZmjBCO1i7g1ukxJrrb5LNLg=; b=zExKpaMtkuz4S565ncNJIWw8w8ThAt067t4/P0DinqGHnWme7FywaV4T84TK//johaVZg2 7Aekg4EczoCX/q3sxoBJ9fLUnsVeyGX5M4KfXDtIlsVh8s+kZLtzzbM0CVhQ1L6vYMlQ7E w+bWMDX8P74PqQTk7r6QK5NjKp/sqZ0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1673004834; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=X5sZf1Ab2IigYpyrf/3tZmjBCO1i7g1ukxJrrb5LNLg=; b=F07UyotxywjnqKZmqRVjwi5JReHyjq4uB6msZXoDfq3OZjvLvMtB7i6cXiGp2r2HivonLF aOPfGqKD8bH0h7Cw== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 8E71B13596; Fri, 6 Jan 2023 11:33:54 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id EW28ICIHuGPqJQAAMHmgww (envelope-from ); Fri, 06 Jan 2023 11:33:54 +0000 Message-ID: <60f9fd2b-211e-c1d5-e17a-1fab1ee51338@suse.cz> Date: Fri, 6 Jan 2023 12:33:54 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.6.1 From: =?utf-8?q?Martin_Li=C5=A1ka?= Subject: [PATCH] diagnostics: fix crash with -fdiagnostics-format=json-file To: gcc-patches@gcc.gnu.org Content-Language: en-US Cc: David Malcolm X-Spam-Status: No, score=-11.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_PASS, 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 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754272753494259056?= X-GMAIL-MSGID: =?utf-8?q?1754272753494259056?= Patch can bootstrap on x86_64-linux-gnu and survives regression tests. Ready to be installed? Thanks, Martin PR middle-end/106133 gcc/ChangeLog: * diagnostic.cc (diagnostic_output_format_init): If -fdiagnostics-format=json-file and -E is used, then base_file_name is null and we should not emit anything. --- gcc/diagnostic.cc | 3 +++ 1 file changed, 3 insertions(+) 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, const char *base_file_name, enum diagnostics_output_format format) { + if (base_file_name == NULL) + return; + switch (format) { default: