From: Jakub Jelinek Date: Tue, 29 Oct 2019 21:09:21 +0000 (+0100) Subject: re PR c++/92201 (ICE: ‘verify_gimple’ failed with -std=c++2a) X-Git-Tag: releases/gcc-9.3.0~454 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9149decc3e9778aefe287f3b64e085989d60e98b;p=thirdparty%2Fgcc.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: r277594 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index e0224a0c421f..86007bde317f 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. + 2018-10-26 Ville Voutilainen Backport from mainline diff --git a/gcc/cp/cp-gimplify.c b/gcc/cp/cp-gimplify.c index c3e37648c60c..a7121b70a3b3 100644 --- a/gcc/cp/cp-gimplify.c +++ b/gcc/cp/cp-gimplify.c @@ -820,6 +820,7 @@ 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_expr (&CALL_EXPR_FN (*expr_p), pre_p, NULL, is_gimple_call_addr, fb_rvalue); @@ -830,6 +831,11 @@ cp_gimplify_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p) CALL_EXPR_FN (*expr_p) = get_initialized_tmp_var (CALL_EXPR_FN (*expr_p), pre_p, NULL); + /* GIMPLE considers most pointer conversion useless, but for + calls we actually care about the exact function pointer type. */ + if (t != GS_ERROR && 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 c6b50a7bd9e0..cf84d9b77b73 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,10 +1,15 @@ +2019-10-29 Jakub Jelinek + + PR c++/92201 + * g++.dg/other/pr92201.C: New test. + 2019-10-28  Paul Thomas   Backport from trunk PR fortran/91926 - * gfortran.dg/ISO_Fortran_binding_13.f90 : New test. - * gfortran.dg/ISO_Fortran_binding_13.c : Additional source. - * gfortran.dg/ISO_Fortran_binding_14.f90 : New test. + * gfortran.dg/ISO_Fortran_binding_13.f90: New test. + * gfortran.dg/ISO_Fortran_binding_13.c: Additional source. + * gfortran.dg/ISO_Fortran_binding_14.f90: New test. 2019-10-28 Jiufu Guo @@ -47,8 +52,8 @@ Backport from mainline PR fortran/86248 - * gfortran.dg/char_result_19.f90 : New test. - * gfortran.dg/char_result_mod_19.f90 : Module for the new test. + * gfortran.dg/char_result_19.f90: New test. + * gfortran.dg/char_result_mod_19.f90: Module for the new test. 2019-10-25 Richard Earnshaw @@ -339,7 +344,7 @@ Backport from mainline PR fortran/91588 - * gfortran.dg/associate_49.f90 : New test. + * gfortran.dg/associate_49.f90: New test. 2019-09-20 Eric Botcazou @@ -404,7 +409,7 @@ Backport from mainline PR fortran/91589 - * gfortran.dg/pr91589.f90 : New test. + * gfortran.dg/pr91589.f90: New test. 2019-09-05 Harald Anlauf @@ -1354,7 +1359,7 @@ Backport from mainline PR fortran/91077 - * gfortran.dg/pointer_array_11.f90 : New test. + * gfortran.dg/pointer_array_11.f90: New test. 2019-07-05 Szabolcs Nagy @@ -1603,7 +1608,7 @@ * gcc.target/i386/pr82699-6.c: Likewise * gcc.target/i386/returninst1.c: Likewise * gcc.target/i386/returninst2.c: Likewise - * gcc.target/i386/returninst3.c : Likewise + * gcc.target/i386/returninst3.c: Likewise 2019-05-30 Iain Sandoe @@ -1765,7 +1770,7 @@ Backport from trunk PR fortran/90498 - * gfortran.dg/associate_48.f90 : New test. + * gfortran.dg/associate_48.f90: New test. 2019-05-17 Jakub Jelinek @@ -4435,21 +4440,21 @@ 2019-02-23 Paul Thomas PR fortran/88117 - * gfortran.dg/deferred_character_32.f90 : New test + * gfortran.dg/deferred_character_32.f90: New test 2019-02-23 Paul Thomas PR fortran/89385 - * gfortran.dg/ISO_Fortran_binding_1.f90 : Correct test for + * gfortran.dg/ISO_Fortran_binding_1.f90: Correct test for previously incorrect lbound for allocatable expressions. Also correct stop values to avoid repetition. - * gfortran.dg/ISO_Fortran_binding_5.f90 : New test - * gfortran.dg/ISO_Fortran_binding_5.c : Support previous test. + * gfortran.dg/ISO_Fortran_binding_5.f90: New test + * gfortran.dg/ISO_Fortran_binding_5.c: Support previous test. PR fortran/89366 - * gfortran.dg/ISO_Fortran_binding_6.f90 : New test - * gfortran.dg/ISO_Fortran_binding_6.c : Support previous test. - * gfortran.dg/pr32599.f03 : Set standard to F2008. + * gfortran.dg/ISO_Fortran_binding_6.f90: New test + * gfortran.dg/ISO_Fortran_binding_6.c: Support previous test. + * gfortran.dg/pr32599.f03: Set standard to F2008. 2019-02-22 David Malcolm @@ -5078,7 +5083,7 @@ 2019-02-09 Paul Thomas PR fortran/89200 - * gfortran.dg/array_reference_2.f90 : New test. + * gfortran.dg/array_reference_2.f90: New test. 2019-02-09 Jakub Jelinek @@ -5338,17 +5343,17 @@ 2019-02-02 Paul Thomas PR fortran/88393 - * gfortran.dg/alloc_comp_assign_16.f03 : New test. + * gfortran.dg/alloc_comp_assign_16.f03: New test. 2019-02-02 Paul Thomas PR fortran/88980 - * gfortran.dg/realloc_on_assign_32.f90 : New test. + * gfortran.dg/realloc_on_assign_32.f90: New test. 2019-02-02 Paul Thomas PR fortran/88685 - * gfortran.dg/pointer_array_component_3.f90 : New test. + * gfortran.dg/pointer_array_component_3.f90: New test. 2019-02-02 Jakub Jelinek diff --git a/gcc/testsuite/g++.dg/other/pr92201.C b/gcc/testsuite/g++.dg/other/pr92201.C new file mode 100644 index 000000000000..15ba1a12525d --- /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)) (); +}