From 83ed54d7ed0a7f02089ce408e0f0acb30e77d4a9 Mon Sep 17 00:00:00 2001 From: Eric Botcazou Date: Sun, 1 Mar 2015 18:27:48 +0000 Subject: [PATCH] c-ada-spec.c (is_tagged_type): Add guard for DECL_VINDEX. * c-ada-spec.c (is_tagged_type): Add guard for DECL_VINDEX. (dump_template_types): Adjust DECL_TEMPLATE_INSTANTIATIONS and DECL_TEMPLATE_RESULT emulations. (dump_ada_template)): Add guard for TYPE_METHODS. From-SVN: r221088 --- gcc/c-family/ChangeLog | 7 +++++ gcc/c-family/c-ada-spec.c | 17 +++++++----- gcc/testsuite/ChangeLog | 4 +++ gcc/testsuite/g++.dg/other/dump-ada-spec-3.C | 27 ++++++++++++++++++++ 4 files changed, 49 insertions(+), 6 deletions(-) create mode 100644 gcc/testsuite/g++.dg/other/dump-ada-spec-3.C diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index 7b638665c54..e1d4eff7bdc 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,10 @@ +2015-03-01 Eric Botcazou + + * c-ada-spec.c (is_tagged_type): Add guard for DECL_VINDEX. + (dump_template_types): Adjust DECL_TEMPLATE_INSTANTIATIONS and + DECL_TEMPLATE_RESULT emulations. + (dump_ada_template)): Add guard for TYPE_METHODS. + 2015-02-27 Marek Polacek PR c/65040 diff --git a/gcc/c-family/c-ada-spec.c b/gcc/c-family/c-ada-spec.c index 945fa7cdb34..fcfefb03f79 100644 --- a/gcc/c-family/c-ada-spec.c +++ b/gcc/c-family/c-ada-spec.c @@ -961,7 +961,7 @@ is_tagged_type (const_tree type) return false; for (tmp = TYPE_METHODS (type); tmp; tmp = TREE_CHAIN (tmp)) - if (DECL_VINDEX (tmp)) + if (TREE_CODE (tmp) == FUNCTION_DECL && DECL_VINDEX (tmp)) return true; return false; @@ -1730,10 +1730,15 @@ dump_template_types (pretty_printer *buffer, tree types, int spc) static int dump_ada_template (pretty_printer *buffer, tree t, int spc) { - /* DECL_VINDEX is DECL_TEMPLATE_INSTANTIATIONS in this context. */ - tree inst = DECL_VINDEX (t); - /* DECL_RESULT_FLD is DECL_TEMPLATE_RESULT in this context. */ - tree result = DECL_RESULT_FLD (t); + /* DECL_SIZE_UNIT is DECL_TEMPLATE_INSTANTIATIONS in this context. */ + tree inst = DECL_SIZE_UNIT (t); + /* This emulates DECL_TEMPLATE_RESULT in this context. */ + struct tree_template_decl { + struct tree_decl_common common; + tree arguments; + tree result; + }; + tree result = ((struct tree_template_decl *) t)->result; int num_inst = 0; /* Don't look at template declarations declaring something coming from @@ -1750,7 +1755,7 @@ dump_ada_template (pretty_printer *buffer, tree t, int spc) if (TREE_VEC_LENGTH (types) == 0) break; - if (!TYPE_P (instance) || !TYPE_METHODS (instance)) + if (!RECORD_OR_UNION_TYPE_P (instance) || !TYPE_METHODS (instance)) break; num_inst++; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 0ec2c0cb9b8..33d69b01adf 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2015-03-01 Eric Botcazou + + * g++.dg/other/dump-ada-spec-3.C: New test. + 2015-03-01 Martin Liska * gcc.target/i386/stackalign/longlong-2.c: Omit ICF. diff --git a/gcc/testsuite/g++.dg/other/dump-ada-spec-3.C b/gcc/testsuite/g++.dg/other/dump-ada-spec-3.C new file mode 100644 index 00000000000..3d5e3f10dfc --- /dev/null +++ b/gcc/testsuite/g++.dg/other/dump-ada-spec-3.C @@ -0,0 +1,27 @@ +/* { dg-do compile } */ +/* { dg-options "-fdump-ada-spec" } */ + +#include + +using namespace std; + +class Base { + public: + int My_V; + virtual void Primitive (); + + Base (); +}; + +void Base::Primitive () { + cout << "C++ Primitive " << this->My_V << "\n"; +} + +Base::Base () { +} + +void Dispatch (Base * B) { + B->Primitive (); +} + +/* { dg-final { cleanup-ada-spec } } */ -- 2.30.2