Skip to content

Commit d88f72a

Browse files
committed
Make deferred initialization of std::array work correctly, closes #564
Also fixed a build break that slipped in a couple of hours ago for GCC and Clang (from inadvertently using an incomplete type, which MSVC didn't diagnose and I hadn't re-run the GCC and Clang builds)
1 parent 9ca2f45 commit d88f72a

11 files changed

+24
-36
lines changed

include/cpp2util.h

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -566,8 +566,7 @@ class deferred_init {
566566
~deferred_init() noexcept { destroy(); }
567567
auto value() noexcept -> T& { Default.expects(init); return t(); }
568568

569-
auto construct (auto&& ...args) -> void { Default.expects(!init); new (&data) T(CPP2_FORWARD(args)...); init = true; }
570-
auto construct_list(auto&& ...args) -> void { Default.expects(!init); new (&data) T{CPP2_FORWARD(args)...}; init = true; }
569+
auto construct(auto&& ...args) -> void { Default.expects(!init); new (&data) T{CPP2_FORWARD(args)...}; init = true; }
571570
};
572571

573572

@@ -636,33 +635,6 @@ class out {
636635
}
637636
}
638637

639-
auto construct_list(auto&& ...args) -> void {
640-
if (has_t || called_construct()) {
641-
if constexpr (requires { *t = T{CPP2_FORWARD(args)...}; }) {
642-
Default.expects( t );
643-
*t = T{CPP2_FORWARD(args)...};
644-
}
645-
else {
646-
Default.expects(false, "attempted to copy assign, but copy assignment is not available");
647-
}
648-
}
649-
else {
650-
Default.expects( dt );
651-
if (dt->init) {
652-
if constexpr (requires { *t = T{CPP2_FORWARD(args)...}; }) {
653-
dt->value() = T{CPP2_FORWARD(args)...};
654-
}
655-
else {
656-
Default.expects(false, "attempted to copy assign, but copy assignment is not available");
657-
}
658-
}
659-
else {
660-
dt->construct(CPP2_FORWARD(args)...);
661-
called_construct() = true;
662-
}
663-
}
664-
}
665-
666638
auto value() noexcept -> T& {
667639
if (has_t) {
668640
Default.expects( t );

regression-tests/test-results/clang-12/mixed-bugfix-for-cpp2-comment-cpp1-sequence.cpp.execution

Whitespace-only changes.

regression-tests/test-results/clang-12/mixed-bugfix-for-cpp2-comment-cpp1-sequence.cpp.output

Whitespace-only changes.

regression-tests/test-results/gcc-13/mixed-bugfix-for-cpp2-comment-cpp1-sequence.cpp.execution

Whitespace-only changes.

regression-tests/test-results/gcc-13/mixed-bugfix-for-cpp2-comment-cpp1-sequence.cpp.output

Whitespace-only changes.

regression-tests/test-results/msvc-2022/mixed-bugfix-for-cpp2-comment-cpp1-sequence.cpp.execution

Whitespace-only changes.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
mixed-bugfix-for-cpp2-comment-cpp1-sequence.cpp

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 8812:0920
2+
cppfront compiler v0.2.1 Build 8812:1229
33
Copyright(c) Herb Sutter All rights reserved
44

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

source/build.info

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
"8812:0920"
1+
"8812:1229"

source/parse.h

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -286,15 +286,15 @@ struct binary_expression_node
286286

287287
// API
288288
//
289-
auto is_standalone_expression() const
289+
auto lhs_is_id_expression() const
290290
-> bool
291291
{
292-
return
293-
my_expression
294-
&& my_expression->is_standalone_expression()
295-
;
292+
return expr->is_id_expression();
296293
}
297294

295+
auto is_standalone_expression() const
296+
-> bool;
297+
298298
auto terms_size() const
299299
-> int
300300
{
@@ -547,6 +547,20 @@ binary_expression_node<Name, Term>::binary_expression_node() {
547547
}
548548

549549

550+
template<
551+
String Name,
552+
typename Term
553+
>
554+
auto binary_expression_node<Name, Term>::is_standalone_expression() const
555+
-> bool
556+
{
557+
return
558+
my_expression
559+
&& my_expression->is_standalone_expression()
560+
;
561+
}
562+
563+
550564
enum class passing_style { in=0, copy, inout, out, move, forward, invalid };
551565
auto to_passing_style(token const& t) -> passing_style {
552566
if (t.type() == lexeme::Identifier) {

source/sema.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1683,6 +1683,7 @@ class sema
16831683
{
16841684
if (
16851685
n.is_standalone_expression()
1686+
&& n.lhs_is_id_expression()
16861687
&& std::ssize(n.terms) > 0
16871688
)
16881689
{

0 commit comments

Comments
 (0)