gnu/gcc/e66c207e111e77c2c67d564ef2a7fdf95c958e8a c++: Fix up sb as condition instantiation error-recovery [PR120039]
The following two testcases ICE during instantation.
Normally for the artificial var used for structured binding as condition
(which has NULL DECL_NAME) there is a DECL_EXPR which registers local
specialization and so tsubst_expr works fine.
But if there are errors while parsing the initializer, the VAR_DECL
has still NULL_TREE DECL_NAME, but error_mark_node TREE_TYPE and
when tsubst_expr is called on it, it falls back to calling lookup_name
(NULL_TREE) and ICEs on that.
The following patch fixes it by not calling lookup_name if DECL_NAME is
NULL.
2026-03-16 Jakub Jelinek <jakub@redhat.com>
PR c++/120039
PR c++/122559
* pt.cc (tsubst_expr) <case VAR_DECL>: Don't call lookup_name on
DECL_NAME (t) if it is NULL_TREE.
* g++.dg/cpp26/decomp28.C: New test.
* g++.dg/cpp26/decomp29.C: New test.
Reviewed-by: Jason Merrill <jason@redhat.com>
(cherry picked from commit caae42b31118f754fbd1f9566373f589d7e1568f)
3 files changed