public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Fix PR c++/60765
@ 2014-04-07 21:00 Patrick Palka
  2014-04-09 20:37 ` Jason Merrill
  2014-04-16 12:15 ` Patrick Palka
  0 siblings, 2 replies; 4+ messages in thread
From: Patrick Palka @ 2014-04-07 21:00 UTC (permalink / raw)
  To: gcc-patches; +Cc: jason, Patrick Palka

Hi,

This patch teaches the C++ frontend how to handle function attributes
attached to pointer-to-member-function declarations.

I bootstrapped and regtested this patch on x86_64-unknown-linux-gnu.

2014-04-05  Patrick Palka  <patrick@parcs.ath.cx>

	PR c++/60765
	* decl2.c (cplus_decl_attributes): Handle
	pointer-to-member-function declarations.
---
 gcc/cp/decl2.c                              | 10 +++++++++-
 gcc/testsuite/g++.dg/cpp0x/gen-attrs-36-1.C |  2 +-
 gcc/testsuite/g++.dg/ext/attrib49.C         | 20 ++++++++++++++++++++
 3 files changed, 30 insertions(+), 2 deletions(-)
 create mode 100644 gcc/testsuite/g++.dg/ext/attrib49.C

diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c
index 80f15a4..91a75f3 100644
--- a/gcc/cp/decl2.c
+++ b/gcc/cp/decl2.c
@@ -1427,7 +1427,15 @@ cplus_decl_attributes (tree *decl, tree attributes, int flags)
   if (TREE_CODE (*decl) == TEMPLATE_DECL)
     decl = &DECL_TEMPLATE_RESULT (*decl);
 
-  decl_attributes (decl, attributes, flags);
+  if (TREE_TYPE (*decl) && TYPE_PTRMEMFUNC_P (TREE_TYPE (*decl)))
+    {
+      attributes
+	= decl_attributes (decl, attributes, flags | ATTR_FLAG_FUNCTION_NEXT);
+      decl_attributes (&TYPE_PTRMEMFUNC_FN_TYPE (TREE_TYPE (*decl)),
+		       attributes, flags);
+    }
+  else
+    decl_attributes (decl, attributes, flags);
 
   if (TREE_CODE (*decl) == TYPE_DECL)
     SET_IDENTIFIER_TYPE_VALUE (DECL_NAME (*decl), TREE_TYPE (*decl));
diff --git a/gcc/testsuite/g++.dg/cpp0x/gen-attrs-36-1.C b/gcc/testsuite/g++.dg/cpp0x/gen-attrs-36-1.C
index 2aae9ca..131af36 100644
--- a/gcc/testsuite/g++.dg/cpp0x/gen-attrs-36-1.C
+++ b/gcc/testsuite/g++.dg/cpp0x/gen-attrs-36-1.C
@@ -6,6 +6,6 @@ typedef int (*F [[gnu::warn_unused_result]]) (int);
 
 typedef int (*F2 [[gnu::warn_unused_result]]) (int);
 
-typedef int (S::*F3 [[gnu::warn_unused_result]]) (int); // { dg-warning "only applies to function types" }
+typedef int (S::*F3 [[gnu::warn_unused_result]]) (int);
 
 typedef int [[gnu::warn_unused_result]] (*F5) (int); // { dg-warning "ignored" }
diff --git a/gcc/testsuite/g++.dg/ext/attrib49.C b/gcc/testsuite/g++.dg/ext/attrib49.C
new file mode 100644
index 0000000..99c6154
--- /dev/null
+++ b/gcc/testsuite/g++.dg/ext/attrib49.C
@@ -0,0 +1,20 @@
+// PR c++/60765
+// { dg-options "-Wall -Wunused-parameter" }
+
+struct foo
+{
+} x;
+
+void (foo::*g) (int *) __attribute__ ((nonnull (2)));
+
+void
+fun1 (void (foo::*f) (int *) __attribute__ ((nonnull (2))))
+{
+    (x.*f) ((int *) 0); // { dg-warning "null argument" }
+}
+
+void
+fun2 (void (foo::*f) () __attribute__ ((nonnull, unused))) // { dg-bogus "unused" }
+{
+    (x.*g) ((int *) 0); // { dg-warning "null argument" }
+}
-- 
1.9.1

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Fix PR c++/60765
  2014-04-07 21:00 [PATCH] Fix PR c++/60765 Patrick Palka
@ 2014-04-09 20:37 ` Jason Merrill
  2014-04-16 12:15 ` Patrick Palka
  1 sibling, 0 replies; 4+ messages in thread
From: Jason Merrill @ 2014-04-09 20:37 UTC (permalink / raw)
  To: Patrick Palka, gcc-patches

OK.

Jason

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Fix PR c++/60765
  2014-04-07 21:00 [PATCH] Fix PR c++/60765 Patrick Palka
  2014-04-09 20:37 ` Jason Merrill
@ 2014-04-16 12:15 ` Patrick Palka
  2014-04-17  0:20   ` Patrick Palka
  1 sibling, 1 reply; 4+ messages in thread
From: Patrick Palka @ 2014-04-16 12:15 UTC (permalink / raw)
  To: GCC Patches; +Cc: Jason Merrill, Patrick Palka

Could someone install this on my behalf?

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Fix PR c++/60765
  2014-04-16 12:15 ` Patrick Palka
@ 2014-04-17  0:20   ` Patrick Palka
  0 siblings, 0 replies; 4+ messages in thread
From: Patrick Palka @ 2014-04-17  0:20 UTC (permalink / raw)
  To: GCC Patches; +Cc: Jason Merrill, Patrick Palka

Thanks, Paolo!

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-04-16 23:57 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-04-07 21:00 [PATCH] Fix PR c++/60765 Patrick Palka
2014-04-09 20:37 ` Jason Merrill
2014-04-16 12:15 ` Patrick Palka
2014-04-17  0:20   ` Patrick Palka

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).