This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Fix PR49718 : allow no_instrument_function attribute in class member definition/declaration


    All,

I was looking at PR49718. I have enclosed a simple fix for this bug report.

2014-01-07  Laurent Alfonsi <laurent.alfonsi@st.com>

    * c-family/c-common.c (handle_no_instrument_function_attribute): Allow
no_instrument_function attribute in class member definition/declaration.


Looking at the implementation of the function attributes, I see no reason anymore to keep this error message.
Let me know if I missed something.
I have also added a testcase in the enclosed patch.

2014-01-07  Laurent Alfonsi <laurent.alfonsi@st.com>

    PR c++/49718
    * g++.dg/pr49718.C: New


gcc/g++/libstdc++ testsuites are ok on x86-64. Ok for trunk ?

Regards,
Laurent

>From 141d2bcfeab5e0635c7f4e362387fd5b1b9494e6 Mon Sep 17 00:00:00 2001
From: Laurent ALFONSI <laurent.alfonsi@st.com>
Date: Tue, 7 Jan 2014 16:26:04 +0100
Subject: [PATCH] Fix PR49718 : allow no_instrument_function attribute in class
 member definition/declaration

---
 gcc/c-family/c-common.c        |  6 ------
 gcc/testsuite/g++.dg/pr49718.C | 41 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 41 insertions(+), 6 deletions(-)
 create mode 100644 gcc/testsuite/g++.dg/pr49718.C

diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c
index 8ecb70c..17fcb0d 100644
--- a/gcc/c-family/c-common.c
+++ b/gcc/c-family/c-common.c
@@ -7929,12 +7929,6 @@ handle_no_instrument_function_attribute (tree *node, tree name,
 		"%qE attribute applies only to functions", name);
       *no_add_attrs = true;
     }
-  else if (DECL_INITIAL (decl))
-    {
-      error_at (DECL_SOURCE_LOCATION (decl),
-		"can%'t set %qE attribute after definition", name);
-      *no_add_attrs = true;
-    }
   else
     DECL_NO_INSTRUMENT_FUNCTION_ENTRY_EXIT (decl) = 1;
 
diff --git a/gcc/testsuite/g++.dg/pr49718.C b/gcc/testsuite/g++.dg/pr49718.C
new file mode 100644
index 0000000..07cac8c
--- /dev/null
+++ b/gcc/testsuite/g++.dg/pr49718.C
@@ -0,0 +1,41 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -finstrument-functions" } */
+/* { dg-final { scan-assembler-times "__cyg_profile_func_enter" 1} } */
+
+#define NOINSTR __attribute__((no_instrument_function))
+
+struct t
+{
+   public:
+       /* Function code should be instrumented */
+       __attribute__((noinline)) t() {}
+       
+       /* Function t::a() should not be instrumented */
+       NOINSTR void a(){
+       }
+       /* Function t::b() should not be instrumented */
+       void NOINSTR b(){
+       }
+       /* Function t::c() should not be instrumented */
+       void c() NOINSTR {
+       }
+       /* Function t::d() should not be instrumented */
+       void d() NOINSTR;
+};
+
+void t::d()
+{
+}
+
+/* Function call_all_functions() should not be instrumented */
+struct t call_all_functions() __attribute__((no_instrument_function));
+struct t call_all_functions() 
+{
+       struct t a;     /* Constructor not inlined */
+       a.a();	       /* Inlined t::a() should not be instrumented */
+       a.b();	       /* Inlined t::b() should not be instrumented */
+       a.c();	       /* Inlined t::c() should not be instrumented */
+       a.d();	       /* Inlined t::d() should not be instrumented */
+       return a;
+}
+
-- 
1.8.4.1


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]