[flang] Fix crash in HLFIR generation (#118399)
[llvm-project.git] / clang / test / CXX / dcl.decl / dcl.meaning / dcl.fct / dcl.fct.def.default / p2.cpp
blobfc11ec3f940317f31c9f8863047d39bb9ab0ca08
1 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
3 // FIXME: test with non-std qualifiers
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 };
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}}
16 struct AssignmentRet1 {
17 AssignmentRet1&& operator=(AssignmentRet1&&) = default; // expected-error {{explicitly-defaulted move assignment operator must return 'AssignmentRet1 &'}}
20 struct AssignmentRet2 {
21 const AssignmentRet2& operator=(AssignmentRet2&&) = default; // expected-error {{explicitly-defaulted move assignment operator must return 'AssignmentRet2 &'}}
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}}
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}}
35 struct Const {
36 Const(const Const&) = default;
37 Const& operator=(const Const&) = default;
40 struct NonConst {
41 NonConst(NonConst&) = default;
42 NonConst& operator=(NonConst&) = default;
45 struct NonConst2 {
46 NonConst2(NonConst2&);
47 NonConst2& operator=(NonConst2&);
49 NonConst2::NonConst2(NonConst2&) = default;
50 NonConst2 &NonConst2::operator=(NonConst2&) = default;
52 struct NonConst3 {
53 NonConst3(NonConst3&) = default;
54 NonConst3& operator=(NonConst3&) = default;
55 NonConst nc;
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
64 struct AssignmentRet1 {
65 AssignmentRet1&& operator=(const AssignmentRet1&) = default; // expected-error {{explicitly-defaulted copy assignment operator must return 'AssignmentRet1 &'}}
68 struct AssignmentRet2 {
69 const AssignmentRet2& operator=(const AssignmentRet2&) = default; // expected-error {{explicitly-defaulted copy assignment operator must return 'AssignmentRet2 &'}}
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}}