]> 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:37:30 +0000 (12:37 -0700)
committerNathan Sidwell <nathan@acm.org>
Wed, 6 May 2020 19:37:30 +0000 (12:37 -0700)
Jason's fix for 90570 & 79585 was a bit overzealous.  Dependent attribs should still
ttach 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 fe53cc0c0bd3bd182e68ddcd2737f8a3d54b8fe3..1b0b35c0ff240c5e1910105c4fb9c763658fc996 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-27  Jason Merrill  <jason@redhat.com>
 
        PR c++/90750
index 79f61dfe0646979a269ab3e448f99c5b93bb9552..bf00583e29fef7a6d35042c300ff363f5a8c5217 100644 (file)
@@ -11259,9 +11259,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..872b3e0
--- /dev/null
@@ -0,0 +1,7 @@
+// { dg-do compile { target { { i?86-*-* x86_64-*-* } && ia32 } } }
+// { dg-options -m32 }
+// PR 94946
+class a {
+  template <typename b> a(b (*)());
+  template <typename b> a(b(__attribute__((fastcall)) *c)());
+};