diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index b02596f73bd..8eaaaefe2d6 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -3036,14 +3036,13 @@ finish_compound_literal (tree type, tree compound_literal, return error_mark_node; } - if (tree anode = type_uses_auto (type)) - if (CLASS_PLACEHOLDER_TEMPLATE (anode)) - { - type = do_auto_deduction (type, compound_literal, anode, complain, - adc_variable_type); - if (type == error_mark_node) - return error_mark_node; - } + if (template_placeholder_p (type)) + { + type = do_auto_deduction (type, compound_literal, type, complain, + adc_variable_type); + if (type == error_mark_node) + return error_mark_node; + } /* Used to hold a copy of the compound literal in a template. */ tree orig_cl = NULL_TREE; diff --git a/gcc/testsuite/g++.dg/cpp2a/nontype-class42.C b/gcc/testsuite/g++.dg/cpp2a/nontype-class42.C new file mode 100644 index 00000000000..c2e04b2820c --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp2a/nontype-class42.C @@ -0,0 +1,8 @@ +// PR c++/99586 +// { dg-do compile { target c++20 } } + +template +struct B { constexpr B(T); }; + +template struct A{}; +template auto a = A{};