Skip to content

Commit 59fc520

Browse files
committed
A little more self-hosting: meta::object_declaration to Cpp2
And fix a bug this exposed - generated `operator=` memberwise emitted wrong syntax for a base type... previous test cases did not have copyable base types, but `cpp2::meta` embraces copyable base types as a design choice which is find because they aren't polymorphic in the usual inheritance sense
1 parent a2a6f04 commit 59fc520

File tree

4 files changed

+164
-71
lines changed

4 files changed

+164
-71
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 8507:0751
2+
cppfront compiler v0.2.1 Build 8507:1428
33
Copyright(c) Herb Sutter All rights reserved
44

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

source/cppfront.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4497,17 +4497,24 @@ class cppfront
44974497

44984498
// Otherwise, use a default... for a non-copy/move that's the member initializer
44994499
// (for which we don't need to emit anything special because it will get used),
4500-
// and for a copy/move function we default to "= that.same_member"
4500+
// and for a copy/move function we default to "= that.same_member" (or, if this
4501+
// is a base type, just "= that")
45014502
if (!found_explicit_init)
45024503
{
45034504
if (emitting_move_that_function)
45044505
{
4505-
initializer = "std::move(that)." + object_name;
4506+
initializer = "std::move(that)";
4507+
if (!(*object)->has_name("this")) {
4508+
initializer += "." + object_name;
4509+
}
45064510
found_default_init = true;
45074511
}
45084512
else if (emitting_that_function)
45094513
{
4510-
initializer = "that." + object_name;
4514+
initializer = "that";
4515+
if (!(*object)->has_name("this")) {
4516+
initializer += "." + object_name;
4517+
}
45114518
found_default_init = true;
45124519
}
45134520
else if ((*object)->initializer)

0 commit comments

Comments
 (0)