]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/92201 (ICE: ‘verify_gimple’ failed with -std=c++2a)
authorJakub Jelinek <jakub@gcc.gnu.org>
Tue, 29 Oct 2019 21:09:21 +0000 (22:09 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Tue, 29 Oct 2019 21:09:21 +0000 (22:09 +0100)
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

gcc/cp/ChangeLog
gcc/cp/cp-gimplify.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/other/pr92201.C [new file with mode: 0644]

index e0224a0c421f4a8085cc762a35f0557dc5fe0398..86007bde317f019f76f7188b411068aa38e0be47 100644 (file)
@@ -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.
+
 2018-10-26  Ville Voutilainen  <ville.voutilainen@gmail.com>
 
        Backport from mainline
index c3e37648c60c3c0bee8a4954927608ea2365230e..a7121b70a3b3b65b8aef12735487c447bf86ae18 100644 (file)
@@ -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.  */;
index c6b50a7bd9e09ff92d6fcd2508916a23f9d5b535..cf84d9b77b732500ed07cea09781cce44ad8162b 100644 (file)
@@ -1,10 +1,15 @@
+2019-10-29  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/92201
+       * g++.dg/other/pr92201.C: New test.
+
 2019-10-28  Paul Thomas  <pault@gcc.gnu.org>
 
        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  <guojiufu@linux.ibm.com>
 
@@ -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  <rearnsha@arm.com>
 
 
        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  <ebotcazou@adacore.com>
 
 
        Backport from mainline
        PR fortran/91589
-       * gfortran.dg/pr91589.f90 : New test.
+       * gfortran.dg/pr91589.f90: New test.
 
 2019-09-05  Harald Anlauf  <anlauf@gmx.de>
 
 
        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  <szabolcs.nagy@arm.com>
 
        * 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  <iain@sandoe.co.uk>
 
 
        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  <jakub@redhat.com>
 
 2019-02-23  Paul Thomas  <pault@gcc.gnu.org>
 
        PR fortran/88117
-       * gfortran.dg/deferred_character_32.f90 : New test
+       * gfortran.dg/deferred_character_32.f90: New test
 
 2019-02-23  Paul Thomas  <pault@gcc.gnu.org>
 
        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  <dmalcolm@redhat.com>
 
 2019-02-09  Paul Thomas  <pault@gcc.gnu.org>
 
        PR fortran/89200
-       * gfortran.dg/array_reference_2.f90 : New test.
+       * gfortran.dg/array_reference_2.f90: New test.
 
 2019-02-09  Jakub Jelinek  <jakub@redhat.com>
 
 2019-02-02  Paul Thomas  <pault@gcc.gnu.org>
 
        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  <pault@gcc.gnu.org>
 
        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  <pault@gcc.gnu.org>
 
        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  <jakub@redhat.com>
 
diff --git a/gcc/testsuite/g++.dg/other/pr92201.C b/gcc/testsuite/g++.dg/other/pr92201.C
new file mode 100644 (file)
index 0000000..15ba1a1
--- /dev/null
@@ -0,0 +1,7 @@
+// PR c++/92201
+
+int
+foo (void (*p) ())
+{
+  return (*reinterpret_cast<int (*)()> (p)) ();
+}