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, CHKP, PR middle-end/71529] Fix DECL_CONTEXT for args of instrumentation clones with no body


Hi,

Currently chkp_build_instrumented_fndecl copies arguments list
in case function has no body.  Copied arguments have incorrect
DECL_CONTEXT and this patch fixes it.

Bootstrapped and regtested for x86_64-unknown-linux-gnu.  I'm
going to commit it to trunk and later port to gcc-6-branch.

Thanks,
Ilya
--
gcc/

2016-06-15  Ilya Enkovich  <ilya.enkovich@intel.com>

	PR middle-end/71529
	* ipa-chkp.c (chkp_build_instrumented_fndecl): Fix
	DECL_CONTEXT for copied arguments.

gcc/testsuite/

2016-06-15  Ilya Enkovich  <ilya.enkovich@intel.com>

	PR middle-end/71529
	* gcc.target/i386/pr71529.C: New test.


diff --git a/gcc/ipa-chkp.c b/gcc/ipa-chkp.c
index 5f5df64..86c48f1 100644
--- a/gcc/ipa-chkp.c
+++ b/gcc/ipa-chkp.c
@@ -207,7 +207,13 @@ chkp_build_instrumented_fndecl (tree fndecl)
   /* For functions with body versioning will make a copy of arguments.
      For functions with no body we need to do it here.  */
   if (!gimple_has_body_p (fndecl))
-    DECL_ARGUMENTS (new_decl) = copy_list (DECL_ARGUMENTS (fndecl));
+    {
+      tree arg;
+
+      DECL_ARGUMENTS (new_decl) = copy_list (DECL_ARGUMENTS (fndecl));
+      for (arg = DECL_ARGUMENTS (new_decl); arg; arg = DECL_CHAIN (arg))
+	DECL_CONTEXT (arg) = new_decl;
+    }
 
   /* We are going to modify attributes list and therefore should
      make own copy.  */
diff --git a/gcc/testsuite/gcc.target/i386/pr71529.C b/gcc/testsuite/gcc.target/i386/pr71529.C
new file mode 100644
index 0000000..3169101
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr71529.C
@@ -0,0 +1,22 @@
+/* PR71529 */
+/* { dg-do compile { target { ! x32 } } } */
+/* { dg-options "-fcheck-pointer-bounds -mmpx -O2" } */
+
+class c1
+{
+ public:
+  virtual ~c1 ();
+};
+
+class c2
+{
+ public:
+  virtual ~c2 ();
+};
+
+class c3 : c1, c2 { };
+
+int main (int, char **)
+{
+  c3 obj;
+}


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