From f6b455583f8d99f71d006467bb9bd66967e136d9 Mon Sep 17 00:00:00 2001 From: marxin Date: Thu, 9 Mar 2017 09:22:29 +0000 Subject: [PATCH 08/19] Backport r245993 gcc/ChangeLog: 2017-03-09 Martin Liska 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-09 Martin Liska PR ipa/79761 * g++.dg/pr79761.C: New test. --- gcc/testsuite/g++.dg/pr79761.C | 34 ++++++++++++++++++++++++++++++++++ gcc/tree-chkp.c | 4 ++-- 2 files changed, 36 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 4ca2d34607c..1d1013d01b6 100644 --- a/gcc/tree-chkp.c +++ b/gcc/tree-chkp.c @@ -3599,8 +3599,8 @@ 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); + /* Handled above but failed. */ + bounds = chkp_get_invalid_op_bounds (); break; case TARGET_MEM_REF: -- 2.12.0