p2.cpp revision ac71351acdefc9de0c770c1d717e621ac9e684bf
1baa3858d3f5d128a5c8466b700098109edcad5f2repo sync// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
2baa3858d3f5d128a5c8466b700098109edcad5f2repo sync
3baa3858d3f5d128a5c8466b700098109edcad5f2repo sync// FIXME: test with non-std qualifiers
4baa3858d3f5d128a5c8466b700098109edcad5f2repo sync
5baa3858d3f5d128a5c8466b700098109edcad5f2repo syncnamespace move {
6baa3858d3f5d128a5c8466b700098109edcad5f2repo sync  struct Const {
7baa3858d3f5d128a5c8466b700098109edcad5f2repo sync    Const(const Const&&) = default; // expected-error {{the parameter for an explicitly-defaulted move constructor may not be const}}
8baa3858d3f5d128a5c8466b700098109edcad5f2repo sync    Const& operator=(const Const&&) = default; // expected-error {{the parameter for an explicitly-defaulted move assignment operator may not be const}}
9baa3858d3f5d128a5c8466b700098109edcad5f2repo sync  };
10baa3858d3f5d128a5c8466b700098109edcad5f2repo sync
11baa3858d3f5d128a5c8466b700098109edcad5f2repo sync  struct Volatile {
12baa3858d3f5d128a5c8466b700098109edcad5f2repo sync    Volatile(volatile Volatile&&) = default; // expected-error {{the parameter for an explicitly-defaulted move constructor may not be volatile}}
13baa3858d3f5d128a5c8466b700098109edcad5f2repo sync    Volatile& operator=(volatile Volatile&&) = default; // expected-error {{the parameter for an explicitly-defaulted move assignment operator may not be volatile}}
14baa3858d3f5d128a5c8466b700098109edcad5f2repo sync  };
15baa3858d3f5d128a5c8466b700098109edcad5f2repo sync
16baa3858d3f5d128a5c8466b700098109edcad5f2repo sync  struct AssignmentRet1 {
17baa3858d3f5d128a5c8466b700098109edcad5f2repo sync    AssignmentRet1&& operator=(AssignmentRet1&&) = default; // expected-error {{explicitly-defaulted move assignment operator must return 'move::AssignmentRet1 &'}}
18baa3858d3f5d128a5c8466b700098109edcad5f2repo sync  };
19baa3858d3f5d128a5c8466b700098109edcad5f2repo sync
20baa3858d3f5d128a5c8466b700098109edcad5f2repo sync  struct AssignmentRet2 {
21baa3858d3f5d128a5c8466b700098109edcad5f2repo sync    const AssignmentRet2& operator=(AssignmentRet2&&) = default; // expected-error {{explicitly-defaulted move assignment operator must return 'move::AssignmentRet2 &'}}
22baa3858d3f5d128a5c8466b700098109edcad5f2repo sync  };
23baa3858d3f5d128a5c8466b700098109edcad5f2repo sync
24baa3858d3f5d128a5c8466b700098109edcad5f2repo sync  struct ConstAssignment {
25baa3858d3f5d128a5c8466b700098109edcad5f2repo sync    ConstAssignment& operator=(ConstAssignment&&) const = default; // expected-error {{an explicitly-defaulted move assignment operator may not have 'const', 'constexpr' or 'volatile' qualifiers}}
26baa3858d3f5d128a5c8466b700098109edcad5f2repo sync  };
27baa3858d3f5d128a5c8466b700098109edcad5f2repo sync}
28baa3858d3f5d128a5c8466b700098109edcad5f2repo sync
29baa3858d3f5d128a5c8466b700098109edcad5f2repo syncnamespace copy {
30baa3858d3f5d128a5c8466b700098109edcad5f2repo sync  struct Volatile {
31baa3858d3f5d128a5c8466b700098109edcad5f2repo sync    Volatile(const volatile Volatile&) = default; // expected-error {{the parameter for an explicitly-defaulted copy constructor may not be volatile}}
32baa3858d3f5d128a5c8466b700098109edcad5f2repo sync    Volatile& operator=(const volatile Volatile&) = default; // expected-error {{the parameter for an explicitly-defaulted copy assignment operator may not be volatile}}
33baa3858d3f5d128a5c8466b700098109edcad5f2repo sync  };
34baa3858d3f5d128a5c8466b700098109edcad5f2repo sync
35baa3858d3f5d128a5c8466b700098109edcad5f2repo sync  struct Const {
36baa3858d3f5d128a5c8466b700098109edcad5f2repo sync    Const(const Const&) = default;
37baa3858d3f5d128a5c8466b700098109edcad5f2repo sync    Const& operator=(const Const&) = default;
38baa3858d3f5d128a5c8466b700098109edcad5f2repo sync  };
39baa3858d3f5d128a5c8466b700098109edcad5f2repo sync
40baa3858d3f5d128a5c8466b700098109edcad5f2repo sync  struct NonConst {
41baa3858d3f5d128a5c8466b700098109edcad5f2repo sync    NonConst(NonConst&) = default;
42baa3858d3f5d128a5c8466b700098109edcad5f2repo sync    NonConst& operator=(NonConst&) = default;
43baa3858d3f5d128a5c8466b700098109edcad5f2repo sync  };
44baa3858d3f5d128a5c8466b700098109edcad5f2repo sync
45baa3858d3f5d128a5c8466b700098109edcad5f2repo sync  struct NonConst2 {
46baa3858d3f5d128a5c8466b700098109edcad5f2repo sync    NonConst2(NonConst2&);
47baa3858d3f5d128a5c8466b700098109edcad5f2repo sync    NonConst2& operator=(NonConst2&);
48baa3858d3f5d128a5c8466b700098109edcad5f2repo sync  };
49baa3858d3f5d128a5c8466b700098109edcad5f2repo sync  NonConst2::NonConst2(NonConst2&) = default;
50baa3858d3f5d128a5c8466b700098109edcad5f2repo sync  NonConst2 &NonConst2::operator=(NonConst2&) = default;
51baa3858d3f5d128a5c8466b700098109edcad5f2repo sync
52baa3858d3f5d128a5c8466b700098109edcad5f2repo sync  struct NonConst3 {
53baa3858d3f5d128a5c8466b700098109edcad5f2repo sync    NonConst3(NonConst3&) = default;
54baa3858d3f5d128a5c8466b700098109edcad5f2repo sync    NonConst3& operator=(NonConst3&) = default;
55baa3858d3f5d128a5c8466b700098109edcad5f2repo sync    NonConst nc;
56baa3858d3f5d128a5c8466b700098109edcad5f2repo sync  };
57baa3858d3f5d128a5c8466b700098109edcad5f2repo sync
58baa3858d3f5d128a5c8466b700098109edcad5f2repo sync  struct BadConst {
59baa3858d3f5d128a5c8466b700098109edcad5f2repo sync    BadConst(const BadConst&) = default; // expected-error {{is const, but}}
60baa3858d3f5d128a5c8466b700098109edcad5f2repo sync    BadConst& operator=(const BadConst&) = default; // expected-error {{is const, but}}
61baa3858d3f5d128a5c8466b700098109edcad5f2repo sync    NonConst nc; // makes implicit copy non-const
62baa3858d3f5d128a5c8466b700098109edcad5f2repo sync  };
63baa3858d3f5d128a5c8466b700098109edcad5f2repo sync
64baa3858d3f5d128a5c8466b700098109edcad5f2repo sync  struct AssignmentRet1 {
65baa3858d3f5d128a5c8466b700098109edcad5f2repo sync    AssignmentRet1&& operator=(const AssignmentRet1&) = default; // expected-error {{explicitly-defaulted copy assignment operator must return 'copy::AssignmentRet1 &'}}
66baa3858d3f5d128a5c8466b700098109edcad5f2repo sync  };
67baa3858d3f5d128a5c8466b700098109edcad5f2repo sync
68baa3858d3f5d128a5c8466b700098109edcad5f2repo sync  struct AssignmentRet2 {
69baa3858d3f5d128a5c8466b700098109edcad5f2repo sync    const AssignmentRet2& operator=(const AssignmentRet2&) = default; // expected-error {{explicitly-defaulted copy assignment operator must return 'copy::AssignmentRet2 &'}}
70baa3858d3f5d128a5c8466b700098109edcad5f2repo sync  };
71baa3858d3f5d128a5c8466b700098109edcad5f2repo sync
72baa3858d3f5d128a5c8466b700098109edcad5f2repo sync  struct ConstAssignment {
73baa3858d3f5d128a5c8466b700098109edcad5f2repo sync    ConstAssignment& operator=(const ConstAssignment&) const = default; // expected-error {{an explicitly-defaulted copy assignment operator may not have 'const', 'constexpr' or 'volatile' qualifiers}}
74baa3858d3f5d128a5c8466b700098109edcad5f2repo sync  };
75baa3858d3f5d128a5c8466b700098109edcad5f2repo sync}
76baa3858d3f5d128a5c8466b700098109edcad5f2repo sync