From 3508dd19c872f4f409e6fcf395725fa57e594cc7 Mon Sep 17 00:00:00 2001 From: Ehsan Akhgari Date: Tue, 5 Aug 2014 09:21:12 -0400 Subject: [PATCH] Bug 1048013 - Fix some bad implicit constructors in MFBT; r=froydnj --- mfbt/WeakPtr.h | 2 +- mfbt/tests/TestPair.cpp | 10 +++++----- mfbt/tests/TestSplayTree.cpp | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/mfbt/WeakPtr.h b/mfbt/WeakPtr.h index ebcb9250674..58960ad6177 100644 --- a/mfbt/WeakPtr.h +++ b/mfbt/WeakPtr.h @@ -183,7 +183,7 @@ public: return *this = aOther->SelfReferencingWeakPtr(); } - WeakPtr(T* aOther) + MOZ_IMPLICIT WeakPtr(T* aOther) { *this = aOther; } diff --git a/mfbt/tests/TestPair.cpp b/mfbt/tests/TestPair.cpp index 37aa2c69410..940174df0f3 100644 --- a/mfbt/tests/TestPair.cpp +++ b/mfbt/tests/TestPair.cpp @@ -29,21 +29,21 @@ using mozilla::Pair; INSTANTIATE(int, int, prim1, 2 * sizeof(int)); INSTANTIATE(int, long, prim2, 2 * sizeof(long)); -struct EmptyClass { EmptyClass(int) {} }; -struct NonEmpty { char mC; NonEmpty(int) {} }; +struct EmptyClass { explicit EmptyClass(int) {} }; +struct NonEmpty { char mC; explicit NonEmpty(int) {} }; INSTANTIATE(int, EmptyClass, both1, sizeof(int)); INSTANTIATE(int, NonEmpty, both2, 2 * sizeof(int)); INSTANTIATE(EmptyClass, NonEmpty, both3, 1); -struct A { char dummy; A(int) {} }; -struct B : A { B(int aI) : A(aI) {} }; +struct A { char dummy; explicit A(int) {} }; +struct B : A { explicit B(int aI) : A(aI) {} }; INSTANTIATE(A, A, class1, 2); INSTANTIATE(A, B, class2, 2); INSTANTIATE(A, EmptyClass, class3, 1); -struct OtherEmpty : EmptyClass { OtherEmpty(int aI) : EmptyClass(aI) {} }; +struct OtherEmpty : EmptyClass { explicit OtherEmpty(int aI) : EmptyClass(aI) {} }; // C++11 requires distinct objects of the same type, within the same "most // derived object", to have different addresses. Pair allocates its elements as diff --git a/mfbt/tests/TestSplayTree.cpp b/mfbt/tests/TestSplayTree.cpp index b49371f3237..e1511e1abe0 100644 --- a/mfbt/tests/TestSplayTree.cpp +++ b/mfbt/tests/TestSplayTree.cpp @@ -89,7 +89,7 @@ static int gValues[] = { struct SplayInt : SplayTreeNode { - SplayInt(int aValue) : mValue(aValue) {} + explicit SplayInt(int aValue) : mValue(aValue) {} static int compare(const SplayInt& aOne, const SplayInt& aTwo) {