https://gcc.gnu.org/g:2bbbdffdb45f5977cceaf987efbe2dc16168ee26
commit 2bbbdffdb45f5977cceaf987efbe2dc16168ee26 Author: Sandra Loosemore <[email protected]> Date: Sat Jul 4 13:58:42 2026 +0000 Fortran: Fix ICE-on-invalid in trans_code. gcc/fortran/ChangeLog * trans.cc (trans_code): Do not try to set location on non-expr tree expressions, e.g. error_mark_node. (cherry picked from commit 5f2c4cacfcdf9f6ed77ded6467df31cc90181e07) Diff: --- gcc/fortran/trans.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/gcc/fortran/trans.cc b/gcc/fortran/trans.cc index c366d7f4dbff..874dac59e4a0 100644 --- a/gcc/fortran/trans.cc +++ b/gcc/fortran/trans.cc @@ -2696,7 +2696,9 @@ trans_code (gfc_code * code, tree cond) if (res != NULL_TREE && ! IS_EMPTY_STMT (res)) { - if (TREE_CODE (res) != STATEMENT_LIST) + /* Don't try to set location for trees that don't have one, + e.g. STATEMENT_LIST or error_mark_node. */ + if (EXPR_P (res)) SET_EXPR_LOCATION (res, input_location); /* Add the new statement to the block. */
