aboutsummaryrefslogtreecommitdiff
path: root/libphobos/src
diff options
context:
space:
mode:
authorMarek Polacek <polacek@redhat.com>2022-04-14 13:48:15 -0400
committerMarek Polacek <polacek@redhat.com>2022-04-15 09:59:11 -0400
commitccae4443c8322d9d82a19a1e7c689413a122a478 (patch)
tree6386a8ba124f3532d233d5038bd9667dc8e8f4f4 /libphobos/src
parenta54137c88061c7495728fc6b8dfd0474e812b2cb (diff)
downloadgcc-ccae4443c8322d9d82a19a1e7c689413a122a478.zip
gcc-ccae4443c8322d9d82a19a1e7c689413a122a478.tar.gz
gcc-ccae4443c8322d9d82a19a1e7c689413a122a478.tar.bz2
c++: wrong error with variadic concept [PR105268]
Here we issue a wrong error for the template<typename T = S<C_many<int>>> void g(); line in the testcase. I surmise that's because we mistakenly parse C_many<int> as a placeholder-type-specifier, and things go wrong from there. We are in a default argument so we should reject parsing C_many<int> as a placeholder-type-specifier, which would mean creating a new parameter. We want C_many<int> to be a concept-id instead. It's interesting to see why the same problem didn't occur for C_one<int>. In that case, cp_parser_placeholder_type_specifier -> finish_type_constraints -> build_type_constraint -> build_concept_check -> build_standard_check -> coerce_template_parms fails the parse here: 8916 nargs = inner_args ? NUM_TMPL_ARGS (inner_args) : 0; 8917 if ((nargs - variadic_args_p > nparms && !variadic_p) 8918 || (nargs < nparms - variadic_p 8919 && require_all_args 8920 && !variadic_args_p 8921 && (!use_default_args 8922 || (TREE_VEC_ELT (parms, nargs) != error_mark_node 8923 && !TREE_PURPOSE (TREE_VEC_ELT (parms, nargs)))))) 8924 { 8925 bad_nargs: ... 8943 return error_mark_node; because nargs is 2 (the targs are <WILDCARD_DECL, int>) while nparms is 1 (for the one 'typename' in the tparam list of C_one). But for C_many<int> variadic_p is true so we don't return error_mark_node but <type_argument_pack>. This patch does not issue any error for the !tentative case because I didn't figure out how to trigger that. So it adds an assert instead. PR c++/105268 gcc/cp/ChangeLog: * parser.cc (cp_parser_placeholder_type_specifier): Return error_mark_node when trying to build up a constrained parameter in a default argument. gcc/testsuite/ChangeLog: * g++.dg/concepts/variadic6.C: New test.
Diffstat (limited to 'libphobos/src')
0 files changed, 0 insertions, 0 deletions