diff options
author | Ilya Enkovich <ilya.enkovich@intel.com> | 2016-05-10 16:06:36 +0000 |
---|---|---|
committer | Ilya Enkovich <ienkovich@gcc.gnu.org> | 2016-05-10 16:06:36 +0000 |
commit | 1e3af2a4e0f65adf5cfb2d4faf48eeab94eff280 (patch) | |
tree | 1af996345d268d77408e804d789ecc0c6a911be8 | |
parent | cd36c83e9bb1c8cf66082da63234925482695ef1 (diff) | |
download | gcc-1e3af2a4e0f65adf5cfb2d4faf48eeab94eff280.zip gcc-1e3af2a4e0f65adf5cfb2d4faf48eeab94eff280.tar.gz gcc-1e3af2a4e0f65adf5cfb2d4faf48eeab94eff280.tar.bz2 |
re PR middle-end/70877 ([MPX] ICE in in convert_move)
gcc/
PR middle-end/70877
* tree-chkp.c (chkp_add_bounds_to_call_stmt): Handle
calls with type casted fndecl.
gcc/testsuite/
PR middle-end/70877
* gcc.target/i386/pr70877.c: New test.
From-SVN: r236088
-rw-r--r-- | gcc/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/gcc.target/i386/pr70877.c | 14 | ||||
-rw-r--r-- | gcc/tree-chkp.c | 15 |
4 files changed, 38 insertions, 2 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 941748c..562d303 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -5,6 +5,12 @@ 2016-05-10 Ilya Enkovich <ilya.enkovich@intel.com> + PR middle-end/70877 + * tree-chkp.c (chkp_add_bounds_to_call_stmt): Handle + calls with type casted fndecl. + +2016-05-10 Ilya Enkovich <ilya.enkovich@intel.com> + PR tree-optimization/70786 * tree-chkp.c (chkp_find_bounds_1): Support WITH_SIZE_EXPR. * gcc/calls.c (initialize_argument_information): Bind bounds diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 1e42f38..36b8e2f 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -4,6 +4,11 @@ 2016-05-10 Ilya Enkovich <ilya.enkovich@intel.com> + PR middle-end/70877 + * gcc.target/i386/pr70877.c: New test. + +2016-05-10 Ilya Enkovich <ilya.enkovich@intel.com> + PR tree-optimization/70786 * gcc.target/i386/pr70876.c: New test. diff --git a/gcc/testsuite/gcc.target/i386/pr70877.c b/gcc/testsuite/gcc.target/i386/pr70877.c new file mode 100644 index 0000000..4269e84 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr70877.c @@ -0,0 +1,14 @@ +/* { dg-do compile { target { ! x32 } } } */ +/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ + +int foo(int); + +typedef struct { + double d; + int a; +} str_t; + +void bar(double d, int i, str_t s) +{ + d = ((double (*) (int)) foo) (i); /* { dg-warning "function called through a non-compatible type" } */ +} diff --git a/gcc/tree-chkp.c b/gcc/tree-chkp.c index 8c7d214..4ca2d34 100644 --- a/gcc/tree-chkp.c +++ b/gcc/tree-chkp.c @@ -1853,7 +1853,9 @@ chkp_add_bounds_to_call_stmt (gimple_stmt_iterator *gsi) /* If function decl is available then use it for formal arguments list. Otherwise use function type. */ - if (fndecl && DECL_ARGUMENTS (fndecl)) + if (fndecl + && DECL_ARGUMENTS (fndecl) + && gimple_call_fntype (call) == TREE_TYPE (fndecl)) first_formal_arg = DECL_ARGUMENTS (fndecl); else { @@ -1929,7 +1931,16 @@ chkp_add_bounds_to_call_stmt (gimple_stmt_iterator *gsi) { tree new_decl = chkp_maybe_create_clone (fndecl)->decl; gimple_call_set_fndecl (new_call, new_decl); - gimple_call_set_fntype (new_call, TREE_TYPE (new_decl)); + /* In case of a type cast we should modify used function + type instead of using type of new fndecl. */ + if (gimple_call_fntype (call) != TREE_TYPE (fndecl)) + { + tree type = gimple_call_fntype (call); + type = chkp_copy_function_type_adding_bounds (type); + gimple_call_set_fntype (new_call, type); + } + else + gimple_call_set_fntype (new_call, TREE_TYPE (new_decl)); } /* For indirect call we should fix function pointer type if pass some bounds. */ |