This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH 2/5] Get bounds for a PARM_DECL (PR ipa/79761).
- From: marxin <mliska at suse dot cz>
- To: gcc-patches at gcc dot gnu dot org
- Date: Thu, 2 Mar 2017 18:06:39 +0100
- Subject: [PATCH 2/5] Get bounds for a PARM_DECL (PR ipa/79761).
- Authentication-results: sourceware.org; auth=none
- References: <cover.1488881229.git.mliska@suse.cz>
- Resent-user-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.7.1
gcc/ChangeLog:
2017-03-06 Martin Liska <mliska@suse.cz>
PR ipa/79761
* tree-chkp.c (chkp_get_bound_for_parm): Get bounds for a param.
(chkp_find_bounds_1): Remove gcc_unreachable.
gcc/testsuite/ChangeLog:
2017-03-06 Martin Liska <mliska@suse.cz>
PR ipa/79761
* g++.dg/pr79761.C: New test.
---
gcc/testsuite/g++.dg/pr79761.C | 34 ++++++++++++++++++++++++++++++++++
gcc/tree-chkp.c | 3 +--
2 files changed, 35 insertions(+), 2 deletions(-)
create mode 100644 gcc/testsuite/g++.dg/pr79761.C
diff --git a/gcc/testsuite/g++.dg/pr79761.C b/gcc/testsuite/g++.dg/pr79761.C
new file mode 100644
index 00000000000..b1f92d2b036
--- /dev/null
+++ b/gcc/testsuite/g++.dg/pr79761.C
@@ -0,0 +1,34 @@
+/* { dg-do compile { target { ! x32 } } } */
+/* { dg-options "-fcheck-pointer-bounds -mmpx -mabi=ms" } */
+
+struct Foo
+{
+ Foo() : a(1), b(1), c('a') {}
+ int a;
+ int b;
+ char c;
+};
+
+static Foo copy_foo(Foo) __attribute__((noinline, noclone));
+
+static Foo copy_foo(Foo A)
+{
+ return A;
+}
+
+struct Bar : Foo
+{
+ Bar(Foo t) : Foo(copy_foo(t)) {}
+};
+
+Foo F;
+
+int main (void)
+{
+ Bar B (F);
+
+ if (B.a != 1 || B.b != 1 || B.c != 'a')
+ __builtin_abort ();
+
+ return 0;
+}
diff --git a/gcc/tree-chkp.c b/gcc/tree-chkp.c
index 3d497f51ed8..d5683b1b9cf 100644
--- a/gcc/tree-chkp.c
+++ b/gcc/tree-chkp.c
@@ -2353,7 +2353,7 @@ chkp_get_next_bounds_parm (tree parm)
static tree
chkp_get_bound_for_parm (tree parm)
{
- tree decl = SSA_NAME_VAR (parm);
+ tree decl = TREE_CODE (parm) == PARM_DECL ? parm : SSA_NAME_VAR (parm);
tree bounds;
gcc_assert (TREE_CODE (decl) == PARM_DECL);
@@ -3602,7 +3602,6 @@ chkp_find_bounds_1 (tree ptr, tree ptr_src, gimple_stmt_iterator *iter)
break;
case PARM_DECL:
- gcc_unreachable ();
bounds = chkp_get_bound_for_parm (ptr_src);
break;
--
2.11.1