diff options
| author | Sebastian Redl <sebastian.redl@getdesigned.at> | 2011-09-04 18:14:28 +0000 |
|---|---|---|
| committer | Sebastian Redl <sebastian.redl@getdesigned.at> | 2011-09-04 18:14:28 +0000 |
| commit | e9c4e84f8ea7a8245b1cbb44e158cf0b8d29eb28 (patch) | |
| tree | ff41d2a78044b2de8fc64426eb322c1e13eb5d3f /clang/test | |
| parent | c92151516f4630a2cabcb9b8e5edbd565e16a219 (diff) | |
| download | bcm5719-llvm-e9c4e84f8ea7a8245b1cbb44e158cf0b8d29eb28.tar.gz bcm5719-llvm-e9c4e84f8ea7a8245b1cbb44e158cf0b8d29eb28.zip | |
Add test case for defaulted copy and move structure validation.
Fix bug this uncovered.
Address minor comments from Doug.
Enable cxx_implicit_moves feature.
llvm-svn: 139101
Diffstat (limited to 'clang/test')
| -rw-r--r-- | clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct/dcl.fct.def.default/p2.cpp | 62 | ||||
| -rw-r--r-- | clang/test/Lexer/has_feature_cxx0x.cpp | 9 |
2 files changed, 71 insertions, 0 deletions
diff --git a/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct/dcl.fct.def.default/p2.cpp b/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct/dcl.fct.def.default/p2.cpp new file mode 100644 index 00000000000..6b964dba31c --- /dev/null +++ b/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct/dcl.fct.def.default/p2.cpp @@ -0,0 +1,62 @@ +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++0x %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 {{an explicitly-defaulted move assignment operator must return an unqualified lvalue reference to its class type}} + }; + + struct AssignmentRet2 { + const AssignmentRet2& operator=(AssignmentRet2&&) = default; // expected-error {{an explicitly-defaulted move assignment operator must return an unqualified lvalue reference to its class type}} + }; + + struct ConstAssignment { + ConstAssignment& operator=(ConstAssignment&&) const = default; // expected-error {{an explicitly-defaulted move assignment operator may not have 'const' 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 BadConst { + NonConst nc; // makes implicit copy non-const + BadConst(const BadConst&) = default; // expected-error {{is const, but}} + BadConst& operator=(const BadConst&) = default; // expected-error {{is const, but}} + }; + + struct AssignmentRet1 { + AssignmentRet1&& operator=(const AssignmentRet1&) = default; // expected-error {{an explicitly-defaulted copy assignment operator must return an unqualified lvalue reference to its class type}} + }; + + struct AssignmentRet2 { + const AssignmentRet2& operator=(const AssignmentRet2&) = default; // expected-error {{an explicitly-defaulted copy assignment operator must return an unqualified lvalue reference to its class type}} + }; + + struct ConstAssignment { + ConstAssignment& operator=(const ConstAssignment&) const = default; // expected-error {{an explicitly-defaulted copy assignment operator may not have 'const' or 'volatile' qualifiers}} + }; +} diff --git a/clang/test/Lexer/has_feature_cxx0x.cpp b/clang/test/Lexer/has_feature_cxx0x.cpp index ca5f868d9b0..76254303848 100644 --- a/clang/test/Lexer/has_feature_cxx0x.cpp +++ b/clang/test/Lexer/has_feature_cxx0x.cpp @@ -164,3 +164,12 @@ int no_alias_templates(); // CHECK-0X: has_alias_templates // CHECK-NO-0X: no_alias_templates + +#if __has_feature(cxx_implicit_moves) +int has_implicit_moves(); +#else +int no_implicit_moves(); +#endif + +// CHECK-0X: has_implicit_moves +// CHECK-NO-0X: no_implicit_moves |

