diff options
author | Nathan Sidwell <nathan@acm.org> | 2020-05-06 12:09:59 -0700 |
---|---|---|
committer | Nathan Sidwell <nathan@acm.org> | 2020-05-06 12:14:44 -0700 |
commit | bc95e478febd35e0d1fb13c1833d2383ad0e7d18 (patch) | |
tree | 847d03f15b3c822cef5cab23aa855ddbb38656bf /gcc | |
parent | 80644a672e635261c15a5804cdcd1eb851814478 (diff) | |
download | gcc-bc95e478febd35e0d1fb13c1833d2383ad0e7d18.zip gcc-bc95e478febd35e0d1fb13c1833d2383ad0e7d18.tar.gz gcc-bc95e478febd35e0d1fb13c1833d2383ad0e7d18.tar.bz2 |
c++: QT overload regression with attribute [PR94946]
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.
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/cp/decl.c | 9 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/ext/attr-parm-1.C | 6 |
3 files changed, 18 insertions, 3 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 218ed03..7e41433 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -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-05-05 Iain Sandoe <iain@sandoe.co.uk> * coroutines.cc: Remove references to n4849 throughout. diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 3e7ed98..232d7ed 100644 --- a/gcc/cp/decl.c +++ b/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 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 0000000..cc53a2c --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/attr-parm-1.C @@ -0,0 +1,6 @@ +// { dg-do compile { target { { i?86-*-* x86_64-*-* } && ia32 } } } +// PR 94946 +class a { + template <typename b> a(b (*)()); + template <typename b> a(b(__attribute__((fastcall)) *c)()); +}; |