On Fri, Mar 25, 2022 at 07:55:56PM +0100, Jakub Jelinek via Gcc-patches wrote: > On Fri, Mar 25, 2022 at 07:48:33PM +0100, Jakub Jelinek wrote: > > We then wouldn't propagate TREE_DEPRECATED/TREE_UNAVAILABLE from templates > > to their instantiations and wouldn't diagnose static data members in OpenMP > > declare target. > > But perhaps that is fine, with error_mark_attribute it is error recovery > > anyway. > > Can the splice_template_attributes change stay too, or just > > change cplus_decl_attributes (add it to the early out, remove from other > > spots in the function)? > > So like (or without the first hunk): > > 2022-03-25 Jakub Jelinek <ja...@redhat.com> > > PR c++/104668 > * decl2.cc (splice_template_attributes): Return NULL if *p is > error_mark_node. > (cplus_decl_attributes): Return early if attributes is > error_mark_node. Don't check that later. > > * g++.dg/cpp0x/pr104668.C: New test.
I'd like to ping this patch. Bootstrapped/regtested successfully on {powerpc64le,x86_64,i686}-linux. > --- gcc/cp/decl2.cc.jj 2022-03-09 09:09:55.415843331 +0100 > +++ gcc/cp/decl2.cc 2022-03-25 19:54:12.454749089 +0100 > @@ -1336,7 +1336,7 @@ splice_template_attributes (tree *attr_p > tree late_attrs = NULL_TREE; > tree *q = &late_attrs; > > - if (!p) > + if (!p || *p == error_mark_node) > return NULL_TREE; > > for (; *p; ) > @@ -1631,7 +1631,7 @@ void > cplus_decl_attributes (tree *decl, tree attributes, int flags) > { > if (*decl == NULL_TREE || *decl == void_type_node > - || *decl == error_mark_node) > + || *decl == error_mark_node || attributes == error_mark_node) > return; > > /* Add implicit "omp declare target" attribute if requested. */ > @@ -1668,7 +1668,7 @@ cplus_decl_attributes (tree *decl, tree > > cp_check_const_attributes (attributes); > > - if ((flag_openmp || flag_openmp_simd) && attributes != error_mark_node) > + if (flag_openmp || flag_openmp_simd) > { > bool diagnosed = false; > for (tree *pa = &attributes; *pa; ) > --- gcc/testsuite/g++.dg/cpp0x/pr104668.C.jj 2022-03-25 17:25:42.280068058 > +0100 > +++ gcc/testsuite/g++.dg/cpp0x/pr104668.C 2022-03-25 17:24:44.862881444 > +0100 > @@ -0,0 +1,13 @@ > +// PR c++/104668 > +// { dg-do compile { target c++11 } } > +// { dg-excess-errors "" } > + > +template <class... Ts> > +void sink(Ts...); > +template <class... Ts> > +void f(Ts...) { > + sink([] { struct alignas:Ts) S {}; }...); } > +} > +int main() { > + f(0); > +} Jakub