Skip to content

Commit f22ad60

Browse files
committed
Bug 847521 - Allow CheckedInt<signed char> in addition to char/unsigned char. char != signed char (but is guaranteed to have the same representation as either signed char or unsigned char, for backwards-compatibility reasons), so we have to handle signed char as a third character type. r=bjacob
--HG-- rename : content/html/content/src/HTMLObjectElement.h => content/html/content/src/HTMLObjectElement.cpp extra : rebase_source : d07d72b78fcbae31483d726703b3605561295684
1 parent df3c11f commit f22ad60

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

mfbt/CheckedInt.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,10 @@ template<>
104104
struct IsSupportedPass2<char>
105105
{ static const bool value = true; };
106106

107+
template<>
108+
struct IsSupportedPass2<signed char>
109+
{ static const bool value = true; };
110+
107111
template<>
108112
struct IsSupportedPass2<unsigned char>
109113
{ static const bool value = true; };

mfbt/tests/TestCheckedInt.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -413,12 +413,14 @@ void test()
413413
VERIFY_CONSTRUCTION_FROM_INTEGER_TYPE(int64_t)
414414
VERIFY_CONSTRUCTION_FROM_INTEGER_TYPE(uint64_t)
415415

416+
typedef signed char signedChar;
416417
typedef unsigned char unsignedChar;
417418
typedef unsigned short unsignedShort;
418419
typedef unsigned int unsignedInt;
419420
typedef unsigned long unsignedLong;
420421

421422
VERIFY_CONSTRUCTION_FROM_INTEGER_TYPE(char)
423+
VERIFY_CONSTRUCTION_FROM_INTEGER_TYPE(signedChar)
422424
VERIFY_CONSTRUCTION_FROM_INTEGER_TYPE(unsignedChar)
423425
VERIFY_CONSTRUCTION_FROM_INTEGER_TYPE(short)
424426
VERIFY_CONSTRUCTION_FROM_INTEGER_TYPE(unsignedShort)
@@ -470,6 +472,7 @@ int main()
470472
test<uint64_t>();
471473

472474
test<char>();
475+
test<signed char>();
473476
test<unsigned char>();
474477
test<short>();
475478
test<unsigned short>();
@@ -478,9 +481,11 @@ int main()
478481
test<long>();
479482
test<unsigned long>();
480483

481-
if (gIntegerTypesTested < 8) {
484+
const int MIN_TYPES_TESTED = 9;
485+
if (gIntegerTypesTested < MIN_TYPES_TESTED) {
482486
std::cerr << "Only " << gIntegerTypesTested << " have been tested. "
483-
<< "This should not be less than 8." << std::endl;
487+
<< "This should not be less than " << MIN_TYPES_TESTED << "."
488+
<< std::endl;
484489
gTestsFailed++;
485490
}
486491

0 commit comments

Comments
 (0)