1762bb9d0ad20320b9f97a841dce57ba5e8e48b07Richard Smith// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s 274e611a5fd0b5977c664d13a07b625ae23527d0dSebastian Redl 374e611a5fd0b5977c664d13a07b625ae23527d0dSebastian Redl// FIXME: test with non-std qualifiers 474e611a5fd0b5977c664d13a07b625ae23527d0dSebastian Redl 574e611a5fd0b5977c664d13a07b625ae23527d0dSebastian Redlnamespace move { 674e611a5fd0b5977c664d13a07b625ae23527d0dSebastian Redl struct Const { 774e611a5fd0b5977c664d13a07b625ae23527d0dSebastian Redl Const(const Const&&) = default; // expected-error {{the parameter for an explicitly-defaulted move constructor may not be const}} 874e611a5fd0b5977c664d13a07b625ae23527d0dSebastian Redl Const& operator=(const Const&&) = default; // expected-error {{the parameter for an explicitly-defaulted move assignment operator may not be const}} 974e611a5fd0b5977c664d13a07b625ae23527d0dSebastian Redl }; 1074e611a5fd0b5977c664d13a07b625ae23527d0dSebastian Redl 1174e611a5fd0b5977c664d13a07b625ae23527d0dSebastian Redl struct Volatile { 1274e611a5fd0b5977c664d13a07b625ae23527d0dSebastian Redl Volatile(volatile Volatile&&) = default; // expected-error {{the parameter for an explicitly-defaulted move constructor may not be volatile}} 1374e611a5fd0b5977c664d13a07b625ae23527d0dSebastian Redl Volatile& operator=(volatile Volatile&&) = default; // expected-error {{the parameter for an explicitly-defaulted move assignment operator may not be volatile}} 1474e611a5fd0b5977c664d13a07b625ae23527d0dSebastian Redl }; 1574e611a5fd0b5977c664d13a07b625ae23527d0dSebastian Redl 1674e611a5fd0b5977c664d13a07b625ae23527d0dSebastian Redl struct AssignmentRet1 { 173003e1d6626d07e8fc4af95fad95b3a5d4c4af98Richard Smith AssignmentRet1&& operator=(AssignmentRet1&&) = default; // expected-error {{explicitly-defaulted move assignment operator must return 'move::AssignmentRet1 &'}} 1874e611a5fd0b5977c664d13a07b625ae23527d0dSebastian Redl }; 1974e611a5fd0b5977c664d13a07b625ae23527d0dSebastian Redl 2074e611a5fd0b5977c664d13a07b625ae23527d0dSebastian Redl struct AssignmentRet2 { 213003e1d6626d07e8fc4af95fad95b3a5d4c4af98Richard Smith const AssignmentRet2& operator=(AssignmentRet2&&) = default; // expected-error {{explicitly-defaulted move assignment operator must return 'move::AssignmentRet2 &'}} 2274e611a5fd0b5977c664d13a07b625ae23527d0dSebastian Redl }; 2374e611a5fd0b5977c664d13a07b625ae23527d0dSebastian Redl 2474e611a5fd0b5977c664d13a07b625ae23527d0dSebastian Redl struct ConstAssignment { 2555dec868977ccb89cab0286122f9345f63bb5de7Richard Smith ConstAssignment& operator=(ConstAssignment&&) const = default; // expected-error {{an explicitly-defaulted move assignment operator may not have 'const', 'constexpr' or 'volatile' qualifiers}} 2674e611a5fd0b5977c664d13a07b625ae23527d0dSebastian Redl }; 2774e611a5fd0b5977c664d13a07b625ae23527d0dSebastian Redl} 2874e611a5fd0b5977c664d13a07b625ae23527d0dSebastian Redl 2974e611a5fd0b5977c664d13a07b625ae23527d0dSebastian Redlnamespace copy { 3074e611a5fd0b5977c664d13a07b625ae23527d0dSebastian Redl struct Volatile { 3174e611a5fd0b5977c664d13a07b625ae23527d0dSebastian Redl Volatile(const volatile Volatile&) = default; // expected-error {{the parameter for an explicitly-defaulted copy constructor may not be volatile}} 3274e611a5fd0b5977c664d13a07b625ae23527d0dSebastian Redl Volatile& operator=(const volatile Volatile&) = default; // expected-error {{the parameter for an explicitly-defaulted copy assignment operator may not be volatile}} 3374e611a5fd0b5977c664d13a07b625ae23527d0dSebastian Redl }; 3474e611a5fd0b5977c664d13a07b625ae23527d0dSebastian Redl 3574e611a5fd0b5977c664d13a07b625ae23527d0dSebastian Redl struct Const { 3674e611a5fd0b5977c664d13a07b625ae23527d0dSebastian Redl Const(const Const&) = default; 3774e611a5fd0b5977c664d13a07b625ae23527d0dSebastian Redl Const& operator=(const Const&) = default; 3874e611a5fd0b5977c664d13a07b625ae23527d0dSebastian Redl }; 3974e611a5fd0b5977c664d13a07b625ae23527d0dSebastian Redl 4074e611a5fd0b5977c664d13a07b625ae23527d0dSebastian Redl struct NonConst { 41ac71351acdefc9de0c770c1d717e621ac9e684bfRichard Smith NonConst(NonConst&) = default; 42ac71351acdefc9de0c770c1d717e621ac9e684bfRichard Smith NonConst& operator=(NonConst&) = default; 433003e1d6626d07e8fc4af95fad95b3a5d4c4af98Richard Smith }; 443003e1d6626d07e8fc4af95fad95b3a5d4c4af98Richard Smith 453003e1d6626d07e8fc4af95fad95b3a5d4c4af98Richard Smith struct NonConst2 { 463003e1d6626d07e8fc4af95fad95b3a5d4c4af98Richard Smith NonConst2(NonConst2&); 473003e1d6626d07e8fc4af95fad95b3a5d4c4af98Richard Smith NonConst2& operator=(NonConst2&); 483003e1d6626d07e8fc4af95fad95b3a5d4c4af98Richard Smith }; 493003e1d6626d07e8fc4af95fad95b3a5d4c4af98Richard Smith NonConst2::NonConst2(NonConst2&) = default; 503003e1d6626d07e8fc4af95fad95b3a5d4c4af98Richard Smith NonConst2 &NonConst2::operator=(NonConst2&) = default; 513003e1d6626d07e8fc4af95fad95b3a5d4c4af98Richard Smith 523003e1d6626d07e8fc4af95fad95b3a5d4c4af98Richard Smith struct NonConst3 { 533003e1d6626d07e8fc4af95fad95b3a5d4c4af98Richard Smith NonConst3(NonConst3&) = default; 543003e1d6626d07e8fc4af95fad95b3a5d4c4af98Richard Smith NonConst3& operator=(NonConst3&) = default; 553003e1d6626d07e8fc4af95fad95b3a5d4c4af98Richard Smith NonConst nc; 5674e611a5fd0b5977c664d13a07b625ae23527d0dSebastian Redl }; 5774e611a5fd0b5977c664d13a07b625ae23527d0dSebastian Redl 5874e611a5fd0b5977c664d13a07b625ae23527d0dSebastian Redl struct BadConst { 5974e611a5fd0b5977c664d13a07b625ae23527d0dSebastian Redl BadConst(const BadConst&) = default; // expected-error {{is const, but}} 6074e611a5fd0b5977c664d13a07b625ae23527d0dSebastian Redl BadConst& operator=(const BadConst&) = default; // expected-error {{is const, but}} 613003e1d6626d07e8fc4af95fad95b3a5d4c4af98Richard Smith NonConst nc; // makes implicit copy non-const 6274e611a5fd0b5977c664d13a07b625ae23527d0dSebastian Redl }; 6374e611a5fd0b5977c664d13a07b625ae23527d0dSebastian Redl 6474e611a5fd0b5977c664d13a07b625ae23527d0dSebastian Redl struct AssignmentRet1 { 653003e1d6626d07e8fc4af95fad95b3a5d4c4af98Richard Smith AssignmentRet1&& operator=(const AssignmentRet1&) = default; // expected-error {{explicitly-defaulted copy assignment operator must return 'copy::AssignmentRet1 &'}} 6674e611a5fd0b5977c664d13a07b625ae23527d0dSebastian Redl }; 6774e611a5fd0b5977c664d13a07b625ae23527d0dSebastian Redl 6874e611a5fd0b5977c664d13a07b625ae23527d0dSebastian Redl struct AssignmentRet2 { 693003e1d6626d07e8fc4af95fad95b3a5d4c4af98Richard Smith const AssignmentRet2& operator=(const AssignmentRet2&) = default; // expected-error {{explicitly-defaulted copy assignment operator must return 'copy::AssignmentRet2 &'}} 7074e611a5fd0b5977c664d13a07b625ae23527d0dSebastian Redl }; 7174e611a5fd0b5977c664d13a07b625ae23527d0dSebastian Redl 7274e611a5fd0b5977c664d13a07b625ae23527d0dSebastian Redl struct ConstAssignment { 7355dec868977ccb89cab0286122f9345f63bb5de7Richard Smith ConstAssignment& operator=(const ConstAssignment&) const = default; // expected-error {{an explicitly-defaulted copy assignment operator may not have 'const', 'constexpr' or 'volatile' qualifiers}} 7474e611a5fd0b5977c664d13a07b625ae23527d0dSebastian Redl }; 7574e611a5fd0b5977c664d13a07b625ae23527d0dSebastian Redl} 76