aboutsummaryrefslogtreecommitdiff
path: root/test/CXX/dcl.decl/dcl.meaning/dcl.fct/dcl.fct.def.default/p2.cpp
blob: 4227d82e7753ee50b114876cf8eea17a62188a7c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %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 {{explicitly-defaulted move assignment operator must return 'move::AssignmentRet1 &'}}
  };

  struct AssignmentRet2 {
    const AssignmentRet2& operator=(AssignmentRet2&&) = default; // expected-error {{explicitly-defaulted move assignment operator must return 'move::AssignmentRet2 &'}}
  };

  struct ConstAssignment {
    ConstAssignment& operator=(ConstAssignment&&) const = default; // expected-error {{an explicitly-defaulted move assignment operator may not have 'const', 'constexpr' 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 NonConst2 {
    NonConst2(NonConst2&);
    NonConst2& operator=(NonConst2&);
  };
  NonConst2::NonConst2(NonConst2&) = default;
  NonConst2 &NonConst2::operator=(NonConst2&) = default;

  struct NonConst3 {
    NonConst3(NonConst3&) = default;
    NonConst3& operator=(NonConst3&) = default;
    NonConst nc;
  };

  struct BadConst {
    BadConst(const BadConst&) = default; // expected-error {{is const, but}}
    BadConst& operator=(const BadConst&) = default; // expected-error {{is const, but}}
    NonConst nc; // makes implicit copy non-const
  };

  struct AssignmentRet1 {
    AssignmentRet1&& operator=(const AssignmentRet1&) = default; // expected-error {{explicitly-defaulted copy assignment operator must return 'copy::AssignmentRet1 &'}}
  };

  struct AssignmentRet2 {
    const AssignmentRet2& operator=(const AssignmentRet2&) = default; // expected-error {{explicitly-defaulted copy assignment operator must return 'copy::AssignmentRet2 &'}}
  };

  struct ConstAssignment {
    ConstAssignment& operator=(const ConstAssignment&) const = default; // expected-error {{an explicitly-defaulted copy assignment operator may not have 'const', 'constexpr' or 'volatile' qualifiers}}
  };
}