From 6ba856d450119e438b62d944e646e929f16da4c6 Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Fri, 9 Jun 2017 09:35:05 +0000 Subject: [PATCH] re PR ipa/81007 (ICE with virtual function in broken class) 2017-06-09 Richard Biener PR middle-end/81007 * ipa-polymorphic-call.c (ipa_polymorphic_call_context::restrict_to_inner_class): Skip FIELD_DECLs with error_mark_node type. * passes.def (all_lowering_passes): Run pass_build_cgraph_edges last again. * g++.dg/pr81007.C: New testcase. From-SVN: r249051 --- gcc/ChangeLog | 9 +++++++++ gcc/ipa-polymorphic-call.c | 3 ++- gcc/passes.def | 2 +- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/pr81007.C | 15 +++++++++++++++ 5 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/g++.dg/pr81007.C diff --git a/gcc/ChangeLog b/gcc/ChangeLog index d61dc3e6ef7..39902009ade 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,12 @@ +2017-06-09 Richard Biener + + PR middle-end/81007 + * ipa-polymorphic-call.c + (ipa_polymorphic_call_context::restrict_to_inner_class): + Skip FIELD_DECLs with error_mark_node type. + * passes.def (all_lowering_passes): Run pass_build_cgraph_edges + last again. + 2017-06-09 Martin Liska * predict.c (struct branch_predictor): New struct. diff --git a/gcc/ipa-polymorphic-call.c b/gcc/ipa-polymorphic-call.c index abbcfbf5ada..6b9f82138dc 100644 --- a/gcc/ipa-polymorphic-call.c +++ b/gcc/ipa-polymorphic-call.c @@ -267,7 +267,8 @@ ipa_polymorphic_call_context::restrict_to_inner_class (tree otr_type, { for (fld = TYPE_FIELDS (type); fld; fld = DECL_CHAIN (fld)) { - if (TREE_CODE (fld) != FIELD_DECL) + if (TREE_CODE (fld) != FIELD_DECL + || TREE_TYPE (fld) == error_mark_node) continue; pos = int_bit_position (fld); diff --git a/gcc/passes.def b/gcc/passes.def index beb350be3a6..25e9d974bc8 100644 --- a/gcc/passes.def +++ b/gcc/passes.def @@ -42,9 +42,9 @@ along with GCC; see the file COPYING3. If not see NEXT_PASS (pass_build_cfg); NEXT_PASS (pass_warn_function_return); NEXT_PASS (pass_expand_omp); - NEXT_PASS (pass_build_cgraph_edges); NEXT_PASS (pass_sprintf_length, false); NEXT_PASS (pass_walloca, /*strict_mode_p=*/true); + NEXT_PASS (pass_build_cgraph_edges); TERMINATE_PASS_LIST (all_lowering_passes) /* Interprocedural optimization passes. */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 4c577de2fdd..c661a145128 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2017-06-09 Richard Biener + + PR middle-end/81007 + * g++.dg/pr81007.C: New testcase. + 2017-06-09 Jakub Jelinek * gcc.target/i386/mpx/hard-reg-1-nov.c (mpx_test): Use "esp" diff --git a/gcc/testsuite/g++.dg/pr81007.C b/gcc/testsuite/g++.dg/pr81007.C new file mode 100644 index 00000000000..87d7d40b913 --- /dev/null +++ b/gcc/testsuite/g++.dg/pr81007.C @@ -0,0 +1,15 @@ +// { dg-do compile } +// { dg-options "-O2" } + +struct A +{ + A p; // { dg-error "incomplete" } + virtual void foo(); +}; + +struct B : A {}; + +void bar(B& b) +{ + b.foo(); +} -- 2.30.2