diff options
author | Alon Zakai <azakai@google.com> | 2021-04-23 09:17:51 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-23 09:17:51 -0700 |
commit | 8b66a9d40f55758b99b528d7adb371d275707c5e (patch) | |
tree | 89b53aa2f1a759312200eef6e8638921dbfc0436 /src | |
parent | b0dd7fe1b82fa7e3696e06cac1daafd5eb54c221 (diff) | |
download | binaryen-8b66a9d40f55758b99b528d7adb371d275707c5e.tar.gz binaryen-8b66a9d40f55758b99b528d7adb371d275707c5e.tar.bz2 binaryen-8b66a9d40f55758b99b528d7adb371d275707c5e.zip |
Fix a new clang warning on implicit Tuple construction (#3841)
Fixes #3838 and current breakage on CI here.
IIUC the warning is that we define a copy assignment operator, but
did not define a copy constructor. Clang wants both to exist now. However,
we delete the copy assignment one, so perhaps we should find a way to
avoid a copy on construction too? That happens here:
../src/wasm/wasm-type.cpp:60:51: note: in implicit copy constructor for 'wasm::Tuple' first required here
TypeInfo(const Tuple& tuple) : kind(TupleKind), tuple(tuple) {}
^
But I don't see an easy way to remove the copy there, so this PR
defines the copy constructor as clang wants.
Diffstat (limited to 'src')
-rw-r--r-- | src/wasm-type.h | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/wasm-type.h b/src/wasm-type.h index def5c7e2b..1b7d389ca 100644 --- a/src/wasm-type.h +++ b/src/wasm-type.h @@ -377,13 +377,17 @@ struct Tuple { Tuple(std::initializer_list<Type> types) : types(types) { validate(); } Tuple(const TypeList& types) : types(types) { validate(); } Tuple(TypeList&& types) : types(std::move(types)) { validate(); } + + // Allow copies when constructing. + Tuple(const Tuple& other) : types(other.types) { validate(); } + + // Prevent accidental copies. + Tuple& operator=(const Tuple&) = delete; + bool operator==(const Tuple& other) const { return types == other.types; } bool operator!=(const Tuple& other) const { return !(*this == other); } std::string toString() const; - // Prevent accidental copies - Tuple& operator=(const Tuple&) = delete; - private: void validate() { #ifndef NDEBUG |