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 {{explicitly-defaulted move assignment operator must return 'move::AssignmentRet1 &'}}
     18   };
     19 
     20   struct AssignmentRet2 {
     21     const AssignmentRet2& operator=(AssignmentRet2&&) = default; // expected-error {{explicitly-defaulted move assignment operator must return 'move::AssignmentRet2 &'}}
     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 NonConst2 {
     46     NonConst2(NonConst2&);
     47     NonConst2& operator=(NonConst2&);
     48   };
     49   NonConst2::NonConst2(NonConst2&) = default;
     50   NonConst2 &NonConst2::operator=(NonConst2&) = default;
     51 
     52   struct NonConst3 {
     53     NonConst3(NonConst3&) = default;
     54     NonConst3& operator=(NonConst3&) = default;
     55     NonConst nc;
     56   };
     57 
     58   struct BadConst {
     59     BadConst(const BadConst&) = default; // expected-error {{is const, but}}
     60     BadConst& operator=(const BadConst&) = default; // expected-error {{is const, but}}
     61     NonConst nc; // makes implicit copy non-const
     62   };
     63 
     64   struct AssignmentRet1 {
     65     AssignmentRet1&& operator=(const AssignmentRet1&) = default; // expected-error {{explicitly-defaulted copy assignment operator must return 'copy::AssignmentRet1 &'}}
     66   };
     67 
     68   struct AssignmentRet2 {
     69     const AssignmentRet2& operator=(const AssignmentRet2&) = default; // expected-error {{explicitly-defaulted copy assignment operator must return 'copy::AssignmentRet2 &'}}
     70   };
     71 
     72   struct ConstAssignment {
     73     ConstAssignment& operator=(const ConstAssignment&) const = default; // expected-error {{an explicitly-defaulted copy assignment operator may not have 'const', 'constexpr' or 'volatile' qualifiers}}
     74   };
     75 }
     76