Skip to content

Commit d4647ed

Browse files
committed
Emit a non-implicit default constructor as explicit, closes #398
1 parent 187ba23 commit d4647ed

8 files changed

+10
-10
lines changed

regression-tests/test-results/pure2-requires-clauses.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ template<typename T, typename U>
2323
requires( std::is_same_v<T,int>
2424
&& std::is_same_v<U,int> )
2525
class X {
26-
public: X();
26+
public: explicit X();
2727

2828
public: X(X const&) = delete; /* No 'that' constructor, suppress copy */
2929
public: auto operator=(X const&) -> void = delete;

regression-tests/test-results/pure2-types-basics.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class myclass {
4242

4343

4444
#line 27 "pure2-types-basics.cpp2"
45-
public: myclass();
45+
public: explicit myclass();
4646

4747

4848
#line 34 "pure2-types-basics.cpp2"

regression-tests/test-results/pure2-types-ordering-via-meta-functions.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ class mystruct {
7373
public: auto operator=(mystruct const& that) -> mystruct& ;
7474
public: mystruct(mystruct&& that);
7575
public: auto operator=(mystruct&& that) -> mystruct& ;
76-
public: mystruct();
76+
public: explicit mystruct();
7777

7878
#line 19 "pure2-types-ordering-via-meta-functions.cpp2"
7979
};

regression-tests/test-results/pure2-types-that-parameters.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class myclass;
1717
#line 2 "pure2-types-that-parameters.cpp2"
1818
class myclass {
1919

20-
public: myclass();
20+
public: explicit myclass();
2121

2222
public: myclass(myclass const& that);
2323

regression-tests/test-results/pure2-types-value-types-via-meta-functions.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public: widget(widget const& that);
3434
public: auto operator=(widget const& that) -> widget& ;
3535
public: widget(widget&& that);
3636
public: auto operator=(widget&& that) -> widget& ;
37-
public: widget();
37+
public: explicit widget();
3838

3939
#line 5 "pure2-types-value-types-via-meta-functions.cpp2"
4040
};
@@ -50,7 +50,7 @@ public: w_widget(w_widget const& that);
5050
public: auto operator=(w_widget const& that) -> w_widget& ;
5151
public: w_widget(w_widget&& that);
5252
public: auto operator=(w_widget&& that) -> w_widget& ;
53-
public: w_widget();
53+
public: explicit w_widget();
5454

5555
#line 10 "pure2-types-value-types-via-meta-functions.cpp2"
5656
};
@@ -66,7 +66,7 @@ public: p_widget(p_widget const& that);
6666
public: auto operator=(p_widget const& that) -> p_widget& ;
6767
public: p_widget(p_widget&& that);
6868
public: auto operator=(p_widget&& that) -> p_widget& ;
69-
public: p_widget();
69+
public: explicit p_widget();
7070

7171
#line 15 "pure2-types-value-types-via-meta-functions.cpp2"
7272
};

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 8515:0547
2+
cppfront compiler v0.2.1 Build 8515:0551
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-
"8515:0547"
1+
"8515:0551"

source/cppfront.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5262,8 +5262,8 @@ class cppfront
52625262
break;default:
52635263
if (
52645264
func->is_constructor()
5265+
&& (func->is_default_constructor() || func->parameters->ssize() == 2)
52655266
&& !func->is_constructor_with_that()
5266-
&& func->parameters->ssize() == 2
52675267
&& generating_assignment_from != &n
52685268
)
52695269
{

0 commit comments

Comments
 (0)