BasePath.push_back(BaseSpec);
CopyCtorArg = SemaRef.ImpCastExprToType(CopyCtorArg, ArgTy,
CK_UncheckedDerivedToBase,
- Moving ? VK_RValue : VK_LValue,
+ Moving ? VK_XValue : VK_LValue,
&BasePath).take();
InitializationKind InitKind
MemberLookup.addDecl(Indirect ? cast<ValueDecl>(Indirect)
: cast<ValueDecl>(Field), AS_public);
MemberLookup.resolveKind();
- ExprResult CopyCtorArg
+ ExprResult CtorArg
= SemaRef.BuildMemberReferenceExpr(MemberExprBase,
ParamType, Loc,
/*IsArrow=*/false,
/*FirstQualifierInScope=*/0,
MemberLookup,
/*TemplateArgs=*/0);
- if (CopyCtorArg.isInvalid())
+ if (CtorArg.isInvalid())
return true;
// C++11 [class.copy]p15:
// - if a member m has rvalue reference type T&&, it is direct-initialized
// with static_cast<T&&>(x.m);
- if (RefersToRValueRef(CopyCtorArg.get())) {
- CopyCtorArg = CastForMoving(SemaRef, CopyCtorArg.take());
+ if (RefersToRValueRef(CtorArg.get())) {
+ CtorArg = CastForMoving(SemaRef, CtorArg.take());
}
// When the field we are copying is an array, create index variables for
= SemaRef.BuildDeclRefExpr(IterationVar, SizeType, VK_RValue, Loc);
assert(!IterationVarRef.isInvalid() &&
"Reference to invented variable cannot fail!");
-
+
// Subscript the array with this iteration variable.
- CopyCtorArg = SemaRef.CreateBuiltinArraySubscriptExpr(CopyCtorArg.take(),
- Loc,
+ CtorArg = SemaRef.CreateBuiltinArraySubscriptExpr(CtorArg.take(), Loc,
IterationVarRef.take(),
- Loc);
- if (CopyCtorArg.isInvalid())
+ Loc);
+ if (CtorArg.isInvalid())
return true;
BaseType = Array->getElementType();
// The array subscript expression is an lvalue, which is wrong for moving.
if (Moving && InitializingArray)
- CopyCtorArg = CastForMoving(SemaRef, CopyCtorArg.take());
+ CtorArg = CastForMoving(SemaRef, CtorArg.take());
// Construct the entity that we will be initializing. For an array, this
// will be first element in the array, which may require several levels
InitializationKind InitKind =
InitializationKind::CreateDirect(Loc, SourceLocation(), SourceLocation());
- Expr *CopyCtorArgE = CopyCtorArg.takeAs<Expr>();
+ Expr *CtorArgE = CtorArg.takeAs<Expr>();
InitializationSequence InitSeq(SemaRef, Entities.back(), InitKind,
- &CopyCtorArgE, 1);
+ &CtorArgE, 1);
ExprResult MemberInit
= InitSeq.Perform(SemaRef, Entities.back(), InitKind,
- MultiExprArg(&CopyCtorArgE, 1));
+ MultiExprArg(&CtorArgE, 1));
MemberInit = SemaRef.MaybeCreateExprWithCleanups(MemberInit);
if (MemberInit.isInvalid())
return true;
--- /dev/null
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++0x %s
+
+// FIXME: test with non-std qualifiers
+
+namespace move {
+ struct Const {
+ Const(const Const&&) = default; // expected-error {{the parameter for an explicitly-defaulted move constructor may not be const}}
+ Const& operator=(const Const&&) = default; // expected-error {{the parameter for an explicitly-defaulted move assignment operator may not be const}}
+ };
+
+ struct Volatile {
+ Volatile(volatile Volatile&&) = default; // expected-error {{the parameter for an explicitly-defaulted move constructor may not be volatile}}
+ Volatile& operator=(volatile Volatile&&) = default; // expected-error {{the parameter for an explicitly-defaulted move assignment operator may not be volatile}}
+ };
+
+ struct AssignmentRet1 {
+ AssignmentRet1&& operator=(AssignmentRet1&&) = default; // expected-error {{an explicitly-defaulted move assignment operator must return an unqualified lvalue reference to its class type}}
+ };
+
+ struct AssignmentRet2 {
+ const AssignmentRet2& operator=(AssignmentRet2&&) = default; // expected-error {{an explicitly-defaulted move assignment operator must return an unqualified lvalue reference to its class type}}
+ };
+
+ struct ConstAssignment {
+ ConstAssignment& operator=(ConstAssignment&&) const = default; // expected-error {{an explicitly-defaulted move assignment operator may not have 'const' or 'volatile' qualifiers}}
+ };
+}
+
+namespace copy {
+ struct Volatile {
+ Volatile(const volatile Volatile&) = default; // expected-error {{the parameter for an explicitly-defaulted copy constructor may not be volatile}}
+ Volatile& operator=(const volatile Volatile&) = default; // expected-error {{the parameter for an explicitly-defaulted copy assignment operator may not be volatile}}
+ };
+
+ struct Const {
+ Const(const Const&) = default;
+ Const& operator=(const Const&) = default;
+ };
+
+ struct NonConst {
+ NonConst(NonConst&) = default;
+ NonConst& operator=(NonConst&) = default;
+ };
+
+ struct BadConst {
+ NonConst nc; // makes implicit copy non-const
+ BadConst(const BadConst&) = default; // expected-error {{is const, but}}
+ BadConst& operator=(const BadConst&) = default; // expected-error {{is const, but}}
+ };
+
+ struct AssignmentRet1 {
+ AssignmentRet1&& operator=(const AssignmentRet1&) = default; // expected-error {{an explicitly-defaulted copy assignment operator must return an unqualified lvalue reference to its class type}}
+ };
+
+ struct AssignmentRet2 {
+ const AssignmentRet2& operator=(const AssignmentRet2&) = default; // expected-error {{an explicitly-defaulted copy assignment operator must return an unqualified lvalue reference to its class type}}
+ };
+
+ struct ConstAssignment {
+ ConstAssignment& operator=(const ConstAssignment&) const = default; // expected-error {{an explicitly-defaulted copy assignment operator may not have 'const' or 'volatile' qualifiers}}
+ };
+}