Skip to content

Commit 913820d

Browse files
committed
Defaulting copy constructors now works reasonably well.
One more special member to go llvm-svn: 131287
1 parent b4ccc2d commit 913820d

File tree

4 files changed

+350
-43
lines changed

4 files changed

+350
-43
lines changed

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3628,6 +3628,14 @@ def warn_explicit_conversion_functions : Warning<
36283628
// C++0x defaulted functions
36293629
def err_defaulted_default_ctor_params : Error<
36303630
"an explicitly-defaulted default constructor must have no parameters">;
3631+
def err_defaulted_copy_ctor_params : Error<
3632+
"an explicitly-defaulted copy constructor must have exactly one parameter">;
3633+
def err_defaulted_copy_ctor_volatile_param : Error<
3634+
"the parameter for an explicitly-defaulted copy constructor may not be "
3635+
"volatile">;
3636+
def err_defaulted_copy_ctor_const_param : Error<
3637+
"the parameter for this explicitly-defaulted copy constructor is const, but "
3638+
"a member or base requires it to be non-const">;
36313639
def err_incorrect_defaulted_exception_spec : Error<
36323640
"exception specification of explicitly defaulted %select{default constructor|"
36333641
"copy constructor|copy assignment operator|destructor}0 does not match the "

clang/include/clang/Sema/Sema.h

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2531,7 +2531,8 @@ class Sema {
25312531
/// \brief Helper class that collects exception specifications for
25322532
/// implicitly-declared special member functions.
25332533
class ImplicitExceptionSpecification {
2534-
ASTContext &Context;
2534+
// Pointer to allow copying
2535+
ASTContext *Context;
25352536
// We order exception specifications thus:
25362537
// noexcept is the most restrictive, but is only used in C++0x.
25372538
// throw() comes next.
@@ -2549,7 +2550,7 @@ class Sema {
25492550

25502551
public:
25512552
explicit ImplicitExceptionSpecification(ASTContext &Context)
2552-
: Context(Context), ComputedEST(EST_BasicNoexcept) {
2553+
: Context(&Context), ComputedEST(EST_BasicNoexcept) {
25532554
if (!Context.getLangOptions().CPlusPlus0x)
25542555
ComputedEST = EST_DynamicNone;
25552556
}
@@ -2584,6 +2585,11 @@ class Sema {
25842585
ImplicitExceptionSpecification
25852586
ComputeDefaultedDefaultCtorExceptionSpec(CXXRecordDecl *ClassDecl);
25862587

2588+
/// \brief Determine what sort of exception specification a defaulted
2589+
/// constructor of a class will have.
2590+
std::pair<ImplicitExceptionSpecification, bool>
2591+
ComputeDefaultedCopyCtorExceptionSpecAndConst(CXXRecordDecl *ClassDecl);
2592+
25872593
/// \brief Determine what sort of exception specification a defaulted
25882594
/// destructor of a class will have.
25892595
ImplicitExceptionSpecification
@@ -2593,6 +2599,10 @@ class Sema {
25932599
/// deleted.
25942600
bool ShouldDeleteDefaultConstructor(CXXConstructorDecl *CD);
25952601

2602+
/// \brief Determine if a defaulted copy constructor ought to be
2603+
/// deleted.
2604+
bool ShouldDeleteCopyConstructor(CXXConstructorDecl *CD);
2605+
25962606
/// \brief Determine if a defaulted destructor ought to be deleted.
25972607
bool ShouldDeleteDestructor(CXXDestructorDecl *DD);
25982608

@@ -2643,8 +2653,7 @@ class Sema {
26432653
/// DefineImplicitCopyConstructor - Checks for feasibility of
26442654
/// defining this constructor as the copy constructor.
26452655
void DefineImplicitCopyConstructor(SourceLocation CurrentLocation,
2646-
CXXConstructorDecl *Constructor,
2647-
unsigned TypeQuals);
2656+
CXXConstructorDecl *Constructor);
26482657

26492658
/// \brief Declare the implicit copy assignment operator for the given class.
26502659
///
@@ -3271,6 +3280,7 @@ class Sema {
32713280

32723281
void CheckExplicitlyDefaultedMethods(CXXRecordDecl *Record);
32733282
void CheckExplicitlyDefaultedDefaultConstructor(CXXConstructorDecl *Ctor);
3283+
void CheckExplicitlyDefaultedCopyConstructor(CXXConstructorDecl *Ctor);
32743284
void CheckExplicitlyDefaultedDestructor(CXXDestructorDecl *Dtor);
32753285

32763286
//===--------------------------------------------------------------------===//

0 commit comments

Comments
 (0)