From: Martin Jambor Date: Tue, 31 Oct 2017 21:36:51 +0000 (+0100) Subject: [PR 81702] Remove devirtualization assert X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=0a9088ee137d861c70898598d1bb79408f61689e;p=gcc.git [PR 81702] Remove devirtualization assert 2017-10-31 Martin Jambor PR c++/81702 * gimple-fold.c (gimple_get_virt_method_for_vtable): Remove assert. testsuite/ * g++.dg/tree-ssa/pr81702.C: New test. From-SVN: r254283 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 4987693efe3..689b5ab3711 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2017-10-31 Martin Jambor + + PR c++/81702 + * gimple-fold.c (gimple_get_virt_method_for_vtable): Remove assert. + 2017-10-31 David Malcolm * auto-profile.c (autofdo_source_profile::read): Use diff --git a/gcc/gimple-fold.c b/gcc/gimple-fold.c index cb33c1e09fe..85fd3971946 100644 --- a/gcc/gimple-fold.c +++ b/gcc/gimple-fold.c @@ -6586,7 +6586,6 @@ gimple_get_virt_method_for_vtable (HOST_WIDE_INT token, gcc_assert (init); if (init == error_mark_node) { - gcc_assert (in_lto_p); /* Pass down that we lost track of the target. */ if (can_refer) *can_refer = false; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 1af4fd2da43..82fd2aa7495 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2017-10-31 Martin Jambor + + PR c++/81702 + * g++.dg/tree-ssa/pr81702.C: New test. + 2017-10-31 David Malcolm * jit.dg/jit.exp (jit-dg-test): If PRESERVE_EXECUTABLES is set in diff --git a/gcc/testsuite/g++.dg/tree-ssa/pr81702.C b/gcc/testsuite/g++.dg/tree-ssa/pr81702.C new file mode 100644 index 00000000000..85acd857e67 --- /dev/null +++ b/gcc/testsuite/g++.dg/tree-ssa/pr81702.C @@ -0,0 +1,110 @@ +// { dg-do compile } +// { dg-options "-O2" } + +namespace std { + struct type_info + { + virtual bool __do_catch(const type_info *__thr_type, void **__thr_obj, + unsigned __outer) const; + }; +} + +template< typename VALUE_T, typename TYPE > +struct List_policy +{ + typedef VALUE_T *Value_type; + typedef TYPE **Type; + typedef TYPE *Head_type; + typedef TYPE Item_type; +}; + +template< typename POLICY > +class List +{ +public: + typedef typename POLICY::Value_type Value_type; + class Iterator + { + typedef typename POLICY::Type Internal_type; + public: + typedef typename POLICY::Value_type value_type; + typedef typename POLICY::Value_type Value_type; + Value_type operator -> () const { return static_cast(*_c); } + Internal_type _c; + }; + Iterator begin() { return Iterator(); } + Iterator end() { return Iterator(); } + typename POLICY::Head_type _f; +}; + +template class H_list_item_t { }; + +template< typename T, typename POLICY > +class H_list : public List +{ +public: + typedef typename POLICY::Item_type Item; + typedef List Base; + typedef typename Base::Iterator Iterator; + Iterator insert(T *e, Iterator const &pred) + { + Item **x = &this->_f; + *x = static_cast(e); + return Iterator(); + } +}; + +template< typename T > +struct H_list_t : H_list > > +{ + H_list_t(bool b) : H_list > >(b) {} +}; + +template< typename BASE, typename MATCH_RESULT > +struct Type_matcher : H_list_item_t +{ + explicit Type_matcher(std::type_info const *type); + typedef MATCH_RESULT Match_result; + +private: + std::type_info *_type; + typedef H_list_t List; + typedef typename List::Iterator Iterator; + static List _for_type; +}; + +template< typename BASE, typename MR > +Type_matcher::Type_matcher(std::type_info const *t) +{ + Iterator c = _for_type.begin(); + t->__do_catch(c->_type, 0, 0); + _for_type.insert(static_cast(this), _for_type.begin()); +} + +template< typename VI, typename HW > +class Fa : public Type_matcher, VI*> +{ +public: + typedef Fa Self; + virtual VI *do_match(HW *f) = 0; + explicit Fa(std::type_info const *type) : Type_matcher(type) {} +}; + +class Res {}; +typedef Fa R_fac; + +template< typename VI, typename HW_BASE, typename HW, typename BASE > +class Fa_t : public BASE +{ +public: + Fa_t() : BASE(&typeid(HW)) {} + VI *do_match(HW_BASE *) { return 0; } +}; + +template< typename VI, typename HW > +class Resource_factory_t : public Fa_t {}; + +class Foo {}; +class Foo2; +class Foo3 : public Res {}; +Resource_factory_t _x;