| 1 |
#define MOZ_NEEDS_MEMMOVABLE_TYPE __attribute__((annotate("moz_needs_memmovable_type"))) |
| 2 |
#define MOZ_RUNINIT __attribute__((annotate("moz_global_var"))) |
| 3 |
|
| 4 |
template<class T> |
| 5 |
class MOZ_NEEDS_MEMMOVABLE_TYPE Mover { T mForceInst; }; // expected-error-re 9 {{Cannot instantiate 'Mover<{{.*}}>' with non-memmovable template argument '{{.*}}'}} |
| 6 |
|
| 7 |
namespace std { |
| 8 |
// In theory defining things in std:: like this invokes undefined |
| 9 |
// behavior, but in practice it's good enough for this test case. |
| 10 |
template<class C> class basic_string { // expected-note 2 {{'std::basic_string<char>' is a non-memmove()able type because it is an stl-provided type not guaranteed to be memmove-able}} expected-note {{'std::string' (aka 'basic_string<char>') is a non-memmove()able type because it is an stl-provided type not guaranteed to be memmove-able}} |
| 11 |
public: |
| 12 |
basic_string(); |
| 13 |
basic_string(const basic_string&); |
| 14 |
basic_string(basic_string&&); |
| 15 |
basic_string& operator=(const basic_string&); |
| 16 |
basic_string& operator=(basic_string&&); |
| 17 |
~basic_string(); |
| 18 |
}; |
| 19 |
typedef basic_string<char> string; |
| 20 |
template<class T, class U> class pair { T mT; U mU; }; // expected-note-re 4 {{'std::pair<bool, {{.*}}>' is a non-memmove()able type because it has a template argument non-memmove()able type '{{.*}}'}} |
| 21 |
|
| 22 |
struct has_nontrivial_dtor { // expected-note 2 {{'std::has_nontrivial_dtor' is a non-memmove()able type because it is an stl-provided type not guaranteed to be memmove-able}} |
| 23 |
has_nontrivial_dtor() = default; |
| 24 |
~has_nontrivial_dtor(); |
| 25 |
}; |
| 26 |
struct has_nontrivial_copy { // expected-note 2 {{'std::has_nontrivial_copy' is a non-memmove()able type because it is an stl-provided type not guaranteed to be memmove-able}} |
| 27 |
has_nontrivial_copy() = default; |
| 28 |
has_nontrivial_copy(const has_nontrivial_copy&); |
| 29 |
has_nontrivial_copy& operator=(const has_nontrivial_copy&); |
| 30 |
}; |
| 31 |
struct has_nontrivial_move { // expected-note 2 {{'std::has_nontrivial_move' is a non-memmove()able type because it is an stl-provided type not guaranteed to be memmove-able}} |
| 32 |
has_nontrivial_move() = default; |
| 33 |
has_nontrivial_move(const has_nontrivial_move&); |
| 34 |
has_nontrivial_move& operator=(const has_nontrivial_move&); |
| 35 |
}; |
| 36 |
struct has_trivial_dtor { |
| 37 |
has_trivial_dtor() = default; |
| 38 |
~has_trivial_dtor() = default; |
| 39 |
}; |
| 40 |
struct has_trivial_copy { |
| 41 |
has_trivial_copy() = default; |
| 42 |
has_trivial_copy(const has_trivial_copy&) = default; |
| 43 |
has_trivial_copy& operator=(const has_trivial_copy&) = default; |
| 44 |
}; |
| 45 |
struct has_trivial_move { |
| 46 |
has_trivial_move() = default; |
| 47 |
has_trivial_move(const has_trivial_move&) = default; |
| 48 |
has_trivial_move& operator=(const has_trivial_move&) = default; |
| 49 |
}; |
| 50 |
} |
| 51 |
|
| 52 |
class HasString { std::string m; }; // expected-note {{'HasString' is a non-memmove()able type because member 'm' is a non-memmove()able type 'std::string' (aka 'basic_string<char>')}} |
| 53 |
|
| 54 |
MOZ_RUNINIT static Mover<std::string> bad; // expected-note-re {{instantiation of 'Mover<std::basic_string<char>{{ ?}}>' requested here}} |
| 55 |
MOZ_RUNINIT static Mover<HasString> bad_mem; // expected-note {{instantiation of 'Mover<HasString>' requested here}} |
| 56 |
static Mover<std::pair<bool, int>> good; |
| 57 |
MOZ_RUNINIT static Mover<std::pair<bool, std::string>> not_good; // expected-note-re {{instantiation of 'Mover<std::pair<bool, std::basic_string<char>{{ ?}}>{{ ?}}>' requested here}} |
| 58 |
|
| 59 |
MOZ_RUNINIT static Mover<std::has_nontrivial_dtor> nontrivial_dtor; // expected-note {{instantiation of 'Mover<std::has_nontrivial_dtor>' requested here}} |
| 60 |
static Mover<std::has_nontrivial_copy> nontrivial_copy; // expected-note {{instantiation of 'Mover<std::has_nontrivial_copy>' requested here}} |
| 61 |
static Mover<std::has_nontrivial_move> nontrivial_move; // expected-note {{instantiation of 'Mover<std::has_nontrivial_move>' requested here}} |
| 62 |
static Mover<std::has_trivial_dtor> trivial_dtor; |
| 63 |
static Mover<std::has_trivial_copy> trivial_copy; |
| 64 |
static Mover<std::has_trivial_move> trivial_move; |
| 65 |
|
| 66 |
MOZ_RUNINIT static Mover<std::pair<bool, std::has_nontrivial_dtor>> pair_nontrivial_dtor; // expected-note {{instantiation of 'Mover<std::pair<bool, std::has_nontrivial_dtor>>' requested here}} |
| 67 |
static Mover<std::pair<bool, std::has_nontrivial_copy>> pair_nontrivial_copy; // expected-note {{instantiation of 'Mover<std::pair<bool, std::has_nontrivial_copy>>' requested here}} |
| 68 |
static Mover<std::pair<bool, std::has_nontrivial_move>> pair_nontrivial_move; // expected-note {{instantiation of 'Mover<std::pair<bool, std::has_nontrivial_move>>' requested here}} |
| 69 |
static Mover<std::pair<bool, std::has_trivial_dtor>> pair_trivial_dtor; |
| 70 |
static Mover<std::pair<bool, std::has_trivial_copy>> pair_trivial_copy; |
| 71 |
static Mover<std::pair<bool, std::has_trivial_move>> pair_trivial_move; |