From 9ba2c8234c88a96ee386712d26356df4116fba17 Mon Sep 17 00:00:00 2001 From: David Malcolm Date: Tue, 14 Apr 2020 13:27:16 -0400 Subject: [PATCH 033/179] FIXME: WIP on C++ fix --- gcc/analyzer/region-model2.cc | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/gcc/analyzer/region-model2.cc b/gcc/analyzer/region-model2.cc index a4fd6a75b39..b08e3d679f2 100644 --- a/gcc/analyzer/region-model2.cc +++ b/gcc/analyzer/region-model2.cc @@ -6779,7 +6779,6 @@ make_test_compound_type (const char *name, bool is_struct, const auto_vec *fields) { tree t = make_node (is_struct ? RECORD_TYPE : UNION_TYPE); - TYPE_NAME (t) = get_identifier (name); TYPE_SIZE (t) = 0; tree fieldlist = NULL; @@ -6795,14 +6794,30 @@ make_test_compound_type (const char *name, bool is_struct, TYPE_FIELDS (t) = fieldlist; layout_type (t); + +#if 1 + TYPE_NAME (t) = get_identifier (name); +#else + tree id = get_identifier (name); + tree implicit_decl = build_decl (UNKNOWN_LOCATION, TYPE_DECL, id, t); + DECL_ARTIFICIAL (implicit_decl) = 1; + //SET_DECL_IMPLICIT_TYPEDEF_P (implicit_decl); + TYPE_NAME (t) = implicit_decl; + TYPE_STUB_DECL (t) = implicit_decl; + + /* FIXME: ^^^ this needs to be a decl, or selftest-c++ crashes + printing types, treating the TYPE_NAME as a decl. + C++ FE uses create_implicit_typedef and makes a TYPE_DECL. */ +#endif + return t; } /* Selftest fixture for creating the type "struct coord {int x; int y; };". */ -struct coord_test +struct coord_test2 { - coord_test () + coord_test2 () { auto_vec fields; m_x_field = build_decl (UNKNOWN_LOCATION, FIELD_DECL, @@ -6824,7 +6839,7 @@ struct coord_test static void test_dump_2 () { - coord_test ct; + coord_test2 ct; tree c = build_global_decl ("c", ct.m_coord_type); tree c_x = build3 (COMPONENT_REF, TREE_TYPE (ct.m_x_field), @@ -6845,6 +6860,7 @@ test_dump_2 () and a more sophisticated region binding/cluster implementation. */ /* Simplified dump. */ +#if 0 ASSERT_DUMP_EQ (model, true, "base region: {c} has cluster: {" "binding key: {region: c.x, kind: direct, offset: 0}," @@ -6852,11 +6868,14 @@ test_dump_2 () " binding key: {region: c.y, kind: direct, offset: 0}," " value: {-3}" "}"); +#endif /* Full dump. */ +#if 0 ASSERT_DUMP_EQ (model, false, "base region: {decl_region2(globals, `struct coord', `c')} has cluster: {binding key: {region: field_region2(decl_region2(globals, `struct coord', `c'), `int', `x'), kind: direct, offset: 0}, value: {constant_svalue2(`int', 17)}, binding key: {region: field_region2(decl_region2(globals, `struct coord', `c'), `int', `y'), kind: direct, offset: 0}, value: {constant_svalue2(`int', -3)}}"); +#endif } #if 0 -- 2.21.0