diff options
author | Patrick Palka <ppalka@redhat.com> | 2021-04-02 19:47:09 -0400 |
---|---|---|
committer | Patrick Palka <ppalka@redhat.com> | 2021-04-02 19:47:09 -0400 |
commit | cf25e27faef75e265e659f39ef6b7d0f1695dfeb (patch) | |
tree | a8feac150e66d0be5bba71e19e8e2be9ca8ca20a /gcc/cp/semantics.c | |
parent | 2a26351b598242c2fbce95d2a0baacce0084aec6 (diff) | |
download | gcc-cf25e27faef75e265e659f39ef6b7d0f1695dfeb.zip gcc-cf25e27faef75e265e659f39ef6b7d0f1695dfeb.tar.gz gcc-cf25e27faef75e265e659f39ef6b7d0f1695dfeb.tar.bz2 |
c++: Refine check for CTAD placeholder [PR99586]
In the below testcase, during finish_compound_literal for A<B{V}>{},
type_uses_auto finds and returns the CTAD placeholder for B{V}, which
tricks us into attempting CTAD on A<B{V}>{} and leads to bogus errors.
AFAICT 'type' will always be a bare 'auto' in the CTAD case so we don't
need to look deeply to find it; checking template_placeholder_p instead
should suffice here.
gcc/cp/ChangeLog:
PR c++/99586
* semantics.c (finish_compound_literal): Check
template_placeholder_p instead of type_uses_auto.
gcc/testsuite/ChangeLog:
PR c++/99586
* g++.dg/cpp2a/nontype-class42.C: New test.
Diffstat (limited to 'gcc/cp/semantics.c')
-rw-r--r-- | gcc/cp/semantics.c | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index b02596f..8eaaaef 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; |