gnu/gcc/daa030592bdd082c8a4452df5fddc98686d51003 c++: Don't support auto{x} and auto(x) for C++ < 23 in SFINAE contexts [PR120685]
The following testcase ICEs in C++ 20 and older, because during
diagnostics dump_template_bindings attempts to tsubst with tf_none
something and we try to emit a pedwarn during that.
While the pedwarn could be just guarded with if (complain & tf_warning),
I thought we shouldn't support extensions for tf_none and should
instead return error_mark_node.
The following patch does that.
This is a backport version which instead of not supporting it just
doesn't emit the pedwarn in SFINAE contexts for C++ < 23 but still
supports it.
2026-02-17 Jakub Jelinek <jakub@redhat.com>
PR c++/120685
* typeck2.cc (build_functional_cast_1): For C++23 auto(x)
without tf_warning or tf_error return error_mark_node instead of
emitting pedwarn and handling it.
* semantics.cc (finish_compound_literal): Similarly for C++26
auto{x}.
* g++.dg/cpp23/auto-fncast19.C: New test.
(cherry picked from commit f7efb7e62ac96c082ff72549d9b3789f5c955efe)
3 files changed