diff options
author | Jakub Jelinek <jakub@redhat.com> | 2019-10-29 21:58:47 +0100 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2019-10-29 21:58:47 +0100 |
commit | 6835f8a04a062c3d3276a4a723a9237b1eaf835b (patch) | |
tree | 9e61ca3f7d299b22df9358cdccfbb0e319d9995f /gcc | |
parent | 0f1848002a137f3cac5026c5a3af6e16ceabe552 (diff) | |
download | gcc-6835f8a04a062c3d3276a4a723a9237b1eaf835b.zip gcc-6835f8a04a062c3d3276a4a723a9237b1eaf835b.tar.gz gcc-6835f8a04a062c3d3276a4a723a9237b1eaf835b.tar.bz2 |
re PR c++/92201 (ICE: ‘verify_gimple’ failed with -std=c++2a)
PR c++/92201
* cp-gimplify.c (cp_gimplify_expr): If gimplify_to_rvalue changes the
function pointer type, re-add cast to the original one.
* g++.dg/other/pr92201.C: New test.
From-SVN: r277592
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/cp/cp-gimplify.c | 6 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/other/pr92201.C | 7 |
4 files changed, 24 insertions, 0 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 09d1c18..fda743b 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2019-10-29 Jakub Jelinek <jakub@redhat.com> + + PR c++/92201 + * cp-gimplify.c (cp_gimplify_expr): If gimplify_to_rvalue changes the + function pointer type, re-add cast to the original one. + 2019-10-29 Marek Polacek <polacek@redhat.com> PR c++/91548 - fix detecting modifying const objects for ARRAY_REF. diff --git a/gcc/cp/cp-gimplify.c b/gcc/cp/cp-gimplify.c index 9fc60c9..abd82b3 100644 --- a/gcc/cp/cp-gimplify.c +++ b/gcc/cp/cp-gimplify.c @@ -838,11 +838,17 @@ cp_gimplify_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p) && CALL_EXPR_FN (*expr_p) && cp_get_callee_fndecl_nofold (*expr_p) == NULL_TREE) { + tree fnptrtype = TREE_TYPE (CALL_EXPR_FN (*expr_p)); enum gimplify_status t = gimplify_to_rvalue (&CALL_EXPR_FN (*expr_p), pre_p, NULL, is_gimple_call_addr); if (t == GS_ERROR) ret = GS_ERROR; + /* GIMPLE considers most pointer conversion useless, but for + calls we actually care about the exact function pointer type. */ + else if (TREE_TYPE (CALL_EXPR_FN (*expr_p)) != fnptrtype) + CALL_EXPR_FN (*expr_p) + = build1 (NOP_EXPR, fnptrtype, CALL_EXPR_FN (*expr_p)); } if (!CALL_EXPR_FN (*expr_p)) /* Internal function call. */; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index cffd592..3761a99 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-10-29 Jakub Jelinek <jakub@redhat.com> + + PR c++/92201 + * g++.dg/other/pr92201.C: New test. + 2019-10-29 Marek Polacek <polacek@redhat.com> PR c++/91548 - fix detecting modifying const objects for ARRAY_REF. diff --git a/gcc/testsuite/g++.dg/other/pr92201.C b/gcc/testsuite/g++.dg/other/pr92201.C new file mode 100644 index 0000000..15ba1a1 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/pr92201.C @@ -0,0 +1,7 @@ +// PR c++/92201 + +int +foo (void (*p) ()) +{ + return (*reinterpret_cast<int (*)()> (p)) (); +} |