diff options
author | Jason Merrill <jason@redhat.com> | 2019-11-06 19:50:19 -0500 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2019-11-06 19:50:19 -0500 |
commit | 74fa38297b22d826f53f0b1894a1847eca3503dc (patch) | |
tree | 80dd4fe6801052da50c979452f37253d83c5496b /gcc/cp/class.c | |
parent | 951c6f3dd975d795adc409da1a1477b5229199ae (diff) | |
download | gcc-74fa38297b22d826f53f0b1894a1847eca3503dc.zip gcc-74fa38297b22d826f53f0b1894a1847eca3503dc.tar.gz gcc-74fa38297b22d826f53f0b1894a1847eca3503dc.tar.bz2 |
Implement D1907R1 "structural type".
ISO C++ paper D1907R1 proposes "structural type" as an alternative to the
current notion of "strong structural equality", which has various problems.
I'm implementing it to give people a chance to try it.
The build_base_field changes are to make it easier for structural_type_p to
see whether a base is private or protected.
* tree.c (structural_type_p): New.
* pt.c (invalid_nontype_parm_type_p): Use it.
* class.c (build_base_field_1): Take binfo. Copy TREE_PRIVATE.
(build_base_field): Pass binfo.
From-SVN: r277902
Diffstat (limited to 'gcc/cp/class.c')
-rw-r--r-- | gcc/cp/class.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/gcc/cp/class.c b/gcc/cp/class.c index 89ed1c04..a9aa5e7 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -4353,15 +4353,18 @@ layout_empty_base_or_field (record_layout_info rli, tree binfo_or_decl, fields at NEXT_FIELD, and return it. */ static tree -build_base_field_1 (tree t, tree basetype, tree *&next_field) +build_base_field_1 (tree t, tree binfo, tree *&next_field) { /* Create the FIELD_DECL. */ + tree basetype = BINFO_TYPE (binfo); gcc_assert (CLASSTYPE_AS_BASE (basetype)); tree decl = build_decl (input_location, FIELD_DECL, NULL_TREE, CLASSTYPE_AS_BASE (basetype)); DECL_ARTIFICIAL (decl) = 1; DECL_IGNORED_P (decl) = 1; DECL_FIELD_CONTEXT (decl) = t; + TREE_PRIVATE (decl) = TREE_PRIVATE (binfo); + TREE_PROTECTED (decl) = TREE_PROTECTED (binfo); if (is_empty_class (basetype)) /* CLASSTYPE_SIZE is one byte, but the field needs to have size zero. */ DECL_SIZE (decl) = DECL_SIZE_UNIT (decl) = size_zero_node; @@ -4414,7 +4417,7 @@ build_base_field (record_layout_info rli, tree binfo, CLASSTYPE_EMPTY_P (t) = 0; /* Create the FIELD_DECL. */ - decl = build_base_field_1 (t, basetype, next_field); + decl = build_base_field_1 (t, binfo, next_field); /* Try to place the field. It may take more than one try if we have a hard time placing the field without putting two @@ -4448,7 +4451,7 @@ build_base_field (record_layout_info rli, tree binfo, aggregate bases. */ if (cxx_dialect >= cxx17 && !BINFO_VIRTUAL_P (binfo)) { - tree decl = build_base_field_1 (t, basetype, next_field); + tree decl = build_base_field_1 (t, binfo, next_field); DECL_FIELD_OFFSET (decl) = BINFO_OFFSET (binfo); DECL_FIELD_BIT_OFFSET (decl) = bitsize_zero_node; SET_DECL_OFFSET_ALIGN (decl, BITS_PER_UNIT); |