]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
c++: QT overload regression with attribute [PR94946]
authorNathan Sidwell <nathan@acm.org>
Wed, 6 May 2020 19:07:30 +0000 (12:07 -0700)
committerNathan Sidwell <nathan@acm.org>
Wed, 6 May 2020 19:07:30 +0000 (12:07 -0700)
Jason's fix for 90570 & 79585 was a bit overzealous.  Dependent attribs should still
attach to a parameter decl.

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

gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/testsuite/g++.dg/ext/attr-parm-1.C [new file with mode: 0644]

index 3c57945cecfd84641dcb8f7ec26cb035b057a072..87c7e239b9e781a214063ccbe058a3d7c096cc52 100644 (file)
@@ -1,3 +1,9 @@
+2020-05-06  Nathan Sidwell  <nathan@acm.org>
+
+       PR c++/94946
+       * decl.c (grokdeclarator): Don't splice template attributes in
+       parm context -- they can apply to the parm.
+
 2020-04-30  Jason Merrill  <jason@redhat.com>
            Nathan Sidwell  <nathan@acm.org>
 
index 4c0ae1cfa2ed455d224aaffa37ee4b319a14016b..572e220aa45a36200743fd04eb2af9edd24b1b7f 100644 (file)
@@ -11937,9 +11937,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 a/gcc/testsuite/g++.dg/ext/attr-parm-1.C b/gcc/testsuite/g++.dg/ext/attr-parm-1.C
new file mode 100644 (file)
index 0000000..37214e6
--- /dev/null
@@ -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)());
+};