From ac1409d32a94cc3659138d91fa11743393de612b Mon Sep 17 00:00:00 2001 From: Dodji Seketeli Date: Tue, 19 Nov 2013 11:36:25 +0100 Subject: [PATCH] Support for serialization of member types cp/ChangeLog: * abi-instr.cc (gen_scope_of): Member types are linked to their scope via their DECL_CONTEXT (TYPE_NAME()), not their TYPE_CONTEXT. . Also, do not add empty elements to the scope hash table. (gen_scope_decl): Do not use a scope that is not yet fully built. We should not be using gen_scope_decl while building type or decl members. Rather, we should just be sticking the members into the non-fully-built type/decl that we have at hand. (gen_class_type_in_scope): Handle member types. Also, for member functions, use the new (more generic) version of abigail::add_decl_to_scope. gcc/testsuite/ChangeLog: * g++.dg/abi-dump/bases-0.C.bi: Update this for member type(def). * g++.dg/abi-dump/simple-class-0.C.bi: Likewise. --- gcc/cp/abi-instr.cc | 27 +++++-- gcc/testsuite/g++.dg/abi-dump/bases-0.C.bi | 86 +++++++++++++---------- gcc/testsuite/g++.dg/abi-dump/simple-class-0.C.bi | 7 +- 3 files changed, 77 insertions(+), 43 deletions(-) diff --git a/gcc/cp/abi-instr.cc b/gcc/cp/abi-instr.cc index ac697003e10..fe3b9823913 100644 --- a/gcc/cp/abi-instr.cc +++ b/gcc/cp/abi-instr.cc @@ -270,7 +270,7 @@ gen_scope_of (const_tree t) tree context = NULL_TREE; if (TYPE_P (t)) - context = TYPE_CONTEXT (t); + context = TYPE_NAME (t) ? DECL_CONTEXT (TYPE_NAME (t)) : TYPE_CONTEXT (t); else if (DECL_P (t)) context = DECL_CONTEXT (t); @@ -287,7 +287,8 @@ gen_scope_of (const_tree t) result = gen_scope_decl (context, gen_scope_of (context)); - m[t] = result; + if (result) + m[t] = result; return result; } @@ -607,7 +608,17 @@ gen_scope_decl (const_tree t, add_decl_to_scope (result, scope); } else if (TREE_CODE (t) == RECORD_TYPE) - result = gen_class_type_in_scope (t, scope); + { + abigail::class_decl_sptr cl = gen_class_type_in_scope (t, scope); + if (cl->is_declaration_only()) + // This means that t is part of a class scope that is + // currently being defined. So we cannot yet use that scope + // to e.g add stuff into it. So let's just bail out for the + // moment. + ; + else + result = cl; + } else gcc_unreachable (); @@ -816,6 +827,14 @@ gen_class_type_in_scope (const_tree t, gen_data_member (m); if (member) class_type->add_data_member (member); + else if (TREE_CODE (m) == TYPE_DECL) + { + abigail::type_base_sptr ty = + gen_type_in_scope(TREE_TYPE (m), abigail::scope_decl_sptr ()); + if (ty) + class_type->add_member_type (ty, get_access (TREE_TYPE (m))); + } + // else, handle the other kinds of members here. } for (tree m = TYPE_METHODS (t); m; m = DECL_CHAIN (m)) @@ -825,7 +844,7 @@ gen_class_type_in_scope (const_tree t, shared_ptr member = gen_member_function (m, class_type); if (member) - class_type->add_member_function (member); + add_decl_to_scope(member, class_type); } } diff --git a/gcc/testsuite/g++.dg/abi-dump/bases-0.C.bi b/gcc/testsuite/g++.dg/abi-dump/bases-0.C.bi index c121a989966..25940c0c4e9 100644 --- a/gcc/testsuite/g++.dg/abi-dump/bases-0.C.bi +++ b/gcc/testsuite/g++.dg/abi-dump/bases-0.C.bi @@ -9,6 +9,9 @@ + + + @@ -38,121 +41,130 @@ - - - - - + + + + + + + + - + - + - + - + - - - + - + + + + + + - + - + - + - + - - - - + - + - + + + + - - + + + + + - + - + - + - + - - - - - - - - + + + + + + + + diff --git a/gcc/testsuite/g++.dg/abi-dump/simple-class-0.C.bi b/gcc/testsuite/g++.dg/abi-dump/simple-class-0.C.bi index 9d04b298ddd..77733063ff3 100644 --- a/gcc/testsuite/g++.dg/abi-dump/simple-class-0.C.bi +++ b/gcc/testsuite/g++.dg/abi-dump/simple-class-0.C.bi @@ -6,6 +6,9 @@ + + + @@ -36,9 +39,9 @@ - + - + -- 2.11.4.GIT