mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-04-09 23:51:18 +08:00
diagnostics: fix ICE in sarif output with NULL filename [PR107366]
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 <dmalcolm@redhat.com>
This commit is contained in:
parent
18faaeb3af
commit
2e8a055391
@ -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 ();
|
||||
|
20
gcc/testsuite/gcc.dg/analyzer/sarif-pr107366.c
Normal file
20
gcc/testsuite/gcc.dg/analyzer/sarif-pr107366.c
Normal file
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user