aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/typeck2.c
diff options
context:
space:
mode:
authorPatrick Palka <ppalka@redhat.com>2021-04-13 12:35:33 -0400
committerPatrick Palka <ppalka@redhat.com>2021-04-13 12:35:33 -0400
commit8913b2c2bcded39427ff27e6dfc276ae8555f6b8 (patch)
tree41f41a744c09f93171b86d5a51bf2815ce7a2c96 /gcc/cp/typeck2.c
parent989e512f719a44fafca0030d7b8a1f5bf5f1baf7 (diff)
downloadgcc-8913b2c2bcded39427ff27e6dfc276ae8555f6b8.zip
gcc-8913b2c2bcded39427ff27e6dfc276ae8555f6b8.tar.gz
gcc-8913b2c2bcded39427ff27e6dfc276ae8555f6b8.tar.bz2
c++: Reject alias CTAD in C++17 [PR99008]
Here, in C++17 mode, we only pedwarn about the use of alias CTAD and then later ICE from alias_ctad_tweaks when attempting to constrain the guides. Since the construction of the guides of an alias template effectively relies on concepts, we shouldn't be permissive about alias CTAD in C++17 mode, so this patch turns the pertinent pedwarn in do_class_deduction into an error. In order to get a consistent diagnostic for B() vs the other forms in the added testcase, I had to remove the special handling of CTAD with empty initializer in build_functional_cast_1 so that we always pass 'complain' to do_auto_deduction. gcc/cp/ChangeLog: PR c++/99008 * pt.c (do_class_deduction): Reject alias CTAD in C++17 mode rather than issuing a pedwarn. * typeck2.c (build_functional_cast_1): Handle CTAD uniformly for consistent diagnostics. gcc/testsuite/ChangeLog: PR c++/99008 * g++.dg/parse/template2.C: Adjust expected diagnostic. * g++.dg/template/error8.C: Likewise. * g++.dg/cpp1z/class-deduction84.C: New test.
Diffstat (limited to 'gcc/cp/typeck2.c')
-rw-r--r--gcc/cp/typeck2.c17
1 files changed, 3 insertions, 14 deletions
diff --git a/gcc/cp/typeck2.c b/gcc/cp/typeck2.c
index a58d397..4e9632f 100644
--- a/gcc/cp/typeck2.c
+++ b/gcc/cp/typeck2.c
@@ -2197,24 +2197,13 @@ build_functional_cast_1 (location_t loc, tree exp, tree parms,
error_at (loc, "invalid use of %qT", anode);
return error_mark_node;
}
- else if (!parms)
+ else
{
- /* Even if there are no parameters, we might be able to deduce from
- default template arguments. Pass TF_NONE so that we don't
- generate redundant diagnostics. */
- type = do_auto_deduction (type, parms, anode, tf_none,
+ type = do_auto_deduction (type, parms, anode, complain,
adc_variable_type);
if (type == error_mark_node)
- {
- if (complain & tf_error)
- error_at (loc, "cannot deduce template arguments "
- "for %qT from %<()%>", anode);
- return error_mark_node;
- }
+ return error_mark_node;
}
- else
- type = do_auto_deduction (type, parms, anode, complain,
- adc_variable_type);
}
if (processing_template_decl)