Home | History | Annotate | Download | only in dcl.fct.def.default
      1 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
      2 
      3 // FIXME: test with non-std qualifiers
      4 
      5 namespace move {
      6   struct Const {
      7     Const(const Const&&) = default; // expected-error {{the parameter for an explicitly-defaulted move constructor may not be const}}
      8     Const& operator=(const Const&&) = default; // expected-error {{the parameter for an explicitly-defaulted move assignment operator may not be const}}
      9   };
     10 
     11   struct Volatile {
     12     Volatile(volatile Volatile&&) = default; // expected-error {{the parameter for an explicitly-defaulted move constructor may not be volatile}}
     13     Volatile& operator=(volatile Volatile&&) = default; // expected-error {{the parameter for an explicitly-defaulted move assignment operator may not be volatile}}
     14   };
     15 
     16   struct AssignmentRet1 {
     17     AssignmentRet1&& operator=(AssignmentRet1&&) = default; // expected-error {{an explicitly-defaulted move assignment operator must return an unqualified lvalue reference to its class type}}
     18   };
     19 
     20   struct AssignmentRet2 {
     21     const AssignmentRet2& operator=(AssignmentRet2&&) = default; // expected-error {{an explicitly-defaulted move assignment operator must return an unqualified lvalue reference to its class type}}
     22   };
     23 
     24   struct ConstAssignment {
     25     ConstAssignment& operator=(ConstAssignment&&) const = default; // expected-error {{an explicitly-defaulted move assignment operator may not have 'const', 'constexpr' or 'volatile' qualifiers}}
     26   };
     27 }
     28 
     29 namespace copy {
     30   struct Volatile {
     31     Volatile(const volatile Volatile&) = default; // expected-error {{the parameter for an explicitly-defaulted copy constructor may not be volatile}}
     32     Volatile& operator=(const volatile Volatile&) = default; // expected-error {{the parameter for an explicitly-defaulted copy assignment operator may not be volatile}}
     33   };
     34 
     35   struct Const {
     36     Const(const Const&) = default;
     37     Const& operator=(const Const&) = default;
     38   };
     39 
     40   struct NonConst {
     41     NonConst(NonConst&) = default;
     42     NonConst& operator=(NonConst&) = default;
     43   };
     44 
     45   struct BadConst {
     46     NonConst nc; // makes implicit copy non-const
     47     BadConst(const BadConst&) = default; // expected-error {{is const, but}}
     48     BadConst& operator=(const BadConst&) = default; // expected-error {{is const, but}}
     49   };
     50 
     51   struct AssignmentRet1 {
     52     AssignmentRet1&& operator=(const AssignmentRet1&) = default; // expected-error {{an explicitly-defaulted copy assignment operator must return an unqualified lvalue reference to its class type}}
     53   };
     54 
     55   struct AssignmentRet2 {
     56     const AssignmentRet2& operator=(const AssignmentRet2&) = default; // expected-error {{an explicitly-defaulted copy assignment operator must return an unqualified lvalue reference to its class type}}
     57   };
     58 
     59   struct ConstAssignment {
     60     ConstAssignment& operator=(const ConstAssignment&) const = default; // expected-error {{an explicitly-defaulted copy assignment operator may not have 'const', 'constexpr' or 'volatile' qualifiers}}
     61   };
     62 }
     63