https://gcc.gnu.org/g:5f2c4cacfcdf9f6ed77ded6467df31cc90181e07
commit r17-2155-g5f2c4cacfcdf9f6ed77ded6467df31cc90181e07 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. 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 b2ea499bbbe6..51252561b2e4 100644 --- a/gcc/fortran/trans.cc +++ b/gcc/fortran/trans.cc @@ -2697,7 +2697,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. */
