This appears to fix 94946 -- regular testsuite passes, bootstrapping now. I'll commit if the bootstrap is good.

Jakub, ok for gcc-10 too?

nathan

--
Nathan Sidwell
2020-05-06  Nathan Sidwell  <nat...@acm.org>

	PR c++/94946
	* decl.c (grokdeclarator): Don't splice template attributes in
	parm context -- they can apply to the parm.

diff --git c/gcc/cp/decl.c w/gcc/cp/decl.c
index 3e7ed98fed3..232d7ed4a14 100644
--- c/gcc/cp/decl.c
+++ w/gcc/cp/decl.c
@@ -11940,9 +11940,12 @@ grokdeclarator (const cp_declarator *declarator,
 	    attr_flags |= (int) ATTR_FLAG_FUNCTION_NEXT;
 	  if (declarator->kind == cdk_array)
 	    attr_flags |= (int) ATTR_FLAG_ARRAY_NEXT;
-	  /* Assume that any attributes that get applied late to templates will
-	     DTRT when applied to the declaration as a whole.  */
-	  tree late_attrs = splice_template_attributes (&attrs, type);
+	  tree late_attrs = NULL_TREE;
+	  if (decl_context != PARM)
+	    /* Assume that any attributes that get applied late to
+	       templates will DTRT when applied to the declaration
+	       as a whole.  */
+	    late_attrs = splice_template_attributes (&attrs, type);
 	  returned_attrs = decl_attributes (&type,
 					    chainon (returned_attrs, attrs),
 					    attr_flags);
diff --git c/gcc/testsuite/g++.dg/ext/attr-parm-1.C w/gcc/testsuite/g++.dg/ext/attr-parm-1.C
new file mode 100644
index 00000000000..37214e63c01
--- /dev/null
+++ w/gcc/testsuite/g++.dg/ext/attr-parm-1.C
@@ -0,0 +1,7 @@
+// { dg-do compile { target { i?86-*-* x86_64-*-* } } }
+// { dg-options -m32 }
+// PR 94946
+class a {
+  template <typename b> a(b (*)());
+  template <typename b> a(b(__attribute__((fastcall)) *c)());
+};

Reply via email to