From: Jakub Jelinek Date: Tue, 29 Oct 2019 20:58:47 +0000 (+0100) Subject: re PR c++/92201 (ICE: ‘verify_gimple’ failed with -std=c++2a) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=6835f8a04a062c3d3276a4a723a9237b1eaf835b;p=gcc.git 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 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 09d1c18e808..fda743b6872 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2019-10-29 Jakub Jelinek + + 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 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 9fc60c964e0..abd82b3fe42 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 cffd5921772..3761a99bab1 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-10-29 Jakub Jelinek + + PR c++/92201 + * g++.dg/other/pr92201.C: New test. + 2019-10-29 Marek Polacek 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 00000000000..15ba1a12525 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/pr92201.C @@ -0,0 +1,7 @@ +// PR c++/92201 + +int +foo (void (*p) ()) +{ + return (*reinterpret_cast (p)) (); +}