Skip to content

Commit 0aef4d0

Browse files
committed
Also consider default access for polymorphic_base and basic_value
Closes #721
1 parent 36ecc07 commit 0aef4d0

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

regression-tests/test-results/version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
cppfront compiler v0.2.1 Build 8A08:1411
2+
cppfront compiler v0.2.1 Build 8A08:1847
33
Copyright(c) Herb Sutter All rights reserved
44

55
SPDX-License-Identifier: CC-BY-NC-ND-4.0

source/reflect.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1216,7 +1216,7 @@ auto polymorphic_base(meta::type_declaration& t) -> void
12161216
"polymorphic base types may not copy or move; consider a virtual clone() instead");
12171217
if (CPP2_UFCS_0(is_destructor, mf)) {
12181218
has_dtor = true;
1219-
CPP2_UFCS(require, mf, (CPP2_UFCS_0(is_public, mf) && CPP2_UFCS_0(is_virtual, mf))
1219+
CPP2_UFCS(require, mf, ((CPP2_UFCS_0(is_public, mf) || CPP2_UFCS_0(is_default_access, mf)) && CPP2_UFCS_0(is_virtual, mf))
12201220
|| (CPP2_UFCS_0(is_protected, mf) && !(CPP2_UFCS_0(is_virtual, mf))),
12211221
"a polymorphic base type destructor must be public and virtual, or protected and nonvirtual");
12221222
}
@@ -1302,7 +1302,7 @@ auto basic_value(meta::type_declaration& t) -> void
13021302
has_default_ctor |= CPP2_UFCS_0(is_default_constructor, mf);
13031303
CPP2_UFCS(require, mf, !(CPP2_UFCS_0(is_protected, mf)) && !(CPP2_UFCS_0(is_virtual, mf)),
13041304
"a value type may not have a protected or virtual function");
1305-
CPP2_UFCS(require, mf, !(CPP2_UFCS_0(is_destructor, mf)) || CPP2_UFCS_0(is_public, mf),
1305+
CPP2_UFCS(require, mf, !(CPP2_UFCS_0(is_destructor, mf)) || CPP2_UFCS_0(is_public, mf) || CPP2_UFCS_0(is_default_access, mf),
13061306
"a value type may not have a non-public destructor");
13071307
}
13081308

source/reflect.h2

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -604,7 +604,7 @@ polymorphic_base: (inout t: meta::type_declaration) =
604604
"polymorphic base types may not copy or move; consider a virtual clone() instead");
605605
if mf.is_destructor() {
606606
has_dtor = true;
607-
mf.require( (mf.is_public() && mf.is_virtual())
607+
mf.require( ((mf.is_public() || mf.is_default_access()) && mf.is_virtual())
608608
|| (mf.is_protected() && !mf.is_virtual()),
609609
"a polymorphic base type destructor must be public and virtual, or protected and nonvirtual");
610610
}
@@ -740,7 +740,7 @@ basic_value: (inout t: meta::type_declaration) =
740740
has_default_ctor |= mf.is_default_constructor();
741741
mf.require( !mf.is_protected() && !mf.is_virtual(),
742742
"a value type may not have a protected or virtual function");
743-
mf.require( !mf.is_destructor() || mf.is_public(),
743+
mf.require( !mf.is_destructor() || mf.is_public() || mf.is_default_access(),
744744
"a value type may not have a non-public destructor");
745745
}
746746

0 commit comments

Comments
 (0)