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.129.124]) by sourceware.org (Postfix) with ESMTPS id D9EBD3858023 for ; Mon, 24 Oct 2022 20:54:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org D9EBD3858023 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=1666644896; h=from:from:reply-to:subject:subject: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=8wEyL5F4R0/Wxx+aTHFPs3yMq3u1k/TLpQnygjkqS00=; b=LR7QI0vOdW/Y440XhU9EsDVJEiXh7b9zawt7nigGbXbzIUztgfSaglLhV4MlZANoeKaN02 fneJwRvs/DkNs8Fh3vUE6nasSA4hcS0vvPYbL9UqFZOOGxyiMoGtRhZMXjzPy01wnnUyWg 9DHTKYfIacUUul51LfOPvkitjSGgaXc= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-461-u-6I1hcWMIKsZbwsrjyrog-1; Mon, 24 Oct 2022 16:54:55 -0400 X-MC-Unique: u-6I1hcWMIKsZbwsrjyrog-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D87C180280D for ; Mon, 24 Oct 2022 20:54:54 +0000 (UTC) Received: from t14s.localdomain.com (unknown [10.2.17.189]) by smtp.corp.redhat.com (Postfix) with ESMTP id B3069C15BB2; Mon, 24 Oct 2022 20:54:54 +0000 (UTC) From: David Malcolm To: gcc-patches@gcc.gnu.org Cc: David Malcolm Subject: [committed] diagnostics: fix ICE in sarif output with NULL filename [PR107366] Date: Mon, 24 Oct 2022 16:54:53 -0400 Message-Id: <20221024205453.1760357-1-dmalcolm@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true X-Spam-Status: No, score=-11.6 required=5.0 tests=BAYES_00,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: Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu. Pushed to trunk as r13-3469-g2e8a0553918adc. gcc/ChangeLog: PR analyzer/107366 * diagnostic-format-sarif.cc (sarif_builder::maybe_make_physical_location_object): Gracefully reject locations with NULL filename. gcc/testsuite/ChangeLog: PR analyzer/107366 * gcc.dg/analyzer/sarif-pr107366.c: New test. Signed-off-by: David Malcolm --- gcc/diagnostic-format-sarif.cc | 2 +- .../gcc.dg/analyzer/sarif-pr107366.c | 20 +++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.dg/analyzer/sarif-pr107366.c diff --git a/gcc/diagnostic-format-sarif.cc b/gcc/diagnostic-format-sarif.cc index fc28d160c38..7110db4edd6 100644 --- a/gcc/diagnostic-format-sarif.cc +++ b/gcc/diagnostic-format-sarif.cc @@ -595,7 +595,7 @@ sarif_builder::make_location_object (const diagnostic_event &event) json::object * sarif_builder::maybe_make_physical_location_object (location_t loc) { - if (loc <= BUILTINS_LOCATION) + if (loc <= BUILTINS_LOCATION || LOCATION_FILE (loc) == NULL) return NULL; json::object *phys_loc_obj = new json::object (); diff --git a/gcc/testsuite/gcc.dg/analyzer/sarif-pr107366.c b/gcc/testsuite/gcc.dg/analyzer/sarif-pr107366.c new file mode 100644 index 00000000000..997cf56586d --- /dev/null +++ b/gcc/testsuite/gcc.dg/analyzer/sarif-pr107366.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-fdiagnostics-format=sarif-file" } */ + +typedef enum { + HWLOC_TOPOLOGY_DIFF_OBJ_ATTR_INFO +} hwloc_topology_diff_obj_attr_type_t; +enum { HWLOC_TOPOLOGY_DIFF_OBJ_ATTR } hwloc_apply_diff_one_diff_0_0; + +void +hwloc_apply_diff_one() { + switch (hwloc_apply_diff_one_diff_0_0) + case HWLOC_TOPOLOGY_DIFF_OBJ_ATTR: { + hwloc_topology_diff_obj_attr_type_t obj_attr_2_0_0; + switch (obj_attr_2_0_0) + case HWLOC_TOPOLOGY_DIFF_OBJ_ATTR_INFO: { + unsigned ii = 0; + } + } +} + -- 2.26.3