Skip to content

Commit

Permalink
Emit a non-implicit default constructor as explicit, closes #398
Browse files Browse the repository at this point in the history
  • Loading branch information
hsutter committed May 15, 2023
1 parent 187ba23 commit d4647ed
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion regression-tests/test-results/pure2-requires-clauses.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ template<typename T, typename U>
requires( std::is_same_v<T,int>
&& std::is_same_v<U,int> )
class X {
public: X();
public: explicit X();

public: X(X const&) = delete; /* No 'that' constructor, suppress copy */
public: auto operator=(X const&) -> void = delete;
Expand Down
2 changes: 1 addition & 1 deletion regression-tests/test-results/pure2-types-basics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class myclass {


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


#line 34 "pure2-types-basics.cpp2"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class mystruct {
public: auto operator=(mystruct const& that) -> mystruct& ;
public: mystruct(mystruct&& that);
public: auto operator=(mystruct&& that) -> mystruct& ;
public: mystruct();
public: explicit mystruct();

#line 19 "pure2-types-ordering-via-meta-functions.cpp2"
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class myclass;
#line 2 "pure2-types-that-parameters.cpp2"
class myclass {

public: myclass();
public: explicit myclass();

public: myclass(myclass const& that);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public: widget(widget const& that);
public: auto operator=(widget const& that) -> widget& ;
public: widget(widget&& that);
public: auto operator=(widget&& that) -> widget& ;
public: widget();
public: explicit widget();

#line 5 "pure2-types-value-types-via-meta-functions.cpp2"
};
Expand All @@ -50,7 +50,7 @@ public: w_widget(w_widget const& that);
public: auto operator=(w_widget const& that) -> w_widget& ;
public: w_widget(w_widget&& that);
public: auto operator=(w_widget&& that) -> w_widget& ;
public: w_widget();
public: explicit w_widget();

#line 10 "pure2-types-value-types-via-meta-functions.cpp2"
};
Expand All @@ -66,7 +66,7 @@ public: p_widget(p_widget const& that);
public: auto operator=(p_widget const& that) -> p_widget& ;
public: p_widget(p_widget&& that);
public: auto operator=(p_widget&& that) -> p_widget& ;
public: p_widget();
public: explicit p_widget();

#line 15 "pure2-types-value-types-via-meta-functions.cpp2"
};
Expand Down
2 changes: 1 addition & 1 deletion regression-tests/test-results/version
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

cppfront compiler v0.2.1 Build 8515:0547
cppfront compiler v0.2.1 Build 8515:0551
Copyright(c) Herb Sutter All rights reserved

SPDX-License-Identifier: CC-BY-NC-ND-4.0
Expand Down
2 changes: 1 addition & 1 deletion source/build.info
Original file line number Diff line number Diff line change
@@ -1 +1 @@
"8515:0547"
"8515:0551"
2 changes: 1 addition & 1 deletion source/cppfront.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5262,8 +5262,8 @@ class cppfront
break;default:
if (
func->is_constructor()
&& (func->is_default_constructor() || func->parameters->ssize() == 2)
&& !func->is_constructor_with_that()
&& func->parameters->ssize() == 2
&& generating_assignment_from != &n
)
{
Expand Down

0 comments on commit d4647ed

Please sign in to comment.