On Tue, Mar 20, 2018 at 5:57 PM, Alexandre Oliva <aol...@redhat.com> wrote: > On Mar 20, 2018, Jason Merrill <ja...@redhat.com> wrote: > >>> While debugging this, I first tried another patch, that avoids the same >>> ICEs. I thought this one was a more complete solution, and it renders >>> the other unnecessary, but I still though it might be useful to disable >>> auto->implicit_parm while parsing declarators, so as to avoid useless >>> processing. > >> Better, I think, to disable it while parsing attributes; we could >> still encounter auto as a template argument in a declarator. > > How about this? Regstrapping, ok to install if it passes? > > Disable auto_is_implicit_function_template_parm_p while parsing attributes > > for gcc/cp/ChangeLog > > PR c++/84610 > PR c++/84642 > * parser.c (temp_override): New template class, > generalizing... > (cp_parser_parameter_declaration_clause): ... this cleanup. > Use it. > (cp_parser_gnu_attributes_opt): Use it. > (cp_parser_std_attribute): Use it. > --- > gcc/cp/parser.c | 36 ++++++++++++++++++++++++++---------- > 1 file changed, 26 insertions(+), 10 deletions(-) > > diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c > index 5cc201604166..ce05615adfba 100644 > --- a/gcc/cp/parser.c > +++ b/gcc/cp/parser.c > @@ -255,6 +255,21 @@ static bool cp_parser_omp_declare_reduction_exprs > static void cp_finalize_oacc_routine > (cp_parser *, tree, bool); > > +template <typename T> > +class temp_override > +{ > + T& overridden_variable; > + T saved_value; > +public: > + temp_override(T& var) : overridden_variable (var), saved_value (var) {} > + temp_override(T& var, T overrider) > + : overridden_variable (var), saved_value (var) > + { > + overridden_variable = overrider; > + } > + ~temp_override() { overridden_variable = saved_value; } > +};
Let's put this in cp-tree.h, with warning_sentinel. > + (void)cleanup; There are lots of RAII variables without this explicit cast to void, and they don't seem to have been a problem; let's drop it here as well. Jason