Message ID | 5508DCFB.7020103@oracle.com |
---|---|
State | New |
Headers | show |
On 03/17/2015 10:03 PM, Paolo Carlini wrote: > Hi, > > On 03/18/2015 01:11 AM, Jason Merrill wrote: >> On 03/17/2015 01:09 PM, Paolo Carlini wrote: >>> - require_deduced_type (decl); >>> + if (complain & tf_error) >>> + require_deduced_type (decl); >> >> I think we want to return false if there's a problem here so that we >> don't just silently accept this in SFINAE context. So probably we >> want to replace the call with an inlined form like earlier in mark_used. > Indeed, I was a bit nervous about that, should have asked... Anyway, the > below is finishing testing. OK. >> Are there other places that still need to pass complain to mark_used? > Well, if we are talking about functions getting a tsubst_flags_t and > *not* passing it down to mark_used, there are quite a few - see > attached. I didn't feel like raising the issue at this time because in > all those cases, at variance with the specific case we are changing for > the bug, the return value of mark_used is *not* checked, thus is we > suppress the errors in SFINAE context we would like to also add a check > and return early, but in general, doing that when we are *outside* > SFINAE changes what happens during error recovery, thus it seems a bit > risky fiddling with those right now... Agreed, let's defer this until stage 1. Jason
On 03/17/2015 10:15 PM, Jason Merrill wrote: > On 03/17/2015 10:03 PM, Paolo Carlini wrote: >> On 03/18/2015 01:11 AM, Jason Merrill wrote: >>> Are there other places that still need to pass complain to mark_used? >> Well, if we are talking about functions getting a tsubst_flags_t and >> *not* passing it down to mark_used, there are quite a few - see >> attached. I didn't feel like raising the issue at this time because in >> all those cases, at variance with the specific case we are changing for >> the bug, the return value of mark_used is *not* checked, thus is we >> suppress the errors in SFINAE context we would like to also add a check >> and return early, but in general, doing that when we are *outside* >> SFINAE changes what happens during error recovery, thus it seems a bit >> risky fiddling with those right now... > > Agreed, let's defer this until stage 1. I note that it's now stage 1. :) There are various places in the compiler that error and continue if tf_error is set, but return error_mark_node immediately if not; it seems reasonable to follow that pattern in the places that don't currently check the return value. Jason
Hi, On 04/15/2015 03:31 AM, Jason Merrill wrote: > Agreed, let's defer this until stage 1. > > I note that it's now stage 1. :) > > There are various places in the compiler that error and continue if > tf_error is set, but return error_mark_node immediately if not; it > seems reasonable to follow that pattern in the places that don't > currently check the return value. Agreed. First, let me double check that the draft patch which I attached in this thread still passes testing. Paolo.
Index: cp/call.c =================================================================== --- cp/call.c (revision 221481) +++ cp/call.c (working copy) @@ -7486,7 +7486,7 @@ build_over_call (struct z_candidate *cand, int fla } if (!already_used - && !mark_used (fn)) + && !mark_used (fn, complain)) return error_mark_node; if (DECL_VINDEX (fn) && (flags & LOOKUP_NONVIRTUAL) == 0 Index: cp/decl2.c =================================================================== --- cp/decl2.c (revision 221481) +++ cp/decl2.c (working copy) @@ -5037,7 +5037,12 @@ mark_used (tree decl, tsubst_flags_t complain) && uses_template_parms (DECL_TI_ARGS (decl))) return true; - require_deduced_type (decl); + if (undeduced_auto_decl (decl)) + { + if (complain & tf_error) + error ("use of %qD before deduction of %<auto%>", decl); + return false; + } /* If we don't need a value, then we don't need to synthesize DECL. */ if (cp_unevaluated_operand != 0) Index: testsuite/g++.dg/cpp1y/pr65340.C =================================================================== --- testsuite/g++.dg/cpp1y/pr65340.C (revision 0) +++ testsuite/g++.dg/cpp1y/pr65340.C (working copy) @@ -0,0 +1,19 @@ +// PR c++/65340 +// { dg-do compile { target c++14 } } + +template <typename Type> Type constant; +namespace reflect { +namespace functors { + struct recurse { auto operator()(, ); }; // { dg-error "expected" } +} + auto &recurse = constant < functors :: recurse > ; +} +namespace functors { +struct traverse { + template <typename Algo, typename Value> + auto operator()(Algo, Value) -> decltype(reflect + :: recurse(0, 0)); // { dg-error "use of" } +}; +} +auto &traverse = constant < functors :: traverse > ; +operator()()->decltype(traverse(0, 0)) // { dg-error "no match|expected" }