https://gcc.gnu.org/g:605803cf4089955c39dcbed97b343550581b8eed
commit r13-9305-g605803cf4089955c39dcbed97b343550581b8eed Author: Marek Polacek <pola...@redhat.com> Date: Fri Jan 10 17:29:36 2025 -0500 c++: ICE with variable template and [[deprecated]] [PR110031] lookup_and_finish_template_variable already has and uses the complain parameter but it is not passing it down to mark_used so we got the default tf_warning_or_error, which causes various problems when lookup_and_finish_template_variable gets called with complain=tf_none. PR c++/110031 gcc/cp/ChangeLog: * pt.cc (lookup_and_finish_template_variable): Pass complain to mark_used. gcc/testsuite/ChangeLog: * g++.dg/cpp1z/inline-var11.C: New test. Diff: --- gcc/cp/pt.cc | 2 +- gcc/testsuite/g++.dg/cpp1z/inline-var11.C | 32 +++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc index ddfa3c25d10e..bb53d9881405 100644 --- a/gcc/cp/pt.cc +++ b/gcc/cp/pt.cc @@ -10427,7 +10427,7 @@ lookup_and_finish_template_variable (tree templ, tree targs, deduction to work. */ complain &= ~tf_partial; var = finish_template_variable (var, complain); - mark_used (var); + mark_used (var, complain); return convert_from_reference (var); } diff --git a/gcc/testsuite/g++.dg/cpp1z/inline-var11.C b/gcc/testsuite/g++.dg/cpp1z/inline-var11.C new file mode 100644 index 000000000000..d92911ed3a93 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1z/inline-var11.C @@ -0,0 +1,32 @@ +// PR c++/110031 +// { dg-do compile { target c++17 } } + +template <typename T> +[[deprecated]] +inline constexpr bool t = true ; + +template <bool a> +struct enableif; + +template<> +struct enableif<true> +{ + using y = int; +}; +template <bool a> +using enableif_t = typename enableif<a>::y; + +template <typename T, enableif_t<t<T>> = 0> // { dg-warning "deprecated" } +struct A { A(T &&) { }}; + +template <typename T> +struct A<T> { + A(T &&) = delete; + A() = delete; +}; + +int main(void) +{ + A<double> a(5.3); // { dg-error "use of deleted function" } + return 0; +}