From: Nathan Sidwell Date: Wed, 6 May 2020 19:37:30 +0000 (-0700) Subject: c++: QT overload regression with attribute [PR94946] X-Git-Tag: misc/first-auto-changelog-9~53 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=efdbd4fbea08005091e490ec3f9972aa9c946374;p=thirdparty%2Fgcc.git c++: QT overload regression with attribute [PR94946] 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. --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index fe53cc0c0bd3..1b0b35c0ff24 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2020-05-06 Nathan Sidwell + + 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 PR c++/90750 diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 79f61dfe0646..bf00583e29fe 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -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 index 000000000000..872b3e0a019e --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/attr-parm-1.C @@ -0,0 +1,7 @@ +// { dg-do compile { target { { i?86-*-* x86_64-*-* } && ia32 } } } +// { dg-options -m32 } +// PR 94946 +class a { + template a(b (*)()); + template a(b(__attribute__((fastcall)) *c)()); +};