From: Richard Biener Date: Fri, 6 Feb 2026 08:26:37 +0000 (+0100) Subject: tree-optimization/114274 - avoid stray BLOCK refrence from CSWTCH vars X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=48e114ee2a0d5b19796f4f03644d9d9925379e1f;p=thirdparty%2Fgcc.git tree-optimization/114274 - avoid stray BLOCK refrence from CSWTCH vars The following removes the location from CSWTCH variables which are DECL_IGNORED_P and have no DECL_CONTEXT. The location is currently taken from the gswitch statement and thus includes a BLOCK reference which can eventually be elided and GCd, causing later ICEs when ICF decides to merge the variable with some other. PR tree-optimization/114274 * tree-switch-conversion.cc (switch_conversion::build_one_array): Use UNKNOWN_LOCATION for the CSWTCH decl. --- diff --git a/gcc/tree-switch-conversion.cc b/gcc/tree-switch-conversion.cc index cc2b0a5ec30..5027ab559c0 100644 --- a/gcc/tree-switch-conversion.cc +++ b/gcc/tree-switch-conversion.cc @@ -971,7 +971,6 @@ switch_conversion::build_one_array (int num, tree arr_index_type, tree name; gimple *load; gimple_stmt_iterator gsi = gsi_for_stmt (m_switch); - location_t loc = gimple_location (m_switch); gcc_assert (m_default_values[num]); @@ -1030,7 +1029,7 @@ switch_conversion::build_one_array (int num, tree arr_index_type, TREE_CONSTANT (ctor) = true; TREE_STATIC (ctor) = true; - decl = build_decl (loc, VAR_DECL, NULL_TREE, array_type); + decl = build_decl (UNKNOWN_LOCATION, VAR_DECL, NULL_TREE, array_type); TREE_STATIC (decl) = 1; DECL_INITIAL (decl) = ctor;