On 03/07/2017 11:16 AM, Rainer Orth wrote: > marxin <mli...@suse.cz> writes: > >> 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" } */ > > This isn't right: the test must be restricted to x86 targets like > g++.dg/pr71633.C. > > Rainer >
Thanks. I'm sending v2 of the patch. Martin
>From e42fa451780336b06bd8fb63ab352a9cb72323ee Mon Sep 17 00:00:00 2001 From: marxin <mli...@suse.cz> Date: Thu, 2 Mar 2017 18:06:39 +0100 Subject: [PATCH 2/5] Get bounds for a PARM_DECL (PR ipa/79761). gcc/ChangeLog: 2017-03-06 Martin Liska <mli...@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 <mli...@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..a97325a1fc4 --- /dev/null +++ b/gcc/testsuite/g++.dg/pr79761.C @@ -0,0 +1,34 @@ +/* { dg-do compile { target { { i?86-*-* x86_64-*-* } && { ! 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