Bug 895322 - Part 1: Replace the usages of MOZ_STATIC_ASSERT with C++11 static_assert; r=Waldo

This patch was mostly generated by running the following scripts on the codebase, with some
manual changes made afterwards:

# static_assert.sh
#!/bin/bash
# Command to convert an NSPR integer type to the equivalent standard integer type

function convert() {
echo "Converting $1 to $2..."
find . ! -wholename "*nsprpub*" \
       ! -wholename "*security/nss*" \
       ! -wholename "*/.hg*" \
       ! -wholename "obj-ff-dbg*" \
       ! -name nsXPCOMCID.h \
       ! -name prtypes.h \
         -type f \
      \( -iname "*.cpp" \
         -o -iname "*.h" \
         -o -iname "*.cc" \
         -o -iname "*.mm" \) | \
    xargs -n 1 `dirname $0`/assert_replacer.py #sed -i -e "s/\b$1\b/$2/g"
}

convert MOZ_STATIC_ASSERT static_assert
hg rev --no-backup mfbt/Assertions.h \
                   media/webrtc/signaling/src/sipcc/core/includes/ccapi.h \
                   modules/libmar/src/mar_private.h \
                   modules/libmar/src/mar.h


# assert_replacer.py
#!/usr/bin/python

import sys
import re

pattern = re.compile(r"\bMOZ_STATIC_ASSERT\b")

def replaceInPlace(fname):
  print fname
  f = open(fname, "rw+")
  lines = f.readlines()
  for i in range(0, len(lines)):
    while True:
      index = re.search(pattern, lines[i])
      if index != None:
        index = index.start()
        lines[i] = lines[i][0:index] + "static_assert" + lines[i][index+len("MOZ_STATIC_ASSERT"):]
        for j in range(i + 1, len(lines)):
          if lines[j].find("                 ", index) == index:
            lines[j] = lines[j][0:index] + lines[j][index+4:]
          else:
            break
      else:
        break
  f.seek(0, 0)
  f.truncate()
  f.write("".join(lines))
  f.close()

argc = len(sys.argv)
for i in range(1, argc):
  replaceInPlace(sys.argv[i])

--HG--
extra : rebase_source : 4b4a4047d82f2c205b9fad8d56dfc3f1afc0b045
This commit is contained in:
Ehsan Akhgari 2013-07-18 13:59:53 -04:00
parent 97899ea185
commit 5ee21d6d3f
111 changed files with 573 additions and 574 deletions

View File

@ -12,8 +12,8 @@
using namespace mozilla::a11y;
#define ROLE(geckoRole, stringRole, atkRole, macRole, msaaRole, ia2Role, nameRule) \
MOZ_STATIC_ASSERT(static_cast<uint32_t>(roles::geckoRole) \
== static_cast<uint32_t>(nsIAccessibleRole::ROLE_ ## geckoRole), \
"internal and xpcom roles differ!");
static_assert(static_cast<uint32_t>(roles::geckoRole) \
== static_cast<uint32_t>(nsIAccessibleRole::ROLE_ ## geckoRole), \
"internal and xpcom roles differ!");
#include "RoleMap.h"
#undef ROLE

View File

@ -3353,14 +3353,14 @@ Accessible::GetLevelInternal()
void
Accessible::StaticAsserts() const
{
MOZ_STATIC_ASSERT(eLastChildrenFlag <= (2 << kChildrenFlagsBits) - 1,
"Accessible::mChildrenFlags was oversized by eLastChildrenFlag!");
MOZ_STATIC_ASSERT(eLastStateFlag <= (2 << kStateFlagsBits) - 1,
"Accessible::mStateFlags was oversized by eLastStateFlag!");
MOZ_STATIC_ASSERT(eLastAccType <= (2 << kTypeBits) - 1,
"Accessible::mType was oversized by eLastAccType!");
MOZ_STATIC_ASSERT(eLastAccGenericType <= (2 << kGenericTypesBits) - 1,
"Accessible::mGenericType was oversized by eLastAccGenericType!");
static_assert(eLastChildrenFlag <= (2 << kChildrenFlagsBits) - 1,
"Accessible::mChildrenFlags was oversized by eLastChildrenFlag!");
static_assert(eLastStateFlag <= (2 << kStateFlagsBits) - 1,
"Accessible::mStateFlags was oversized by eLastStateFlag!");
static_assert(eLastAccType <= (2 << kTypeBits) - 1,
"Accessible::mType was oversized by eLastAccType!");
static_assert(eLastAccGenericType <= (2 << kGenericTypesBits) - 1,
"Accessible::mGenericType was oversized by eLastAccGenericType!");
}

View File

@ -1617,8 +1617,8 @@ AccessibleWrap::HandleAccEvent(AccEvent* aEvent)
uint32_t eventType = aEvent->GetEventType();
MOZ_STATIC_ASSERT(sizeof(gWinEventMap)/sizeof(gWinEventMap[0]) == nsIAccessibleEvent::EVENT_LAST_ENTRY,
"MSAA event map skewed");
static_assert(sizeof(gWinEventMap)/sizeof(gWinEventMap[0]) == nsIAccessibleEvent::EVENT_LAST_ENTRY,
"MSAA event map skewed");
NS_ENSURE_TRUE(eventType > 0 && eventType < ArrayLength(gWinEventMap), NS_ERROR_FAILURE);

View File

@ -2322,9 +2322,9 @@ nsScriptSecurityManager::nsScriptSecurityManager(void)
mIsJavaScriptEnabled(false),
mPolicyPrefsChanged(true)
{
MOZ_STATIC_ASSERT(sizeof(intptr_t) == sizeof(void*),
"intptr_t and void* have different lengths on this platform. "
"This may cause a security failure with the SecurityLevel union.");
static_assert(sizeof(intptr_t) == sizeof(void*),
"intptr_t and void* have different lengths on this platform. "
"This may cause a security failure with the SecurityLevel union.");
}
nsresult nsScriptSecurityManager::Init()

View File

@ -237,9 +237,9 @@ nsMixedContentBlocker::ShouldLoad(uint32_t aContentType,
// amplifies these concerns.
MOZ_STATIC_ASSERT(TYPE_DATAREQUEST == TYPE_XMLHTTPREQUEST,
"TYPE_DATAREQUEST is not a synonym for "
"TYPE_XMLHTTPREQUEST");
static_assert(TYPE_DATAREQUEST == TYPE_XMLHTTPREQUEST,
"TYPE_DATAREQUEST is not a synonym for "
"TYPE_XMLHTTPREQUEST");
switch (aContentType) {
// The top-level document cannot be mixed content by definition

View File

@ -865,7 +865,7 @@ void
nsXMLHttpRequest::StaticAssertions()
{
#define ASSERT_ENUM_EQUAL(_lc, _uc) \
MOZ_STATIC_ASSERT(\
static_assert(\
static_cast<int>(XMLHttpRequestResponseType::_lc) \
== XML_HTTP_RESPONSE_TYPE_ ## _uc, \
#_uc " should match")

View File

@ -128,8 +128,8 @@ template<typename T>
void CheckUintOverflow()
{
// This test is only for integer types smaller than uint32_t
MOZ_STATIC_ASSERT(sizeof(T) < sizeof(uint32_t), "This test is only for integer types \
smaller than uint32_t");
static_assert(sizeof(T) < sizeof(uint32_t), "This test is only for integer types \
smaller than uint32_t");
const size_t numElems = 64; // should be significantly larger than tree leaf size to
// ensure we exercise some nontrivial tree-walking

View File

@ -157,8 +157,8 @@ inline const void*
AddAudioSampleOffset(const void* aBase, AudioSampleFormat aFormat,
int32_t aOffset)
{
MOZ_STATIC_ASSERT(AUDIO_FORMAT_S16 == 0, "Bad constant");
MOZ_STATIC_ASSERT(AUDIO_FORMAT_FLOAT32 == 1, "Bad constant");
static_assert(AUDIO_FORMAT_S16 == 0, "Bad constant");
static_assert(AUDIO_FORMAT_FLOAT32 == 1, "Bad constant");
NS_ASSERTION(aFormat == AUDIO_FORMAT_S16 || aFormat == AUDIO_FORMAT_FLOAT32,
"Unknown format");

View File

@ -184,10 +184,10 @@ struct WebAudioUtils {
{
using namespace std;
MOZ_STATIC_ASSERT((mozilla::IsIntegral<IntType>::value == true),
"IntType must be an integral type");
MOZ_STATIC_ASSERT((mozilla::IsFloatingPoint<FloatType>::value == true),
"FloatType must be a floating point type");
static_assert(mozilla::IsIntegral<IntType>::value == true,
"IntType must be an integral type");
static_assert(mozilla::IsFloatingPoint<FloatType>::value == true,
"FloatType must be a floating point type");
if (f != f) {
// It is the responsibility of the caller to deal with NaN values.

View File

@ -140,7 +140,7 @@ void TestSpecExample()
void TestInvalidEvents()
{
MOZ_STATIC_ASSERT(numeric_limits<float>::has_quiet_NaN, "Platform must have a quiet NaN");
static_assert(numeric_limits<float>::has_quiet_NaN, "Platform must have a quiet NaN");
const float NaN = numeric_limits<float>::quiet_NaN();
const float Infinity = numeric_limits<float>::infinity();
Timeline timeline(10.0f);

View File

@ -156,9 +156,9 @@ DoMorphology(nsSVGFilterInstance* instance,
int32_t rx,
int32_t ry)
{
MOZ_STATIC_ASSERT(Operator == SVG_OPERATOR_ERODE ||
Operator == SVG_OPERATOR_DILATE,
"unexpected morphology operator");
static_assert(Operator == SVG_OPERATOR_ERODE ||
Operator == SVG_OPERATOR_DILATE,
"unexpected morphology operator");
volatile uint8_t extrema[4]; // RGBA magnitude of extrema

View File

@ -61,21 +61,21 @@ AudioChannelAgent::InitInternal(int32_t aChannelType,
{
// We syncd the enum of channel type between nsIAudioChannelAgent.idl and
// AudioChannelCommon.h the same.
MOZ_STATIC_ASSERT(static_cast<AudioChannelType>(AUDIO_AGENT_CHANNEL_NORMAL) ==
AUDIO_CHANNEL_NORMAL &&
static_cast<AudioChannelType>(AUDIO_AGENT_CHANNEL_CONTENT) ==
AUDIO_CHANNEL_CONTENT &&
static_cast<AudioChannelType>(AUDIO_AGENT_CHANNEL_NOTIFICATION) ==
AUDIO_CHANNEL_NOTIFICATION &&
static_cast<AudioChannelType>(AUDIO_AGENT_CHANNEL_ALARM) ==
AUDIO_CHANNEL_ALARM &&
static_cast<AudioChannelType>(AUDIO_AGENT_CHANNEL_TELEPHONY) ==
AUDIO_CHANNEL_TELEPHONY &&
static_cast<AudioChannelType>(AUDIO_AGENT_CHANNEL_RINGER) ==
AUDIO_CHANNEL_RINGER &&
static_cast<AudioChannelType>(AUDIO_AGENT_CHANNEL_PUBLICNOTIFICATION) ==
AUDIO_CHANNEL_PUBLICNOTIFICATION,
"Enum of channel on nsIAudioChannelAgent.idl should be the same with AudioChannelCommon.h");
static_assert(static_cast<AudioChannelType>(AUDIO_AGENT_CHANNEL_NORMAL) ==
AUDIO_CHANNEL_NORMAL &&
static_cast<AudioChannelType>(AUDIO_AGENT_CHANNEL_CONTENT) ==
AUDIO_CHANNEL_CONTENT &&
static_cast<AudioChannelType>(AUDIO_AGENT_CHANNEL_NOTIFICATION) ==
AUDIO_CHANNEL_NOTIFICATION &&
static_cast<AudioChannelType>(AUDIO_AGENT_CHANNEL_ALARM) ==
AUDIO_CHANNEL_ALARM &&
static_cast<AudioChannelType>(AUDIO_AGENT_CHANNEL_TELEPHONY) ==
AUDIO_CHANNEL_TELEPHONY &&
static_cast<AudioChannelType>(AUDIO_AGENT_CHANNEL_RINGER) ==
AUDIO_CHANNEL_RINGER &&
static_cast<AudioChannelType>(AUDIO_AGENT_CHANNEL_PUBLICNOTIFICATION) ==
AUDIO_CHANNEL_PUBLICNOTIFICATION,
"Enum of channel on nsIAudioChannelAgent.idl should be the same with AudioChannelCommon.h");
if (mAudioChannelType != AUDIO_AGENT_CHANNEL_ERROR ||
aChannelType > AUDIO_AGENT_CHANNEL_PUBLICNOTIFICATION ||

View File

@ -1220,9 +1220,9 @@ nsDOMClassInfo::Init()
{
/* Errors that can trigger early returns are done first,
otherwise nsDOMClassInfo is left in a half inited state. */
MOZ_STATIC_ASSERT(sizeof(uintptr_t) == sizeof(void*),
"BAD! You'll need to adjust the size of uintptr_t to the "
"size of a pointer on your platform.");
static_assert(sizeof(uintptr_t) == sizeof(void*),
"BAD! You'll need to adjust the size of uintptr_t to the "
"size of a pointer on your platform.");
NS_ENSURE_TRUE(!sIsInitialized, NS_ERROR_ALREADY_INITIALIZED);
@ -1686,9 +1686,9 @@ nsDOMClassInfo::Init()
DOM_CLASSINFO_MAP_ENTRY(nsIDOMXULPopupElement)
DOM_CLASSINFO_MAP_END
MOZ_STATIC_ASSERT(MOZ_ARRAY_LENGTH(sClassInfoData) == eDOMClassInfoIDCount,
"The number of items in sClassInfoData doesn't match the "
"number of nsIDOMClassInfo ID's, this is bad! Fix it!");
static_assert(MOZ_ARRAY_LENGTH(sClassInfoData) == eDOMClassInfoIDCount,
"The number of items in sClassInfoData doesn't match the "
"number of nsIDOMClassInfo ID's, this is bad! Fix it!");
#ifdef DEBUG
for (size_t i = 0; i < eDOMClassInfoIDCount; i++) {

View File

@ -1985,13 +1985,13 @@ ConvertJSValueToByteString(JSContext* cx, JS::Handle<JS::Value> v,
// The largest unsigned 64 bit number (18,446,744,073,709,551,615) has
// 20 digits, plus one more for the null terminator.
char index[21];
MOZ_STATIC_ASSERT(sizeof(size_t) <= 8, "index array too small");
static_assert(sizeof(size_t) <= 8, "index array too small");
PR_snprintf(index, sizeof(index), "%d", i);
// A jschar is 16 bits long. The biggest unsigned 16 bit
// number (65,535) has 5 digits, plus one more for the null
// terminator.
char badChar[6];
MOZ_STATIC_ASSERT(sizeof(jschar) <= 2, "badChar array too small");
static_assert(sizeof(jschar) <= 2, "badChar array too small");
PR_snprintf(badChar, sizeof(badChar), "%d", chars[i]);
ThrowErrorMessage(cx, MSG_INVALID_BYTESTRING, index, badChar);
return false;

View File

@ -131,9 +131,9 @@ IsDOMIfaceAndProtoClass(const js::Class* clasp)
return IsDOMIfaceAndProtoClass(Jsvalify(clasp));
}
MOZ_STATIC_ASSERT(DOM_OBJECT_SLOT == js::PROXY_PRIVATE_SLOT,
"js::PROXY_PRIVATE_SLOT doesn't match DOM_OBJECT_SLOT. "
"Expect bad things");
static_assert(DOM_OBJECT_SLOT == js::PROXY_PRIVATE_SLOT,
"js::PROXY_PRIVATE_SLOT doesn't match DOM_OBJECT_SLOT. "
"Expect bad things");
template <class T>
inline T*
UnwrapDOMObject(JSObject* obj)
@ -269,9 +269,9 @@ UnwrapObject(JSContext* cx, JSObject* obj, U& value)
// The items in the protoAndIfaceArray are indexed by the prototypes::id::ID and
// constructors::id::ID enums, in that order. The end of the prototype objects
// should be the start of the interface objects.
MOZ_STATIC_ASSERT((size_t)constructors::id::_ID_Start ==
(size_t)prototypes::id::_ID_Count,
"Overlapping or discontiguous indexes.");
static_assert((size_t)constructors::id::_ID_Start ==
(size_t)prototypes::id::_ID_Count,
"Overlapping or discontiguous indexes.");
const size_t kProtoAndIfaceCacheCount = constructors::id::_ID_Count;
inline void
@ -1527,17 +1527,17 @@ private:
class DepedentStringAsserter : public nsDependentString {
public:
static void StaticAsserts() {
MOZ_STATIC_ASSERT(sizeof(FakeDependentString) == sizeof(nsDependentString),
"Must have right object size");
MOZ_STATIC_ASSERT(offsetof(FakeDependentString, mData) ==
offsetof(DepedentStringAsserter, mData),
"Offset of mData should match");
MOZ_STATIC_ASSERT(offsetof(FakeDependentString, mLength) ==
offsetof(DepedentStringAsserter, mLength),
"Offset of mLength should match");
MOZ_STATIC_ASSERT(offsetof(FakeDependentString, mFlags) ==
offsetof(DepedentStringAsserter, mFlags),
"Offset of mFlags should match");
static_assert(sizeof(FakeDependentString) == sizeof(nsDependentString),
"Must have right object size");
static_assert(offsetof(FakeDependentString, mData) ==
offsetof(DepedentStringAsserter, mData),
"Offset of mData should match");
static_assert(offsetof(FakeDependentString, mLength) ==
offsetof(DepedentStringAsserter, mLength),
"Offset of mLength should match");
static_assert(offsetof(FakeDependentString, mFlags) ==
offsetof(DepedentStringAsserter, mFlags),
"Offset of mFlags should match");
}
};
};

View File

@ -50,9 +50,9 @@ class nsCycleCollectionParticipant;
// slot for the unforgeable holder is needed.
#define DOM_INTERFACE_PROTO_SLOTS_BASE (DOM_XRAY_EXPANDO_SLOT + 1)
MOZ_STATIC_ASSERT(DOM_PROTO_INSTANCE_CLASS_SLOT != DOM_XRAY_EXPANDO_SLOT,
"Interface prototype object use both of these, so they must "
"not be the same slot.");
static_assert(DOM_PROTO_INSTANCE_CLASS_SLOT != DOM_XRAY_EXPANDO_SLOT,
"Interface prototype object use both of these, so they must "
"not be the same slot.");
namespace mozilla {
namespace dom {

View File

@ -224,8 +224,8 @@ template<typename T>
inline bool
PrimitiveConversionTraits_EnforceRange(JSContext* cx, const double& d, T* retval)
{
MOZ_STATIC_ASSERT(std::numeric_limits<T>::is_integer,
"This can only be applied to integers!");
static_assert(std::numeric_limits<T>::is_integer,
"This can only be applied to integers!");
if (!mozilla::IsFinite(d)) {
return ThrowErrorMessage(cx, MSG_ENFORCE_RANGE_NON_FINITE, TypeName<T>::value());
@ -252,8 +252,8 @@ template<typename T>
inline bool
PrimitiveConversionTraits_Clamp(JSContext* cx, const double& d, T* retval)
{
MOZ_STATIC_ASSERT(std::numeric_limits<T>::is_integer,
"This can only be applied to integers!");
static_assert(std::numeric_limits<T>::is_integer,
"This can only be applied to integers!");
if (mozilla::IsNaN(d)) {
*retval = 0;

View File

@ -795,7 +795,7 @@ static DBusCallback sBluetoothDBusPropCallbacks[] =
GetDevicePropertiesCallback
};
MOZ_STATIC_ASSERT(
static_assert(
sizeof(sBluetoothDBusPropCallbacks) == sizeof(sBluetoothDBusIfaces),
"DBus Property callback array and DBus interface array must be same size");

View File

@ -32,9 +32,9 @@
USING_INDEXEDDB_NAMESPACE
using namespace mozilla::dom::indexedDB::ipc;
MOZ_STATIC_ASSERT(sizeof(size_t) >= sizeof(IDBCursor::Direction),
"Relying on conversion between size_t and "
"IDBCursor::Direction");
static_assert(sizeof(size_t) >= sizeof(IDBCursor::Direction),
"Relying on conversion between size_t and "
"IDBCursor::Direction");
namespace {

View File

@ -1331,8 +1331,8 @@ bool
IDBObjectStore::ReadFileHandle(JSStructuredCloneReader* aReader,
FileHandleData* aRetval)
{
MOZ_STATIC_ASSERT(SCTAG_DOM_FILEHANDLE == 0xFFFF8004,
"Update me!");
static_assert(SCTAG_DOM_FILEHANDLE == 0xFFFF8004,
"Update me!");
MOZ_ASSERT(aReader && aRetval);
nsCString type;
@ -1356,10 +1356,10 @@ IDBObjectStore::ReadBlobOrFile(JSStructuredCloneReader* aReader,
uint32_t aTag,
BlobOrFileData* aRetval)
{
MOZ_STATIC_ASSERT(SCTAG_DOM_BLOB == 0xFFFF8001 &&
SCTAG_DOM_FILE_WITHOUT_LASTMODIFIEDDATE == 0xFFFF8002 &&
SCTAG_DOM_FILE == 0xFFFF8005,
"Update me!");
static_assert(SCTAG_DOM_BLOB == 0xFFFF8001 &&
SCTAG_DOM_FILE_WITHOUT_LASTMODIFIEDDATE == 0xFFFF8002 &&
SCTAG_DOM_FILE == 0xFFFF8005,
"Update me!");
MOZ_ASSERT(aReader && aRetval);
MOZ_ASSERT(aTag == SCTAG_DOM_FILE ||
aTag == SCTAG_DOM_FILE_WITHOUT_LASTMODIFIEDDATE ||
@ -1417,12 +1417,12 @@ IDBObjectStore::StructuredCloneReadCallback(JSContext* aCx,
{
// We need to statically assert that our tag values are what we expect
// so that if people accidentally change them they notice.
MOZ_STATIC_ASSERT(SCTAG_DOM_BLOB == 0xFFFF8001 &&
SCTAG_DOM_FILE_WITHOUT_LASTMODIFIEDDATE == 0xFFFF8002 &&
SCTAG_DOM_FILEHANDLE == 0xFFFF8004 &&
SCTAG_DOM_FILE == 0xFFFF8005,
"You changed our structured clone tag values and just ate "
"everyone's IndexedDB data. I hope you are happy.");
static_assert(SCTAG_DOM_BLOB == 0xFFFF8001 &&
SCTAG_DOM_FILE_WITHOUT_LASTMODIFIEDDATE == 0xFFFF8002 &&
SCTAG_DOM_FILEHANDLE == 0xFFFF8004 &&
SCTAG_DOM_FILE == 0xFFFF8005,
"You changed our structured clone tag values and just ate "
"everyone's IndexedDB data. I hope you are happy.");
if (aTag == SCTAG_DOM_FILE_WITHOUT_LASTMODIFIEDDATE ||
aTag == SCTAG_DOM_FILEHANDLE ||

View File

@ -106,8 +106,8 @@ Key::EncodeJSValInternal(JSContext* aCx, const jsval aVal,
{
NS_ENSURE_TRUE(aRecursionDepth < MaxRecursionDepth, NS_ERROR_DOM_INDEXEDDB_DATA_ERR);
MOZ_STATIC_ASSERT(eMaxType * MaxArrayCollapse < 256,
"Unable to encode jsvals.");
static_assert(eMaxType * MaxArrayCollapse < 256,
"Unable to encode jsvals.");
if (JSVAL_IS_STRING(aVal)) {
nsDependentJSString str;

View File

@ -34,8 +34,8 @@ namespace {
// If JS_STRUCTURED_CLONE_VERSION changes then we need to update our major
// schema version.
MOZ_STATIC_ASSERT(JS_STRUCTURED_CLONE_VERSION == 2,
"Need to update the major schema version.");
static_assert(JS_STRUCTURED_CLONE_VERSION == 2,
"Need to update the major schema version.");
// Major schema version. Bump for almost everything.
const uint32_t kMajorSchemaVersion = 14;
@ -47,10 +47,10 @@ const uint32_t kMinorSchemaVersion = 0;
// The schema version we store in the SQLite database is a (signed) 32-bit
// integer. The major version is left-shifted 4 bits so the max value is
// 0xFFFFFFF. The minor version occupies the lower 4 bits and its max is 0xF.
MOZ_STATIC_ASSERT(kMajorSchemaVersion <= 0xFFFFFFF,
"Major version needs to fit in 28 bits.");
MOZ_STATIC_ASSERT(kMinorSchemaVersion <= 0xF,
"Minor version needs to fit in 4 bits.");
static_assert(kMajorSchemaVersion <= 0xFFFFFFF,
"Major version needs to fit in 28 bits.");
static_assert(kMinorSchemaVersion <= 0xF,
"Minor version needs to fit in 4 bits.");
inline
int32_t
@ -1981,8 +1981,8 @@ OpenDatabaseHelper::CreateDatabaseConnection(
}
else {
// This logic needs to change next time we change the schema!
MOZ_STATIC_ASSERT(kSQLiteSchemaVersion == int32_t((14 << 4) + 0),
"Need upgrade code from schema version increase.");
static_assert(kSQLiteSchemaVersion == int32_t((14 << 4) + 0),
"Need upgrade code from schema version increase.");
while (schemaVersion != kSQLiteSchemaVersion) {
if (schemaVersion == 4) {

View File

@ -364,8 +364,8 @@ inline
already_AddRefed<nsIDOMBlob>
GetBlobFromParams(const SlicedBlobConstructorParams& aParams)
{
MOZ_STATIC_ASSERT(ActorFlavor == mozilla::dom::ipc::Parent,
"No other flavor is supported here!");
static_assert(ActorFlavor == mozilla::dom::ipc::Parent,
"No other flavor is supported here!");
BlobParent* actor =
const_cast<BlobParent*>(

View File

@ -383,9 +383,9 @@ nsPluginTag::GetPluginState()
void
nsPluginTag::SetPluginState(PluginState state)
{
MOZ_STATIC_ASSERT((uint32_t)nsPluginTag::ePluginState_Disabled == nsIPluginTag::STATE_DISABLED, "nsPluginTag::ePluginState_Disabled must match nsIPluginTag::STATE_DISABLED");
MOZ_STATIC_ASSERT((uint32_t)nsPluginTag::ePluginState_Clicktoplay == nsIPluginTag::STATE_CLICKTOPLAY, "nsPluginTag::ePluginState_Clicktoplay must match nsIPluginTag::STATE_CLICKTOPLAY");
MOZ_STATIC_ASSERT((uint32_t)nsPluginTag::ePluginState_Enabled == nsIPluginTag::STATE_ENABLED, "nsPluginTag::ePluginState_Enabled must match nsIPluginTag::STATE_ENABLED");
static_assert((uint32_t)nsPluginTag::ePluginState_Disabled == nsIPluginTag::STATE_DISABLED, "nsPluginTag::ePluginState_Disabled must match nsIPluginTag::STATE_DISABLED");
static_assert((uint32_t)nsPluginTag::ePluginState_Clicktoplay == nsIPluginTag::STATE_CLICKTOPLAY, "nsPluginTag::ePluginState_Clicktoplay must match nsIPluginTag::STATE_CLICKTOPLAY");
static_assert((uint32_t)nsPluginTag::ePluginState_Enabled == nsIPluginTag::STATE_ENABLED, "nsPluginTag::ePluginState_Enabled must match nsIPluginTag::STATE_ENABLED");
SetEnabledState((uint32_t)state);
}

View File

@ -483,8 +483,8 @@ QuotaManager::Init()
mCheckQuotaHelpers.Init();
mLiveStorages.Init();
MOZ_STATIC_ASSERT(Client::IDB == 0 && Client::TYPE_MAX == 1,
"Fix the registration!");
static_assert(Client::IDB == 0 && Client::TYPE_MAX == 1,
"Fix the registration!");
NS_ASSERTION(mClients.Capacity() == Client::TYPE_MAX,
"Should be using an auto array with correct capacity!");

View File

@ -677,7 +677,7 @@ DOMStorageDBThread::TimeUntilFlush()
return 0; // Do it now regardless the timeout.
}
MOZ_STATIC_ASSERT(PR_INTERVAL_NO_TIMEOUT != 0,
static_assert(PR_INTERVAL_NO_TIMEOUT != 0,
"PR_INTERVAL_NO_TIMEOUT must be non-zero");
if (!mDirtyEpoch) {

View File

@ -67,8 +67,8 @@ using mozilla::Preferences;
// The maximum number of threads to use for workers, overridable via pref.
#define MAX_WORKERS_PER_DOMAIN 10
MOZ_STATIC_ASSERT(MAX_WORKERS_PER_DOMAIN >= 1,
"We should allow at least one worker per domain.");
static_assert(MAX_WORKERS_PER_DOMAIN >= 1,
"We should allow at least one worker per domain.");
// The default number of seconds that close handlers will be allowed to run for
// content workers.
@ -156,8 +156,8 @@ const char* gStringChars[] = {
// thread.
};
MOZ_STATIC_ASSERT(NS_ARRAY_LENGTH(gStringChars) == ID_COUNT,
"gStringChars should have the right length.");
static_assert(NS_ARRAY_LENGTH(gStringChars) == ID_COUNT,
"gStringChars should have the right length.");
class LiteralRebindingCString : public nsDependentCString
{

View File

@ -74,8 +74,8 @@ class ConvolutionFilter1D {
// The cast relies on Fixed being a short, implying that on
// the platforms we care about all (16) bits will fit into
// the mantissa of a (32-bit) float.
MOZ_STATIC_ASSERT(sizeof(Fixed) == 2,
"fixed type should fit in float mantissa");
static_assert(sizeof(Fixed) == 2,
"fixed type should fit in float mantissa");
float raw = static_cast<float>(x);
return ldexpf(raw, -kShiftBits);
}

View File

@ -58,8 +58,8 @@ struct ParamTraits<mozilla::gl::GLContext::SharedTextureShareType>
static void Write(Message* msg, const paramType& param)
{
MOZ_STATIC_ASSERT(sizeof(paramType) <= sizeof(int32_t),
"TextureShareType assumes to be int32_t");
static_assert(sizeof(paramType) <= sizeof(int32_t),
"TextureShareType assumes to be int32_t");
WriteParam(msg, int32_t(param));
}

View File

@ -16,8 +16,8 @@
//------------------------------------------------------------------------------
MOZ_STATIC_ASSERT(MOZ_ALIGNOF(Pickle::memberAlignmentType) >= MOZ_ALIGNOF(uint32_t),
"Insufficient alignment");
static_assert(MOZ_ALIGNOF(Pickle::memberAlignmentType) >= MOZ_ALIGNOF(uint32_t),
"Insufficient alignment");
// static
const int Pickle::kPayloadUnit = 64;
@ -61,8 +61,8 @@ struct Copier<T, sizeof(uint64_t), false>
#else
static const int loIndex = 1, hiIndex = 0;
#endif
MOZ_STATIC_ASSERT(MOZ_ALIGNOF(uint32_t*) == MOZ_ALIGNOF(void*),
"Pointers have different alignments");
static_assert(MOZ_ALIGNOF(uint32_t*) == MOZ_ALIGNOF(void*),
"Pointers have different alignments");
uint32_t* src = *reinterpret_cast<uint32_t**>(iter);
uint32_t* uint32dest = reinterpret_cast<uint32_t*>(dest);
uint32dest[loIndex] = src[loIndex];
@ -81,15 +81,15 @@ struct Copier<T, size, true>
// big as MOZ_ALIGNOF(T).
// Check the first condition, as the second condition is already
// known to be true, or we wouldn't be here.
MOZ_STATIC_ASSERT(MOZ_ALIGNOF(T*) == MOZ_ALIGNOF(void*),
"Pointers have different alignments");
static_assert(MOZ_ALIGNOF(T*) == MOZ_ALIGNOF(void*),
"Pointers have different alignments");
*dest = *(*reinterpret_cast<T**>(iter));
}
};
template<typename T>
void CopyFromIter(T* dest, void** iter) {
MOZ_STATIC_ASSERT(mozilla::IsPod<T>::value, "Copied type must be a POD type");
static_assert(mozilla::IsPod<T>::value, "Copied type must be a POD type");
Copier<T, sizeof(T), (MOZ_ALIGNOF(T) <= sizeof(Pickle::memberAlignmentType))>::Copy(dest, iter);
}

View File

@ -251,7 +251,7 @@ class Pickle {
// a power of 2.
template<uint32_t alignment> struct ConstantAligner {
static uint32_t align(int bytes) {
MOZ_STATIC_ASSERT((alignment & (alignment - 1)) == 0,
static_assert((alignment & (alignment - 1)) == 0,
"alignment must be a power of two");
return (bytes + (alignment - 1)) & ~static_cast<uint32_t>(alignment - 1);
}

View File

@ -188,8 +188,8 @@ class Heap : public js::HeapBase<T>
{
public:
Heap() {
MOZ_STATIC_ASSERT(sizeof(T) == sizeof(Heap<T>),
"Heap<T> must be binary compatible with T.");
static_assert(sizeof(T) == sizeof(Heap<T>),
"Heap<T> must be binary compatible with T.");
init(js::GCMethods<T>::initial());
}
explicit Heap(T p) { init(p); }
@ -301,8 +301,8 @@ class TenuredHeap : public js::HeapBase<T>
{
public:
TenuredHeap() : bits(0) {
MOZ_STATIC_ASSERT(sizeof(T) == sizeof(TenuredHeap<T>),
"TenuredHeap<T> must be binary compatible with T.");
static_assert(sizeof(T) == sizeof(TenuredHeap<T>),
"TenuredHeap<T> must be binary compatible with T.");
}
explicit TenuredHeap(T p) : bits(0) { setPtr(p); }
explicit TenuredHeap(const TenuredHeap<T> &p) : bits(0) { setPtr(p.ptr); }
@ -385,22 +385,22 @@ class MOZ_NONHEAP_CLASS Handle : public js::HandleBase<T>
Handle(Handle<S> handle,
typename mozilla::EnableIf<mozilla::IsConvertible<S, T>::value, int>::Type dummy = 0)
{
MOZ_STATIC_ASSERT(sizeof(Handle<T>) == sizeof(T *),
"Handle must be binary compatible with T*.");
static_assert(sizeof(Handle<T>) == sizeof(T *),
"Handle must be binary compatible with T*.");
ptr = reinterpret_cast<const T *>(handle.address());
}
/* Create a handle for a NULL pointer. */
Handle(js::NullPtr) {
MOZ_STATIC_ASSERT(mozilla::IsPointer<T>::value,
"js::NullPtr overload not valid for non-pointer types");
static_assert(mozilla::IsPointer<T>::value,
"js::NullPtr overload not valid for non-pointer types");
ptr = reinterpret_cast<const T *>(&js::NullPtr::constNullValue);
}
/* Create a handle for a NULL pointer. */
Handle(JS::NullPtr) {
MOZ_STATIC_ASSERT(mozilla::IsPointer<T>::value,
"JS::NullPtr overload not valid for non-pointer types");
static_assert(mozilla::IsPointer<T>::value,
"JS::NullPtr overload not valid for non-pointer types");
ptr = reinterpret_cast<const T *>(&JS::NullPtr::constNullValue);
}
@ -1034,8 +1034,8 @@ template <typename T>
inline
MutableHandle<T>::MutableHandle(Rooted<T> *root)
{
MOZ_STATIC_ASSERT(sizeof(MutableHandle<T>) == sizeof(T *),
"MutableHandle must be binary compatible with T*.");
static_assert(sizeof(MutableHandle<T>) == sizeof(T *),
"MutableHandle must be binary compatible with T*.");
ptr = root->address();
}

View File

@ -62,7 +62,7 @@ namespace js {}
# define JS_DIAGNOSTICS_ASSERT(expr) ((void) 0)
#endif
#define JS_STATIC_ASSERT(cond) MOZ_STATIC_ASSERT(cond, "JS_STATIC_ASSERT")
#define JS_STATIC_ASSERT(cond) static_assert(cond, "JS_STATIC_ASSERT")
#define JS_STATIC_ASSERT_IF(cond, expr) MOZ_STATIC_ASSERT_IF(cond, expr, "JS_STATIC_ASSERT_IF")
extern MOZ_NORETURN JS_PUBLIC_API(void)

View File

@ -1645,12 +1645,12 @@ inline Anchor<Value>::~Anchor()
namespace detail {
struct ValueAlignmentTester { char c; JS::Value v; };
MOZ_STATIC_ASSERT(sizeof(ValueAlignmentTester) == 16,
"JS::Value must be 16-byte-aligned");
static_assert(sizeof(ValueAlignmentTester) == 16,
"JS::Value must be 16-byte-aligned");
struct LayoutAlignmentTester { char c; jsval_layout l; };
MOZ_STATIC_ASSERT(sizeof(LayoutAlignmentTester) == 16,
"jsval_layout must be 16-byte-aligned");
static_assert(sizeof(LayoutAlignmentTester) == 16,
"jsval_layout must be 16-byte-aligned");
} // namespace detail
#endif /* DEBUG */
@ -1664,8 +1664,8 @@ MOZ_STATIC_ASSERT(sizeof(LayoutAlignmentTester) == 16,
*/
typedef JS::Value jsval;
MOZ_STATIC_ASSERT(sizeof(jsval_layout) == sizeof(JS::Value),
"jsval_layout and JS::Value must have identical layouts");
static_assert(sizeof(jsval_layout) == sizeof(JS::Value),
"jsval_layout and JS::Value must have identical layouts");
/************************************************************************/

View File

@ -46,6 +46,6 @@
} while (0)
#define ASSERT_NOT_REACHED() MOZ_ASSUME_UNREACHABLE()
#define CRASH() MOZ_CRASH()
#define COMPILE_ASSERT(exp, name) MOZ_STATIC_ASSERT(exp, #name)
#define COMPILE_ASSERT(exp, name) static_assert(exp, #name)
#endif /* assembler_wtf_Assertions_h */

View File

@ -32,9 +32,9 @@ JS_ALWAYS_INLINE
char *
AlignPtr(void *orig)
{
MOZ_STATIC_ASSERT(mozilla::tl::FloorLog2<LIFO_ALLOC_ALIGN>::value ==
mozilla::tl::CeilingLog2<LIFO_ALLOC_ALIGN>::value,
"LIFO_ALLOC_ALIGN must be a power of two");
static_assert(mozilla::tl::FloorLog2<LIFO_ALLOC_ALIGN>::value ==
mozilla::tl::CeilingLog2<LIFO_ALLOC_ALIGN>::value,
"LIFO_ALLOC_ALIGN must be a power of two");
char *result = (char *) ((uintptr_t(orig) + (LIFO_ALLOC_ALIGN - 1)) & (~LIFO_ALLOC_ALIGN + 1));
JS_ASSERT(uintptr_t(result) % LIFO_ALLOC_ALIGN == 0);

View File

@ -5458,8 +5458,8 @@ EmitObject(ExclusiveContext *cx, BytecodeEmitter *bce, ParseNode *pn)
if (!objbox)
return false;
unsigned index = bce->objectList.add(objbox);
MOZ_STATIC_ASSERT(JSOP_NEWINIT_LENGTH == JSOP_NEWOBJECT_LENGTH,
"newinit and newobject must have equal length to edit in-place");
static_assert(JSOP_NEWINIT_LENGTH == JSOP_NEWOBJECT_LENGTH,
"newinit and newobject must have equal length to edit in-place");
EMIT_UINT32_IN_PLACE(offset, JSOP_NEWOBJECT, uint32_t(index));
}

View File

@ -52,8 +52,8 @@ class JSFunction : public JSObject
static void staticAsserts() {
JS_STATIC_ASSERT(INTERPRETED == JS_FUNCTION_INTERPRETED_BIT);
MOZ_STATIC_ASSERT(sizeof(JSFunction) == sizeof(js::shadow::Function),
"shadow interface must match actual interface");
static_assert(sizeof(JSFunction) == sizeof(js::shadow::Function),
"shadow interface must match actual interface");
}
uint16_t nargs; /* maximum number of specified arguments,

View File

@ -1018,12 +1018,12 @@ class JSObject : public js::ObjectImpl
private:
static void staticAsserts() {
MOZ_STATIC_ASSERT(sizeof(JSObject) == sizeof(js::shadow::Object),
"shadow interface must match actual interface");
MOZ_STATIC_ASSERT(sizeof(JSObject) == sizeof(js::ObjectImpl),
"JSObject itself must not have any fields");
MOZ_STATIC_ASSERT(sizeof(JSObject) % sizeof(js::Value) == 0,
"fixed slots after an object must be aligned");
static_assert(sizeof(JSObject) == sizeof(js::shadow::Object),
"shadow interface must match actual interface");
static_assert(sizeof(JSObject) == sizeof(js::ObjectImpl),
"JSObject itself must not have any fields");
static_assert(sizeof(JSObject) % sizeof(js::Value) == 0,
"fixed slots after an object must be aligned");
}
JSObject() MOZ_DELETE;

View File

@ -38,8 +38,8 @@ template<typename ResultType>
inline ResultType
ToUintWidth(double d)
{
MOZ_STATIC_ASSERT(mozilla::IsUnsigned<ResultType>::value,
"ResultType must be an unsigned type");
static_assert(mozilla::IsUnsigned<ResultType>::value,
"ResultType must be an unsigned type");
uint64_t bits = mozilla::BitwiseCast<uint64_t>(d);
@ -69,8 +69,8 @@ ToUintWidth(double d)
// The significand contains the bits that will determine the final result.
// Shift those bits left or right, according to the exponent, to their
// locations in the unsigned binary representation of floor(abs(d)).
MOZ_STATIC_ASSERT(sizeof(ResultType) <= sizeof(uint64_t),
"Left-shifting below would lose upper bits");
static_assert(sizeof(ResultType) <= sizeof(uint64_t),
"Left-shifting below would lose upper bits");
ResultType result = (exponent > mozilla::DoubleExponentShift)
? ResultType(bits << (exponent - mozilla::DoubleExponentShift))
: ResultType(bits >> (mozilla::DoubleExponentShift - exponent));
@ -113,8 +113,8 @@ template<typename ResultType>
inline ResultType
ToIntWidth(double d)
{
MOZ_STATIC_ASSERT(mozilla::IsSigned<ResultType>::value,
"ResultType must be a signed type");
static_assert(mozilla::IsSigned<ResultType>::value,
"ResultType must be a signed type");
const ResultType MaxValue = (1ULL << (CHAR_BIT * sizeof(ResultType) - 1)) - 1;
const ResultType MinValue = -MaxValue - 1;

View File

@ -457,8 +457,8 @@ class ElementsHeader
};
void staticAsserts() {
MOZ_STATIC_ASSERT(sizeof(ElementsHeader) == ValuesPerHeader * sizeof(Value),
"Elements size and values-per-Elements mismatch");
static_assert(sizeof(ElementsHeader) == ValuesPerHeader * sizeof(Value),
"Elements size and values-per-Elements mismatch");
}
public:
@ -638,8 +638,8 @@ struct uint8_clamped {
}
void staticAsserts() {
MOZ_STATIC_ASSERT(sizeof(uint8_clamped) == 1,
"uint8_clamped must be layout-compatible with uint8_t");
static_assert(sizeof(uint8_clamped) == 1,
"uint8_clamped must be layout-compatible with uint8_t");
}
};
@ -1072,8 +1072,8 @@ class ObjectElements
uint32_t length;
void staticAsserts() {
MOZ_STATIC_ASSERT(sizeof(ObjectElements) == VALUES_PER_HEADER * sizeof(Value),
"Elements size and values-per-Elements mismatch");
static_assert(sizeof(ObjectElements) == VALUES_PER_HEADER * sizeof(Value),
"Elements size and values-per-Elements mismatch");
}
bool shouldConvertDoubleElements() const {
@ -1211,19 +1211,19 @@ class ObjectImpl : public gc::Cell
private:
static void staticAsserts() {
MOZ_STATIC_ASSERT(sizeof(ObjectImpl) == sizeof(shadow::Object),
"shadow interface must match actual implementation");
MOZ_STATIC_ASSERT(sizeof(ObjectImpl) % sizeof(Value) == 0,
"fixed slots after an object must be aligned");
static_assert(sizeof(ObjectImpl) == sizeof(shadow::Object),
"shadow interface must match actual implementation");
static_assert(sizeof(ObjectImpl) % sizeof(Value) == 0,
"fixed slots after an object must be aligned");
MOZ_STATIC_ASSERT(offsetof(ObjectImpl, shape_) == offsetof(shadow::Object, shape),
"shadow shape must match actual shape");
MOZ_STATIC_ASSERT(offsetof(ObjectImpl, type_) == offsetof(shadow::Object, type),
"shadow type must match actual type");
MOZ_STATIC_ASSERT(offsetof(ObjectImpl, slots) == offsetof(shadow::Object, slots),
"shadow slots must match actual slots");
MOZ_STATIC_ASSERT(offsetof(ObjectImpl, elements) == offsetof(shadow::Object, _1),
"shadow placeholder must match actual elements");
static_assert(offsetof(ObjectImpl, shape_) == offsetof(shadow::Object, shape),
"shadow shape must match actual shape");
static_assert(offsetof(ObjectImpl, type_) == offsetof(shadow::Object, type),
"shadow type must match actual type");
static_assert(offsetof(ObjectImpl, slots) == offsetof(shadow::Object, slots),
"shadow slots must match actual slots");
static_assert(offsetof(ObjectImpl, elements) == offsetof(shadow::Object, _1),
"shadow placeholder must match actual elements");
}
JSObject * asObjectPtr() { return reinterpret_cast<JSObject *>(this); }
@ -1623,9 +1623,9 @@ class ObjectImpl : public gc::Cell
}
inline HeapSlot *fixedElements() const {
MOZ_STATIC_ASSERT(2 * sizeof(Value) == sizeof(ObjectElements),
"when elements are stored inline, the first two "
"slots will hold the ObjectElements header");
static_assert(2 * sizeof(Value) == sizeof(ObjectElements),
"when elements are stored inline, the first two "
"slots will hold the ObjectElements header");
return &fixedSlots()[2];
}

View File

@ -41,8 +41,8 @@ FramePropertyTable::Set(nsIFrame* aFrame, const FramePropertyDescriptor* aProper
// We need to expand the single current entry to an array
PropertyValue current = entry->mProp;
entry->mProp.mProperty = nullptr;
MOZ_STATIC_ASSERT(sizeof(nsTArray<PropertyValue>) <= sizeof(void *),
"Property array must fit entirely within entry->mProp.mValue");
static_assert(sizeof(nsTArray<PropertyValue>) <= sizeof(void *),
"Property array must fit entirely within entry->mProp.mValue");
new (&entry->mProp.mValue) nsTArray<PropertyValue>(4);
entry->mProp.ToArray()->AppendElement(current);
}

View File

@ -519,10 +519,10 @@ FrameHasPositionedPlaceholderDescendants(nsIFrame* aFrame, uint32_t aPositionMas
static bool
NeedToReframeForAddingOrRemovingTransform(nsIFrame* aFrame)
{
MOZ_STATIC_ASSERT(0 <= NS_STYLE_POSITION_ABSOLUTE &&
NS_STYLE_POSITION_ABSOLUTE < 32, "Style constant out of range");
MOZ_STATIC_ASSERT(0 <= NS_STYLE_POSITION_FIXED &&
NS_STYLE_POSITION_FIXED < 32, "Style constant out of range");
static_assert(0 <= NS_STYLE_POSITION_ABSOLUTE &&
NS_STYLE_POSITION_ABSOLUTE < 32, "Style constant out of range");
static_assert(0 <= NS_STYLE_POSITION_FIXED &&
NS_STYLE_POSITION_FIXED < 32, "Style constant out of range");
uint32_t positionMask;
// Don't call aFrame->IsPositioned here, since that returns true if

View File

@ -4,7 +4,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef DEBUG
MOZ_STATIC_ASSERT(false, "This should not be compiled in !DEBUG");
static_assert(false, "This should not be compiled in !DEBUG");
#endif // DEBUG
#include "nsAutoLayoutPhase.h"

View File

@ -9031,7 +9031,7 @@ nsCSSFrameConstructor::ProcessChildren(nsFrameConstructorState& aState,
"Parent frame in ProcessChildren should be its own "
"content insertion frame");
const uint32_t kMaxDepth = 2 * MAX_REFLOW_DEPTH;
MOZ_STATIC_ASSERT(kMaxDepth <= UINT16_MAX, "mCurrentDepth type is too narrow");
static_assert(kMaxDepth <= UINT16_MAX, "mCurrentDepth type is too narrow");
AutoRestore<uint16_t> savedDepth(mCurrentDepth);
if (mCurrentDepth != UINT16_MAX) {
++mCurrentDepth;

View File

@ -538,8 +538,8 @@ nsPresContext::GetFontPrefsForLang(nsIAtom *aLanguage) const
&prefs->mDefaultCursiveFont,
&prefs->mDefaultFantasyFont
};
MOZ_STATIC_ASSERT(NS_ARRAY_LENGTH(fontTypes) == eDefaultFont_COUNT,
"FontTypes array count is not correct");
static_assert(NS_ARRAY_LENGTH(fontTypes) == eDefaultFont_COUNT,
"FontTypes array count is not correct");
// Get attributes specific to each generic font. We do not get the user's
// generic-font-name-to-specific-family-name preferences because its the

View File

@ -396,9 +396,9 @@ Initialize()
return NS_ERROR_FAILURE;
}
MOZ_STATIC_ASSERT(sizeof(uintptr_t) == sizeof(void*),
"Eeek! You'll need to adjust the size of uintptr_t to the "
"size of a pointer on your platform.");
static_assert(sizeof(uintptr_t) == sizeof(void*),
"Eeek! You'll need to adjust the size of uintptr_t to the "
"size of a pointer on your platform.");
gInitialized = true;

View File

@ -885,7 +885,7 @@ nsImageFrame::Reflow(nsPresContext* aPresContext,
// We include the altFeedbackSize in our visual overflow, but not in our
// scrollable overflow, since it doesn't really need to be scrolled to
// outside the image.
MOZ_STATIC_ASSERT(eOverflowType_LENGTH == 2, "Unknown overflow types?");
static_assert(eOverflowType_LENGTH == 2, "Unknown overflow types?");
nsRect& visualOverflow = aMetrics.VisualOverflow();
visualOverflow.UnionRect(visualOverflow, altFeedbackSize);
}

View File

@ -44,9 +44,9 @@ nsLineBox::nsLineBox(nsIFrame* aFrame, int32_t aCount, bool aIsBlock)
}
#endif
MOZ_STATIC_ASSERT(NS_STYLE_CLEAR_LAST_VALUE <= 15,
"FlagBits needs more bits to store the full range of "
"break type ('clear') values");
static_assert(NS_STYLE_CLEAR_LAST_VALUE <= 15,
"FlagBits needs more bits to store the full range of "
"break type ('clear') values");
#if NS_STYLE_CLEAR_NONE > 0
mFlags.mBreakType = NS_STYLE_CLEAR_NONE;
#endif

View File

@ -24,16 +24,16 @@
#define NS_QUERYFRAME_ENTRY(class) \
case class::kFrameIID: { \
MOZ_STATIC_ASSERT((mozilla::IsSame<class, class::Has_NS_DECL_QUERYFRAME_TARGET>::value), \
#class " must declare itself as a queryframe target"); \
static_assert(mozilla::IsSame<class, class::Has_NS_DECL_QUERYFRAME_TARGET>::value, \
#class " must declare itself as a queryframe target"); \
return static_cast<class*>(this); \
}
#define NS_QUERYFRAME_ENTRY_CONDITIONAL(class, condition) \
case class::kFrameIID: \
if (condition) { \
MOZ_STATIC_ASSERT((mozilla::IsSame<class, class::Has_NS_DECL_QUERYFRAME_TARGET>::value), \
#class " must declare itself as a queryframe target"); \
static_assert(mozilla::IsSame<class, class::Has_NS_DECL_QUERYFRAME_TARGET>::value, \
#class " must declare itself as a queryframe target"); \
return static_cast<class*>(this); \
} \
break;
@ -81,8 +81,8 @@ public:
template<class Dest>
operator Dest*() {
MOZ_STATIC_ASSERT((mozilla::IsSame<Dest, typename Dest::Has_NS_DECL_QUERYFRAME_TARGET>::value),
"Dest must declare itself as a queryframe target");
static_assert(mozilla::IsSame<Dest, typename Dest::Has_NS_DECL_QUERYFRAME_TARGET>::value,
"Dest must declare itself as a queryframe target");
if (!mRawPtr)
return nullptr;

View File

@ -754,9 +754,9 @@ GetStatesForPseudoClass(const nsAString& aStatePseudo)
nsEventStates(),
nsEventStates()
};
MOZ_STATIC_ASSERT(NS_ARRAY_LENGTH(sPseudoClassStates) ==
nsCSSPseudoClasses::ePseudoClass_NotPseudoClass + 1,
"Length of PseudoClassStates array is incorrect");
static_assert(NS_ARRAY_LENGTH(sPseudoClassStates) ==
nsCSSPseudoClasses::ePseudoClass_NotPseudoClass + 1,
"Length of PseudoClassStates array is incorrect");
nsCOMPtr<nsIAtom> atom = do_GetAtom(aStatePseudo);

View File

@ -20,8 +20,8 @@ namespace css {
// check that we can fit all the CSS properties into a uint16_t
// for the mOrder array
MOZ_STATIC_ASSERT(eCSSProperty_COUNT_no_shorthands - 1 <= UINT16_MAX,
"CSS longhand property numbers no longer fit in a uint16_t");
static_assert(eCSSProperty_COUNT_no_shorthands - 1 <= UINT16_MAX,
"CSS longhand property numbers no longer fit in a uint16_t");
Declaration::Declaration()
: mImmutable(false)
@ -481,13 +481,13 @@ Declaration::GetValue(nsCSSProperty aProperty, nsAString& aValue) const
MOZ_ASSERT(nsCSSProps::kKeywordTableTable[
eCSSProperty_background_clip] ==
nsCSSProps::kBackgroundOriginKTable);
MOZ_STATIC_ASSERT(NS_STYLE_BG_CLIP_BORDER ==
NS_STYLE_BG_ORIGIN_BORDER &&
NS_STYLE_BG_CLIP_PADDING ==
NS_STYLE_BG_ORIGIN_PADDING &&
NS_STYLE_BG_CLIP_CONTENT ==
NS_STYLE_BG_ORIGIN_CONTENT,
"bg-clip and bg-origin style constants must agree");
static_assert(NS_STYLE_BG_CLIP_BORDER ==
NS_STYLE_BG_ORIGIN_BORDER &&
NS_STYLE_BG_CLIP_PADDING ==
NS_STYLE_BG_ORIGIN_PADDING &&
NS_STYLE_BG_CLIP_CONTENT ==
NS_STYLE_BG_ORIGIN_CONTENT,
"bg-clip and bg-origin style constants must agree");
aValue.Append(PRUnichar(' '));
origin->mValue.AppendToString(eCSSProperty_background_origin, aValue);

View File

@ -302,8 +302,8 @@ nsCSSSelector::nsCSSSelector(void)
mPseudoType(nsCSSPseudoElements::ePseudo_NotPseudoElement)
{
MOZ_COUNT_CTOR(nsCSSSelector);
MOZ_STATIC_ASSERT(nsCSSPseudoElements::ePseudo_MAX < INT16_MAX,
"nsCSSPseudoElements::Type values overflow mPseudoType");
static_assert(nsCSSPseudoElements::ePseudo_MAX < INT16_MAX,
"nsCSSPseudoElements::Type values overflow mPseudoType");
}
nsCSSSelector*

View File

@ -667,10 +667,10 @@ public:
static KeyTypePointer KeyToPointer(KeyType aKey) { return &aKey; }
static PLDHashNumber HashKey(KeyTypePointer aKey) {
MOZ_STATIC_ASSERT(sizeof(PLDHashNumber) == sizeof(uint32_t),
"this hash function assumes PLDHashNumber is uint32_t");
MOZ_STATIC_ASSERT(PLDHashNumber(-1) > PLDHashNumber(0),
"this hash function assumes PLDHashNumber is uint32_t");
static_assert(sizeof(PLDHashNumber) == sizeof(uint32_t),
"this hash function assumes PLDHashNumber is uint32_t");
static_assert(PLDHashNumber(-1) > PLDHashNumber(0),
"this hash function assumes PLDHashNumber is uint32_t");
float key = *aKey;
NS_ABORT_IF_FALSE(0.0f <= key && key <= 1.0f, "out of range");
return PLDHashNumber(key * UINT32_MAX);

View File

@ -160,17 +160,17 @@ private:
// Make sure the values and properties are aligned appropriately. (These
// assertions are stronger than necessary to keep them simple.)
MOZ_STATIC_ASSERT(sizeof(nsCSSCompressedDataBlock) == 8,
"nsCSSCompressedDataBlock's size has changed");
MOZ_STATIC_ASSERT(NS_ALIGNMENT_OF(nsCSSValue) == 4 || NS_ALIGNMENT_OF(nsCSSValue) == 8,
"nsCSSValue doesn't align with nsCSSCompressedDataBlock");
MOZ_STATIC_ASSERT(NS_ALIGNMENT_OF(nsCSSCompressedDataBlock::CompressedCSSProperty) == 2,
"CompressedCSSProperty doesn't align with nsCSSValue");
static_assert(sizeof(nsCSSCompressedDataBlock) == 8,
"nsCSSCompressedDataBlock's size has changed");
static_assert(NS_ALIGNMENT_OF(nsCSSValue) == 4 || NS_ALIGNMENT_OF(nsCSSValue) == 8,
"nsCSSValue doesn't align with nsCSSCompressedDataBlock");
static_assert(NS_ALIGNMENT_OF(nsCSSCompressedDataBlock::CompressedCSSProperty) == 2,
"CompressedCSSProperty doesn't align with nsCSSValue");
// Make sure that sizeof(CompressedCSSProperty) is big enough.
MOZ_STATIC_ASSERT(eCSSProperty_COUNT_no_shorthands <=
nsCSSCompressedDataBlock::MaxCompressedCSSProperty,
"nsCSSProperty doesn't fit in StoredSizeOfCSSProperty");
static_assert(eCSSProperty_COUNT_no_shorthands <=
nsCSSCompressedDataBlock::MaxCompressedCSSProperty,
"nsCSSProperty doesn't fit in StoredSizeOfCSSProperty");
class nsCSSExpandedDataBlock {
friend class nsCSSCompressedDataBlock;

View File

@ -6957,13 +6957,13 @@ CSSParserImpl::ParseBackgroundItem(CSSParserImpl::BackgroundParseState& aState)
MOZ_ASSERT(nsCSSProps::kKeywordTableTable[
eCSSProperty_background_clip] ==
nsCSSProps::kBackgroundOriginKTable);
MOZ_STATIC_ASSERT(NS_STYLE_BG_CLIP_BORDER ==
NS_STYLE_BG_ORIGIN_BORDER &&
NS_STYLE_BG_CLIP_PADDING ==
NS_STYLE_BG_ORIGIN_PADDING &&
NS_STYLE_BG_CLIP_CONTENT ==
NS_STYLE_BG_ORIGIN_CONTENT,
"bg-clip and bg-origin style constants must agree");
static_assert(NS_STYLE_BG_CLIP_BORDER ==
NS_STYLE_BG_ORIGIN_BORDER &&
NS_STYLE_BG_CLIP_PADDING ==
NS_STYLE_BG_ORIGIN_PADDING &&
NS_STYLE_BG_CLIP_CONTENT ==
NS_STYLE_BG_ORIGIN_CONTENT,
"bg-clip and bg-origin style constants must agree");
if (!ParseSingleValueProperty(aState.mClip->mValue,
eCSSProperty_background_clip)) {
@ -9531,13 +9531,13 @@ CSSParserImpl::ParseTextDecoration()
eDecorationBlink = NS_STYLE_TEXT_DECORATION_LINE_BLINK,
eDecorationPrefAnchors = NS_STYLE_TEXT_DECORATION_LINE_PREF_ANCHORS
};
MOZ_STATIC_ASSERT((eDecorationNone ^ eDecorationUnderline ^
eDecorationOverline ^ eDecorationLineThrough ^
eDecorationBlink ^ eDecorationPrefAnchors) ==
(eDecorationNone | eDecorationUnderline |
eDecorationOverline | eDecorationLineThrough |
eDecorationBlink | eDecorationPrefAnchors),
"text decoration constants need to be bitmasks");
static_assert((eDecorationNone ^ eDecorationUnderline ^
eDecorationOverline ^ eDecorationLineThrough ^
eDecorationBlink ^ eDecorationPrefAnchors) ==
(eDecorationNone | eDecorationUnderline |
eDecorationOverline | eDecorationLineThrough |
eDecorationBlink | eDecorationPrefAnchors),
"text decoration constants need to be bitmasks");
static const int32_t kTextDecorationKTable[] = {
eCSSKeyword_none, eDecorationNone,
@ -10774,7 +10774,7 @@ CSSParserImpl::ParseMarker()
bool
CSSParserImpl::ParsePaintOrder()
{
MOZ_STATIC_ASSERT
static_assert
((1 << NS_STYLE_PAINT_ORDER_BITWIDTH) > NS_STYLE_PAINT_ORDER_LAST_VALUE,
"bitfield width insufficient for paint-order constants");
@ -10786,9 +10786,9 @@ CSSParserImpl::ParsePaintOrder()
eCSSKeyword_UNKNOWN,-1
};
MOZ_STATIC_ASSERT(NS_ARRAY_LENGTH(kPaintOrderKTable) ==
2 * (NS_STYLE_PAINT_ORDER_LAST_VALUE + 2),
"missing paint-order values in kPaintOrderKTable");
static_assert(NS_ARRAY_LENGTH(kPaintOrderKTable) ==
2 * (NS_STYLE_PAINT_ORDER_LAST_VALUE + 2),
"missing paint-order values in kPaintOrderKTable");
nsCSSValue value;
if (!ParseVariant(value, VARIANT_HK, kPaintOrderKTable)) {
@ -10801,7 +10801,7 @@ CSSParserImpl::ParsePaintOrder()
// Ensure that even cast to a signed int32_t when stored in CSSValue,
// we have enough space for the entire paint-order value.
MOZ_STATIC_ASSERT
static_assert
(NS_STYLE_PAINT_ORDER_BITWIDTH * NS_STYLE_PAINT_ORDER_LAST_VALUE < 32,
"seen and order not big enough");
@ -10845,8 +10845,8 @@ CSSParserImpl::ParsePaintOrder()
}
}
MOZ_STATIC_ASSERT(NS_STYLE_PAINT_ORDER_NORMAL == 0,
"unexpected value for NS_STYLE_PAINT_ORDER_NORMAL");
static_assert(NS_STYLE_PAINT_ORDER_NORMAL == 0,
"unexpected value for NS_STYLE_PAINT_ORDER_NORMAL");
value.SetIntValue(static_cast<int32_t>(order), eCSSUnit_Enumerated);
}

View File

@ -356,8 +356,8 @@ nsCSSProps::LookupProperty(const nsACString& aProperty,
// Check eCSSAliasCount against 0 to make it easy for the
// compiler to optimize away the 0-aliases case.
if (eCSSAliasCount != 0 && res >= eCSSProperty_COUNT) {
MOZ_STATIC_ASSERT(eCSSProperty_UNKNOWN < eCSSProperty_COUNT,
"assuming eCSSProperty_UNKNOWN doesn't hit this code");
static_assert(eCSSProperty_UNKNOWN < eCSSProperty_COUNT,
"assuming eCSSProperty_UNKNOWN doesn't hit this code");
if (IsEnabled(res) || aEnabled == eAny) {
res = gAliases[res - eCSSProperty_COUNT];
NS_ABORT_IF_FALSE(0 <= res && res < eCSSProperty_COUNT,
@ -383,8 +383,8 @@ nsCSSProps::LookupProperty(const nsAString& aProperty, EnabledState aEnabled)
// Check eCSSAliasCount against 0 to make it easy for the
// compiler to optimize away the 0-aliases case.
if (eCSSAliasCount != 0 && res >= eCSSProperty_COUNT) {
MOZ_STATIC_ASSERT(eCSSProperty_UNKNOWN < eCSSProperty_COUNT,
"assuming eCSSProperty_UNKNOWN doesn't hit this code");
static_assert(eCSSProperty_UNKNOWN < eCSSProperty_COUNT,
"assuming eCSSProperty_UNKNOWN doesn't hit this code");
if (IsEnabled(res) || aEnabled == eAny) {
res = gAliases[res - eCSSProperty_COUNT];
NS_ABORT_IF_FALSE(0 <= res && res < eCSSProperty_COUNT,
@ -647,10 +647,10 @@ const int32_t nsCSSProps::kBackgroundInlinePolicyKTable[] = {
eCSSKeyword_UNKNOWN,-1
};
MOZ_STATIC_ASSERT(NS_STYLE_BG_CLIP_BORDER == NS_STYLE_BG_ORIGIN_BORDER &&
NS_STYLE_BG_CLIP_PADDING == NS_STYLE_BG_ORIGIN_PADDING &&
NS_STYLE_BG_CLIP_CONTENT == NS_STYLE_BG_ORIGIN_CONTENT,
"bg-clip and bg-origin style constants must agree");
static_assert(NS_STYLE_BG_CLIP_BORDER == NS_STYLE_BG_ORIGIN_BORDER &&
NS_STYLE_BG_CLIP_PADDING == NS_STYLE_BG_ORIGIN_PADDING &&
NS_STYLE_BG_CLIP_CONTENT == NS_STYLE_BG_ORIGIN_CONTENT,
"bg-clip and bg-origin style constants must agree");
const int32_t nsCSSProps::kBackgroundOriginKTable[] = {
eCSSKeyword_border_box, NS_STYLE_BG_ORIGIN_BORDER,
eCSSKeyword_padding_box, NS_STYLE_BG_ORIGIN_PADDING,
@ -1954,9 +1954,9 @@ static const nsCSSProperty gBorderBottomSubpropTable[] = {
eCSSProperty_UNKNOWN
};
MOZ_STATIC_ASSERT(NS_SIDE_TOP == 0 && NS_SIDE_RIGHT == 1 &&
NS_SIDE_BOTTOM == 2 && NS_SIDE_LEFT == 3,
"box side constants not top/right/bottom/left == 0/1/2/3");
static_assert(NS_SIDE_TOP == 0 && NS_SIDE_RIGHT == 1 &&
NS_SIDE_BOTTOM == 2 && NS_SIDE_LEFT == 3,
"box side constants not top/right/bottom/left == 0/1/2/3");
static const nsCSSProperty gBorderColorSubpropTable[] = {
// Code relies on these being in top-right-bottom-left order.
// Code relies on these matching the NS_SIDE_* constants.

View File

@ -159,9 +159,9 @@
// See CSSParserImpl::ParseSingleValueProperty and comment above
// CSS_PROPERTY_PARSE_FUNCTION (which is different).
#define CSS_PROPERTY_VALUE_PARSER_FUNCTION (1<<12)
MOZ_STATIC_ASSERT((CSS_PROPERTY_PARSE_PROPERTY_MASK &
CSS_PROPERTY_VALUE_PARSER_FUNCTION) == 0,
"didn't leave enough room for the parse property constants");
static_assert((CSS_PROPERTY_PARSE_PROPERTY_MASK &
CSS_PROPERTY_VALUE_PARSER_FUNCTION) == 0,
"didn't leave enough room for the parse property constants");
#define CSS_PROPERTY_VALUE_RESTRICTION_MASK (3<<13)
// The parser (in particular, CSSParserImpl::ParseSingleValueProperty)

View File

@ -1619,10 +1619,10 @@ static const nsEventStates sPseudoClassStates[] = {
nsEventStates(),
nsEventStates()
};
MOZ_STATIC_ASSERT(NS_ARRAY_LENGTH(sPseudoClassStates) ==
nsCSSPseudoClasses::ePseudoClass_NotPseudoClass + 1,
"ePseudoClass_NotPseudoClass is no longer at the end of"
"sPseudoClassStates");
static_assert(NS_ARRAY_LENGTH(sPseudoClassStates) ==
nsCSSPseudoClasses::ePseudoClass_NotPseudoClass + 1,
"ePseudoClass_NotPseudoClass is no longer at the end of"
"sPseudoClassStates");
// |aDependence| has two functions:
// * when non-null, it indicates that we're processing a negation,

View File

@ -76,8 +76,8 @@ static const uint8_t gLexTable[] = {
SUIJ, SUIJ, SUIJ, SU, SU, SU, SU, S,
};
MOZ_STATIC_ASSERT(MOZ_ARRAY_LENGTH(gLexTable) == 128,
"gLexTable expected to cover all 128 ASCII characters");
static_assert(MOZ_ARRAY_LENGTH(gLexTable) == 128,
"gLexTable expected to cover all 128 ASCII characters");
#undef I
#undef J

View File

@ -863,7 +863,7 @@ nsCSSValue::AppendToString(nsCSSProperty aProperty, nsAString& aResult) const
break;
case eCSSProperty_paint_order:
MOZ_STATIC_ASSERT
static_assert
(NS_STYLE_PAINT_ORDER_BITWIDTH * NS_STYLE_PAINT_ORDER_LAST_VALUE <= 8,
"SVGStyleStruct::mPaintOrder and the following cast not big enough");
nsStyleUtil::AppendPaintOrderValue(static_cast<uint8_t>(GetIntValue()),
@ -1533,9 +1533,9 @@ nsCSSRect_heap::SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const
return n;
}
MOZ_STATIC_ASSERT(NS_SIDE_TOP == 0 && NS_SIDE_RIGHT == 1 &&
NS_SIDE_BOTTOM == 2 && NS_SIDE_LEFT == 3,
"box side constants not top/right/bottom/left == 0/1/2/3");
static_assert(NS_SIDE_TOP == 0 && NS_SIDE_RIGHT == 1 &&
NS_SIDE_BOTTOM == 2 && NS_SIDE_LEFT == 3,
"box side constants not top/right/bottom/left == 0/1/2/3");
/* static */ const nsCSSRect::side_type nsCSSRect::sides[4] = {
&nsCSSRect::mTop,
@ -1933,9 +1933,9 @@ nsCSSCornerSizes::Reset()
}
}
MOZ_STATIC_ASSERT(NS_CORNER_TOP_LEFT == 0 && NS_CORNER_TOP_RIGHT == 1 &&
NS_CORNER_BOTTOM_RIGHT == 2 && NS_CORNER_BOTTOM_LEFT == 3,
"box corner constants not tl/tr/br/bl == 0/1/2/3");
static_assert(NS_CORNER_TOP_LEFT == 0 && NS_CORNER_TOP_RIGHT == 1 &&
NS_CORNER_BOTTOM_RIGHT == 2 && NS_CORNER_BOTTOM_LEFT == 3,
"box corner constants not tl/tr/br/bl == 0/1/2/3");
/* static */ const nsCSSCornerSizes::corner_type
nsCSSCornerSizes::corners[4] = {

View File

@ -2958,8 +2958,8 @@ nsComputedDOMStyle::DoGetDirection()
return val;
}
MOZ_STATIC_ASSERT(NS_STYLE_UNICODE_BIDI_NORMAL == 0,
"unicode-bidi style constants not as expected");
static_assert(NS_STYLE_UNICODE_BIDI_NORMAL == 0,
"unicode-bidi style constants not as expected");
CSSValue*
nsComputedDOMStyle::DoGetUnicodeBidi()
@ -3734,9 +3734,9 @@ nsComputedDOMStyle::GetAbsoluteOffset(mozilla::css::Side aSide)
return val;
}
MOZ_STATIC_ASSERT(NS_SIDE_TOP == 0 && NS_SIDE_RIGHT == 1 &&
NS_SIDE_BOTTOM == 2 && NS_SIDE_LEFT == 3,
"box side constants not as expected for NS_OPPOSITE_SIDE");
static_assert(NS_SIDE_TOP == 0 && NS_SIDE_RIGHT == 1 &&
NS_SIDE_BOTTOM == 2 && NS_SIDE_LEFT == 3,
"box side constants not as expected for NS_OPPOSITE_SIDE");
#define NS_OPPOSITE_SIDE(s_) mozilla::css::Side(((s_) + 2) & 3)
CSSValue*

View File

@ -14,12 +14,12 @@ nsRuleData::GetPoisonOffset()
// Fill in mValueOffsets such that mValueStorage + mValueOffsets[i]
// will yield the frame poison value for all uninitialized value
// offsets.
MOZ_STATIC_ASSERT(sizeof(uintptr_t) == sizeof(size_t),
"expect uintptr_t and size_t to be the same size");
MOZ_STATIC_ASSERT(uintptr_t(-1) > uintptr_t(0),
"expect uintptr_t to be unsigned");
MOZ_STATIC_ASSERT(size_t(-1) > size_t(0),
"expect size_t to be unsigned");
static_assert(sizeof(uintptr_t) == sizeof(size_t),
"expect uintptr_t and size_t to be the same size");
static_assert(uintptr_t(-1) > uintptr_t(0),
"expect uintptr_t to be unsigned");
static_assert(size_t(-1) > size_t(0),
"expect size_t to be unsigned");
uintptr_t framePoisonValue = mozPoisonValue();
return size_t(framePoisonValue - uintptr_t(mValueStorage)) /
sizeof(nsCSSValue);

View File

@ -3082,7 +3082,7 @@ nsRuleNode::SetFont(nsPresContext* aPresContext, nsStyleContext* aContext,
aFont->mLanguage);
// -moz-system-font: enum (never inherit!)
MOZ_STATIC_ASSERT(
static_assert(
NS_STYLE_FONT_CAPTION == LookAndFeel::eFont_Caption &&
NS_STYLE_FONT_ICON == LookAndFeel::eFont_Icon &&
NS_STYLE_FONT_MENU == LookAndFeel::eFont_Menu &&
@ -5549,11 +5549,11 @@ struct BackgroundItemComputer<nsCSSValuePairList, nsStyleBackground::Size>
size.*(axis->type) = nsStyleBackground::Size::eAuto;
}
else if (eCSSUnit_Enumerated == specified.GetUnit()) {
MOZ_STATIC_ASSERT(nsStyleBackground::Size::eContain ==
NS_STYLE_BG_SIZE_CONTAIN &&
nsStyleBackground::Size::eCover ==
NS_STYLE_BG_SIZE_COVER,
"background size constants out of sync");
static_assert(nsStyleBackground::Size::eContain ==
NS_STYLE_BG_SIZE_CONTAIN &&
nsStyleBackground::Size::eCover ==
NS_STYLE_BG_SIZE_COVER,
"background size constants out of sync");
NS_ABORT_IF_FALSE(specified.GetIntValue() == NS_STYLE_BG_SIZE_CONTAIN ||
specified.GetIntValue() == NS_STYLE_BG_SIZE_COVER,
"invalid enumerated value for size coordinate");
@ -7535,7 +7535,7 @@ nsRuleNode::ComputeSVGData(void* aStartStruct,
break;
case eCSSUnit_Enumerated:
MOZ_STATIC_ASSERT
static_assert
(NS_STYLE_PAINT_ORDER_BITWIDTH * NS_STYLE_PAINT_ORDER_LAST_VALUE <= 8,
"SVGStyleStruct::mPaintOrder not big enough");
svg->mPaintOrder = static_cast<uint8_t>(paintOrderValue->GetIntValue());

View File

@ -2824,9 +2824,9 @@ nsStyleAnimation::ExtractComputedValue(nsCSSProperty aProperty,
case eCSSProperty_font_stretch: {
int16_t stretch =
static_cast<const nsStyleFont*>(styleStruct)->mFont.stretch;
MOZ_STATIC_ASSERT(NS_STYLE_FONT_STRETCH_ULTRA_CONDENSED == -4 &&
NS_STYLE_FONT_STRETCH_ULTRA_EXPANDED == 4,
"font stretch constants not as expected");
static_assert(NS_STYLE_FONT_STRETCH_ULTRA_CONDENSED == -4 &&
NS_STYLE_FONT_STRETCH_ULTRA_EXPANDED == 4,
"font stretch constants not as expected");
if (stretch < NS_STYLE_FONT_STRETCH_ULTRA_CONDENSED ||
stretch > NS_STYLE_FONT_STRETCH_ULTRA_EXPANDED) {
return false;
@ -3049,7 +3049,7 @@ nsStyleAnimation::ExtractComputedValue(nsCSSProperty aProperty,
case eStyleAnimType_Sides_Right:
case eStyleAnimType_Sides_Bottom:
case eStyleAnimType_Sides_Left: {
MOZ_STATIC_ASSERT(
static_assert(
NS_SIDE_TOP == eStyleAnimType_Sides_Top -eStyleAnimType_Sides_Top &&
NS_SIDE_RIGHT == eStyleAnimType_Sides_Right -eStyleAnimType_Sides_Top &&
NS_SIDE_BOTTOM == eStyleAnimType_Sides_Bottom-eStyleAnimType_Sides_Top &&
@ -3065,7 +3065,7 @@ nsStyleAnimation::ExtractComputedValue(nsCSSProperty aProperty,
case eStyleAnimType_Corner_TopRight:
case eStyleAnimType_Corner_BottomRight:
case eStyleAnimType_Corner_BottomLeft: {
MOZ_STATIC_ASSERT(
static_assert(
NS_CORNER_TOP_LEFT == eStyleAnimType_Corner_TopLeft -
eStyleAnimType_Corner_TopLeft &&
NS_CORNER_TOP_RIGHT == eStyleAnimType_Corner_TopRight -

View File

@ -48,9 +48,9 @@ nsStyleContext::nsStyleContext(nsStyleContext* aParent,
{
// This check has to be done "backward", because if it were written the
// more natural way it wouldn't fail even when it needed to.
MOZ_STATIC_ASSERT((UINT32_MAX >> NS_STYLE_CONTEXT_TYPE_SHIFT) >=
nsCSSPseudoElements::ePseudo_MAX,
"pseudo element bits no longer fit in a uint32_t");
static_assert((UINT32_MAX >> NS_STYLE_CONTEXT_TYPE_SHIFT) >=
nsCSSPseudoElements::ePseudo_MAX,
"pseudo element bits no longer fit in a uint32_t");
MOZ_ASSERT(aRuleNode);
mNextSibling = this;

View File

@ -248,8 +248,8 @@ void nsStyleCorners::Reset()
// Validation of NS_SIDE_IS_VERTICAL and NS_HALF_CORNER_IS_X.
#define CASE(side, result) \
MOZ_STATIC_ASSERT(NS_SIDE_IS_VERTICAL(side) == result, \
"NS_SIDE_IS_VERTICAL is wrong")
static_assert(NS_SIDE_IS_VERTICAL(side) == result, \
"NS_SIDE_IS_VERTICAL is wrong")
CASE(NS_SIDE_TOP, false);
CASE(NS_SIDE_RIGHT, true);
CASE(NS_SIDE_BOTTOM, false);
@ -257,8 +257,8 @@ CASE(NS_SIDE_LEFT, true);
#undef CASE
#define CASE(corner, result) \
MOZ_STATIC_ASSERT(NS_HALF_CORNER_IS_X(corner) == result, \
"NS_HALF_CORNER_IS_X is wrong")
static_assert(NS_HALF_CORNER_IS_X(corner) == result, \
"NS_HALF_CORNER_IS_X is wrong")
CASE(NS_CORNER_TOP_LEFT_X, true);
CASE(NS_CORNER_TOP_LEFT_Y, false);
CASE(NS_CORNER_TOP_RIGHT_X, true);
@ -271,8 +271,8 @@ CASE(NS_CORNER_BOTTOM_LEFT_Y, false);
// Validation of NS_HALF_TO_FULL_CORNER.
#define CASE(corner, result) \
MOZ_STATIC_ASSERT(NS_HALF_TO_FULL_CORNER(corner) == result, \
"NS_HALF_TO_FULL_CORNER is wrong")
static_assert(NS_HALF_TO_FULL_CORNER(corner) == result, \
"NS_HALF_TO_FULL_CORNER is wrong")
CASE(NS_CORNER_TOP_LEFT_X, NS_CORNER_TOP_LEFT);
CASE(NS_CORNER_TOP_LEFT_Y, NS_CORNER_TOP_LEFT);
CASE(NS_CORNER_TOP_RIGHT_X, NS_CORNER_TOP_RIGHT);
@ -285,8 +285,8 @@ CASE(NS_CORNER_BOTTOM_LEFT_Y, NS_CORNER_BOTTOM_LEFT);
// Validation of NS_FULL_TO_HALF_CORNER.
#define CASE(corner, vert, result) \
MOZ_STATIC_ASSERT(NS_FULL_TO_HALF_CORNER(corner, vert) == result, \
"NS_FULL_TO_HALF_CORNER is wrong")
static_assert(NS_FULL_TO_HALF_CORNER(corner, vert) == result, \
"NS_FULL_TO_HALF_CORNER is wrong")
CASE(NS_CORNER_TOP_LEFT, false, NS_CORNER_TOP_LEFT_X);
CASE(NS_CORNER_TOP_LEFT, true, NS_CORNER_TOP_LEFT_Y);
CASE(NS_CORNER_TOP_RIGHT, false, NS_CORNER_TOP_RIGHT_X);
@ -299,8 +299,8 @@ CASE(NS_CORNER_BOTTOM_LEFT, true, NS_CORNER_BOTTOM_LEFT_Y);
// Validation of NS_SIDE_TO_{FULL,HALF}_CORNER.
#define CASE(side, second, result) \
MOZ_STATIC_ASSERT(NS_SIDE_TO_FULL_CORNER(side, second) == result, \
"NS_SIDE_TO_FULL_CORNER is wrong")
static_assert(NS_SIDE_TO_FULL_CORNER(side, second) == result, \
"NS_SIDE_TO_FULL_CORNER is wrong")
CASE(NS_SIDE_TOP, false, NS_CORNER_TOP_LEFT);
CASE(NS_SIDE_TOP, true, NS_CORNER_TOP_RIGHT);
@ -315,8 +315,8 @@ CASE(NS_SIDE_LEFT, true, NS_CORNER_TOP_LEFT);
#undef CASE
#define CASE(side, second, parallel, result) \
MOZ_STATIC_ASSERT(NS_SIDE_TO_HALF_CORNER(side, second, parallel) == result, \
"NS_SIDE_TO_HALF_CORNER is wrong")
static_assert(NS_SIDE_TO_HALF_CORNER(side, second, parallel) == result, \
"NS_SIDE_TO_HALF_CORNER is wrong")
CASE(NS_SIDE_TOP, false, true, NS_CORNER_TOP_LEFT_X);
CASE(NS_SIDE_TOP, false, false, NS_CORNER_TOP_LEFT_Y);
CASE(NS_SIDE_TOP, true, true, NS_CORNER_TOP_RIGHT_X);

View File

@ -29,9 +29,9 @@
#include "mozilla/Likely.h"
#include <algorithm>
MOZ_STATIC_ASSERT((((1 << nsStyleStructID_Length) - 1) &
~(NS_STYLE_INHERIT_MASK)) == 0,
"Not enough bits in NS_STYLE_INHERIT_MASK");
static_assert((((1 << nsStyleStructID_Length) - 1) &
~(NS_STYLE_INHERIT_MASK)) == 0,
"Not enough bits in NS_STYLE_INHERIT_MASK");
inline bool IsFixedUnit(const nsStyleCoord& aCoord, bool aEnumOK)
{
@ -2101,12 +2101,12 @@ void nsTimingFunction::AssignFromKeyword(int32_t aTimingFunctionType)
break;
}
MOZ_STATIC_ASSERT(NS_STYLE_TRANSITION_TIMING_FUNCTION_EASE == 0 &&
NS_STYLE_TRANSITION_TIMING_FUNCTION_LINEAR == 1 &&
NS_STYLE_TRANSITION_TIMING_FUNCTION_EASE_IN == 2 &&
NS_STYLE_TRANSITION_TIMING_FUNCTION_EASE_OUT == 3 &&
NS_STYLE_TRANSITION_TIMING_FUNCTION_EASE_IN_OUT == 4,
"transition timing function constants not as expected");
static_assert(NS_STYLE_TRANSITION_TIMING_FUNCTION_EASE == 0 &&
NS_STYLE_TRANSITION_TIMING_FUNCTION_LINEAR == 1 &&
NS_STYLE_TRANSITION_TIMING_FUNCTION_EASE_IN == 2 &&
NS_STYLE_TRANSITION_TIMING_FUNCTION_EASE_OUT == 3 &&
NS_STYLE_TRANSITION_TIMING_FUNCTION_EASE_IN_OUT == 4,
"transition timing function constants not as expected");
static const float timingFunctionValues[5][4] = {
{ 0.25f, 0.10f, 0.25f, 1.00f }, // ease

View File

@ -160,7 +160,7 @@ nsStyleUtil::AppendBitmaskCSSValue(nsCSSProperty aProperty,
nsStyleUtil::AppendPaintOrderValue(uint8_t aValue,
nsAString& aResult)
{
MOZ_STATIC_ASSERT
static_assert
(NS_STYLE_PAINT_ORDER_BITWIDTH * NS_STYLE_PAINT_ORDER_LAST_VALUE <= 8,
"SVGStyleStruct::mPaintOrder and local variables not big enough");
@ -170,8 +170,8 @@ nsStyleUtil::AppendPaintOrderValue(uint8_t aValue,
}
// Append the minimal value necessary for the given paint order.
MOZ_STATIC_ASSERT(NS_STYLE_PAINT_ORDER_LAST_VALUE == 3,
"paint-order values added; check serialization");
static_assert(NS_STYLE_PAINT_ORDER_LAST_VALUE == 3,
"paint-order values added; check serialization");
// The following relies on the default order being the order of the
// constant values.

View File

@ -37,8 +37,8 @@ static nsCellMap::CellDataArray * sEmptyRow;
CellData::CellData(nsTableCellFrame* aOrigCell)
{
MOZ_COUNT_CTOR(CellData);
MOZ_STATIC_ASSERT(sizeof(mOrigCell) == sizeof(mBits),
"mOrigCell and mBits must be the same size");
static_assert(sizeof(mOrigCell) == sizeof(mBits),
"mOrigCell and mBits must be the same size");
mOrigCell = aOrigCell;
}

View File

@ -37,8 +37,8 @@ mozalloc_handle_oom(size_t size)
if (gAbortHandler)
gAbortHandler(size);
MOZ_STATIC_ASSERT(OOM_MSG_FIRST_DIGIT_OFFSET > 0,
"Loop below will never terminate (i can't go below 0)");
static_assert(OOM_MSG_FIRST_DIGIT_OFFSET > 0,
"Loop below will never terminate (i can't go below 0)");
// Insert size into the diagnostic message using only primitive operations
for (i = OOM_MSG_LAST_DIGIT_OFFSET;

View File

@ -706,8 +706,8 @@ struct IntrinsicBase
typedef T ValueType;
typedef PrimitiveIntrinsics<sizeof(T)> Primitives;
typedef typename Primitives::Type PrimType;
MOZ_STATIC_ASSERT(sizeof(PrimType) == sizeof(T),
"Selection of PrimitiveIntrinsics was wrong");
static_assert(sizeof(PrimType) == sizeof(T),
"Selection of PrimitiveIntrinsics was wrong");
typedef CastHelper<PrimType, T> Cast;
};
@ -898,10 +898,10 @@ class Atomic : public detail::AtomicBase<T, Order>
{
// We only support 32-bit types on 32-bit Windows, which constrains our
// implementation elsewhere. But we support pointer-sized types everywhere.
MOZ_STATIC_ASSERT(sizeof(T) == 4 || (sizeof(uintptr_t) == 8 && sizeof(T) == 8),
"mozilla/Atomics.h only supports 32-bit and pointer-sized types");
static_assert(sizeof(T) == 4 || (sizeof(uintptr_t) == 8 && sizeof(T) == 8),
"mozilla/Atomics.h only supports 32-bit and pointer-sized types");
// Regardless of the OS, we only support integral types here.
MOZ_STATIC_ASSERT(IsIntegral<T>::value, "can only have integral atomic variables");
static_assert(IsIntegral<T>::value, "can only have integral atomic variables");
typedef typename detail::AtomicBase<T, Order> Base;

View File

@ -106,7 +106,7 @@ class BloomFilter
*/
public:
BloomFilter() {
MOZ_STATIC_ASSERT(KeySize <= keyShift, "KeySize too big");
static_assert(KeySize <= keyShift, "KeySize too big");
// Should we have a custom operator new using calloc instead and
// require that we're allocated via the operator?

View File

@ -27,8 +27,8 @@ template<typename To, typename From>
inline To
BitwiseCast(const From from)
{
MOZ_STATIC_ASSERT(sizeof(From) == sizeof(To),
"To and From must have the same size");
static_assert(sizeof(From) == sizeof(To),
"To and From must have the same size");
union {
From from;
To to;

View File

@ -50,8 +50,8 @@
*/
#define MOZ_UTF16(s) MOZ_UTF16_HELPER(s)
MOZ_STATIC_ASSERT(sizeof(char16_t) == 2, "Is char16_t type 16 bits?");
MOZ_STATIC_ASSERT(sizeof(MOZ_UTF16('A')) == 2, "Is char literal 16 bits?");
MOZ_STATIC_ASSERT(sizeof(MOZ_UTF16("")[0]) == 2, "Is string char 16 bits?");
static_assert(sizeof(char16_t) == 2, "Is char16_t type 16 bits?");
static_assert(sizeof(MOZ_UTF16('A')) == 2, "Is char literal 16 bits?");
static_assert(sizeof(MOZ_UTF16("")[0]) == 2, "Is string char 16 bits?");
#endif /* mozilla_Char16_h */

View File

@ -18,7 +18,6 @@
# include "mozilla/Assertions.h"
#else
# include <cassert>
# define MOZ_STATIC_ASSERT(cond, reason) assert((cond) && reason)
# define MOZ_ASSERT(cond, reason) assert((cond) && reason)
# define MOZ_DELETE
#endif
@ -600,9 +599,9 @@ class CheckedInt
template<typename U>
CheckedInt(U value, bool isValid) : mValue(value), mIsValid(isValid)
{
MOZ_STATIC_ASSERT(detail::IsSupported<T>::value &&
detail::IsSupported<U>::value,
"This type is not supported by CheckedInt");
static_assert(detail::IsSupported<T>::value &&
detail::IsSupported<U>::value,
"This type is not supported by CheckedInt");
}
friend struct detail::NegateImpl<T>;
@ -624,9 +623,9 @@ class CheckedInt
: mValue(T(value)),
mIsValid(detail::IsInRange<T>(value))
{
MOZ_STATIC_ASSERT(detail::IsSupported<T>::value &&
detail::IsSupported<U>::value,
"This type is not supported by CheckedInt");
static_assert(detail::IsSupported<T>::value &&
detail::IsSupported<U>::value,
"This type is not supported by CheckedInt");
}
template<typename U>
@ -643,8 +642,8 @@ class CheckedInt
/** Constructs a valid checked integer with initial value 0 */
CheckedInt() : mValue(0), mIsValid(true)
{
MOZ_STATIC_ASSERT(detail::IsSupported<T>::value,
"This type is not supported by CheckedInt");
static_assert(detail::IsSupported<T>::value,
"This type is not supported by CheckedInt");
}
/** @returns the actual value */
@ -817,9 +816,9 @@ template<typename T, typename U>
inline typename detail::CastToCheckedIntImpl<T, U>::ReturnType
castToCheckedInt(U u)
{
MOZ_STATIC_ASSERT(detail::IsSupported<T>::value &&
detail::IsSupported<U>::value,
"This type is not supported by CheckedInt");
static_assert(detail::IsSupported<T>::value &&
detail::IsSupported<U>::value,
"This type is not supported by CheckedInt");
return detail::CastToCheckedIntImpl<T, U>::run(u);
}

View File

@ -38,7 +38,7 @@ namespace mozilla {
* the case. But we required this in implementations of these algorithms that
* preceded this header, so we shouldn't break anything if we continue doing so.
*/
MOZ_STATIC_ASSERT(sizeof(double) == sizeof(uint64_t), "double must be 64 bits");
static_assert(sizeof(double) == sizeof(uint64_t), "double must be 64 bits");
const unsigned DoubleExponentBias = 1023;
const unsigned DoubleExponentShift = 52;
@ -47,16 +47,16 @@ const uint64_t DoubleSignBit = 0x8000000000000000ULL;
const uint64_t DoubleExponentBits = 0x7ff0000000000000ULL;
const uint64_t DoubleSignificandBits = 0x000fffffffffffffULL;
MOZ_STATIC_ASSERT((DoubleSignBit & DoubleExponentBits) == 0,
"sign bit doesn't overlap exponent bits");
MOZ_STATIC_ASSERT((DoubleSignBit & DoubleSignificandBits) == 0,
"sign bit doesn't overlap significand bits");
MOZ_STATIC_ASSERT((DoubleExponentBits & DoubleSignificandBits) == 0,
"exponent bits don't overlap significand bits");
static_assert((DoubleSignBit & DoubleExponentBits) == 0,
"sign bit doesn't overlap exponent bits");
static_assert((DoubleSignBit & DoubleSignificandBits) == 0,
"sign bit doesn't overlap significand bits");
static_assert((DoubleExponentBits & DoubleSignificandBits) == 0,
"exponent bits don't overlap significand bits");
MOZ_STATIC_ASSERT((DoubleSignBit | DoubleExponentBits | DoubleSignificandBits) ==
~uint64_t(0),
"all bits accounted for");
static_assert((DoubleSignBit | DoubleExponentBits | DoubleSignificandBits) ==
~uint64_t(0),
"all bits accounted for");
/** Determines whether a double is NaN. */
static MOZ_ALWAYS_INLINE bool

View File

@ -175,8 +175,8 @@ AddToHash(uint32_t hash, A* a)
* catch data pointers and couldn't handle function pointers.
*/
MOZ_STATIC_ASSERT(sizeof(a) == sizeof(uintptr_t),
"Strange pointer!");
static_assert(sizeof(a) == sizeof(uintptr_t),
"Strange pointer!");
return detail::AddUintptrToHash<sizeof(uintptr_t)>(hash, uintptr_t(a));
}

View File

@ -142,8 +142,8 @@ GetDesiredRegionSize()
#endif // system dependencies
MOZ_STATIC_ASSERT(sizeof(uintptr_t) == 4 || sizeof(uintptr_t) == 8, "");
MOZ_STATIC_ASSERT(sizeof(uintptr_t) == sizeof(void *), "");
static_assert(sizeof(uintptr_t) == 4 || sizeof(uintptr_t) == 8, "");
static_assert(sizeof(uintptr_t) == sizeof(void *), "");
static uintptr_t
ReservePoisonArea(uintptr_t rgnsize)

View File

@ -103,8 +103,8 @@ class RefCounted : public detail::RefCounted<T, detail::NonAtomicRefCount>
{
public:
~RefCounted() {
MOZ_STATIC_ASSERT((IsBaseOf<RefCounted, T>::value),
"T must derive from RefCounted<T>");
static_assert(IsBaseOf<RefCounted, T>::value,
"T must derive from RefCounted<T>");
}
};
@ -117,8 +117,8 @@ class AtomicRefCounted : public detail::RefCounted<T, detail::AtomicRefCount>
{
public:
~AtomicRefCounted() {
MOZ_STATIC_ASSERT((IsBaseOf<AtomicRefCounted, T>::value),
"T must derive from AtomicRefCounted<T>");
static_assert(IsBaseOf<AtomicRefCounted, T>::value,
"T must derive from AtomicRefCounted<T>");
}
};

View File

@ -100,9 +100,9 @@ template<typename T>
inline bool
ThreadLocal<T>::init()
{
MOZ_STATIC_ASSERT(sizeof(T) <= sizeof(void*),
"mozilla::ThreadLocal can't be used for types larger than "
"a pointer");
static_assert(sizeof(T) <= sizeof(void*),
"mozilla::ThreadLocal can't be used for types larger than "
"a pointer");
MOZ_ASSERT(!initialized());
#ifdef XP_WIN
key = TlsAlloc();

View File

@ -324,7 +324,7 @@ ArrayEnd(T (&arr)[N])
/*
* MOZ_ARRAY_LENGTH() is an alternative to mozilla::ArrayLength() for C files
* that can't use C++ template functions and for MOZ_STATIC_ASSERT() calls that
* that can't use C++ template functions and for static_assert() calls that
* can't call ArrayLength() when it is not a C++11 constexpr function.
*/
#ifdef MOZ_HAVE_CXX11_CONSTEXPR

View File

@ -1121,8 +1121,8 @@ template<typename T, size_t N, class AP, class TV>
inline void
VectorBase<T, N, AP, TV>::swap(TV& other)
{
MOZ_STATIC_ASSERT(N == 0,
"still need to implement this for N != 0");
static_assert(N == 0,
"still need to implement this for N != 0");
// This only works when inline storage is always empty.
if (!usingInlineStorage() && other.usingInlineStorage()) {

View File

@ -108,8 +108,8 @@ class SupportsWeakPtrBase
protected:
~SupportsWeakPtrBase() {
MOZ_STATIC_ASSERT((IsBaseOf<SupportsWeakPtrBase<T, WeakReference>, T>::value),
"T must derive from SupportsWeakPtrBase<T, WeakReference>");
static_assert(IsBaseOf<SupportsWeakPtrBase<T, WeakReference>, T>::value,
"T must derive from SupportsWeakPtrBase<T, WeakReference>");
if (weakRef)
weakRef->detach();
}

View File

@ -193,9 +193,9 @@ main()
{ 0xc8, 0xf2, 0x09, 0x59, 0x4e, 0x64, 0x40, 0xaa, 0x7b, 0xf7, 0xb8, 0xe0,
0xfa, 0x44, 0xb2, 0x31, 0x95, 0xad, 0x94, 0x81 };
MOZ_STATIC_ASSERT(sizeof(expected) == sizeof(SHA1Sum::Hash),
"expected-data size should be the same as the actual hash "
"size");
static_assert(sizeof(expected) == sizeof(SHA1Sum::Hash),
"expected-data size should be the same as the actual hash "
"size");
for (size_t i = 0; i < SHA1Sum::HashSize; i++)
MOZ_ASSERT(hash[i] == expected[i]);

View File

@ -14,54 +14,54 @@ using mozilla::IsUnsigned;
using mozilla::MakeSigned;
using mozilla::MakeUnsigned;
MOZ_STATIC_ASSERT(!IsSigned<bool>::value, "bool shouldn't be signed");
MOZ_STATIC_ASSERT(IsUnsigned<bool>::value, "bool should be unsigned");
static_assert(!IsSigned<bool>::value, "bool shouldn't be signed");
static_assert(IsUnsigned<bool>::value, "bool should be unsigned");
MOZ_STATIC_ASSERT(!IsSigned<const bool>::value, "const bool shouldn't be signed");
MOZ_STATIC_ASSERT(IsUnsigned<const bool>::value, "const bool should be unsigned");
static_assert(!IsSigned<const bool>::value, "const bool shouldn't be signed");
static_assert(IsUnsigned<const bool>::value, "const bool should be unsigned");
MOZ_STATIC_ASSERT(!IsSigned<volatile bool>::value, "volatile bool shouldn't be signed");
MOZ_STATIC_ASSERT(IsUnsigned<volatile bool>::value, "volatile bool should be unsigned");
static_assert(!IsSigned<volatile bool>::value, "volatile bool shouldn't be signed");
static_assert(IsUnsigned<volatile bool>::value, "volatile bool should be unsigned");
MOZ_STATIC_ASSERT(!IsSigned<unsigned char>::value, "unsigned char shouldn't be signed");
MOZ_STATIC_ASSERT(IsUnsigned<unsigned char>::value, "unsigned char should be unsigned");
MOZ_STATIC_ASSERT(IsSigned<signed char>::value, "signed char should be signed");
MOZ_STATIC_ASSERT(!IsUnsigned<signed char>::value, "signed char shouldn't be unsigned");
static_assert(!IsSigned<unsigned char>::value, "unsigned char shouldn't be signed");
static_assert(IsUnsigned<unsigned char>::value, "unsigned char should be unsigned");
static_assert(IsSigned<signed char>::value, "signed char should be signed");
static_assert(!IsUnsigned<signed char>::value, "signed char shouldn't be unsigned");
MOZ_STATIC_ASSERT(!IsSigned<unsigned short>::value, "unsigned short shouldn't be signed");
MOZ_STATIC_ASSERT(IsUnsigned<unsigned short>::value, "unsigned short should be unsigned");
MOZ_STATIC_ASSERT(IsSigned<short>::value, "short should be signed");
MOZ_STATIC_ASSERT(!IsUnsigned<short>::value, "short shouldn't be unsigned");
static_assert(!IsSigned<unsigned short>::value, "unsigned short shouldn't be signed");
static_assert(IsUnsigned<unsigned short>::value, "unsigned short should be unsigned");
static_assert(IsSigned<short>::value, "short should be signed");
static_assert(!IsUnsigned<short>::value, "short shouldn't be unsigned");
MOZ_STATIC_ASSERT(!IsSigned<unsigned int>::value, "unsigned int shouldn't be signed");
MOZ_STATIC_ASSERT(IsUnsigned<unsigned int>::value, "unsigned int should be unsigned");
MOZ_STATIC_ASSERT(IsSigned<int>::value, "int should be signed");
MOZ_STATIC_ASSERT(!IsUnsigned<int>::value, "int shouldn't be unsigned");
static_assert(!IsSigned<unsigned int>::value, "unsigned int shouldn't be signed");
static_assert(IsUnsigned<unsigned int>::value, "unsigned int should be unsigned");
static_assert(IsSigned<int>::value, "int should be signed");
static_assert(!IsUnsigned<int>::value, "int shouldn't be unsigned");
MOZ_STATIC_ASSERT(!IsSigned<unsigned long>::value, "unsigned long shouldn't be signed");
MOZ_STATIC_ASSERT(IsUnsigned<unsigned long>::value, "unsigned long should be unsigned");
MOZ_STATIC_ASSERT(IsSigned<long>::value, "long should be signed");
MOZ_STATIC_ASSERT(!IsUnsigned<long>::value, "long shouldn't be unsigned");
static_assert(!IsSigned<unsigned long>::value, "unsigned long shouldn't be signed");
static_assert(IsUnsigned<unsigned long>::value, "unsigned long should be unsigned");
static_assert(IsSigned<long>::value, "long should be signed");
static_assert(!IsUnsigned<long>::value, "long shouldn't be unsigned");
MOZ_STATIC_ASSERT(IsSigned<float>::value, "float should be signed");
MOZ_STATIC_ASSERT(!IsUnsigned<float>::value, "float shouldn't be unsigned");
static_assert(IsSigned<float>::value, "float should be signed");
static_assert(!IsUnsigned<float>::value, "float shouldn't be unsigned");
MOZ_STATIC_ASSERT(IsSigned<const float>::value, "const float should be signed");
MOZ_STATIC_ASSERT(!IsUnsigned<const float>::value, "const float shouldn't be unsigned");
static_assert(IsSigned<const float>::value, "const float should be signed");
static_assert(!IsUnsigned<const float>::value, "const float shouldn't be unsigned");
MOZ_STATIC_ASSERT(IsSigned<double>::value, "double should be signed");
MOZ_STATIC_ASSERT(!IsUnsigned<double>::value, "double shouldn't be unsigned");
static_assert(IsSigned<double>::value, "double should be signed");
static_assert(!IsUnsigned<double>::value, "double shouldn't be unsigned");
MOZ_STATIC_ASSERT(IsSigned<volatile double>::value, "volatile double should be signed");
MOZ_STATIC_ASSERT(!IsUnsigned<volatile double>::value, "volatile double shouldn't be unsigned");
static_assert(IsSigned<volatile double>::value, "volatile double should be signed");
static_assert(!IsUnsigned<volatile double>::value, "volatile double shouldn't be unsigned");
MOZ_STATIC_ASSERT(IsSigned<long double>::value, "long double should be signed");
MOZ_STATIC_ASSERT(!IsUnsigned<long double>::value, "long double shouldn't be unsigned");
static_assert(IsSigned<long double>::value, "long double should be signed");
static_assert(!IsUnsigned<long double>::value, "long double shouldn't be unsigned");
MOZ_STATIC_ASSERT(IsSigned<const volatile long double>::value,
"const volatile long double should be signed");
MOZ_STATIC_ASSERT(!IsUnsigned<const volatile long double>::value,
"const volatile long double shouldn't be unsigned");
static_assert(IsSigned<const volatile long double>::value,
"const volatile long double should be signed");
static_assert(!IsUnsigned<const volatile long double>::value,
"const volatile long double shouldn't be unsigned");
namespace CPlusPlus11IsBaseOf {
@ -153,56 +153,56 @@ TestIsConvertible()
// "C doesn't convert to A (private inheritance)");
}
MOZ_STATIC_ASSERT((IsSame<MakeSigned<const unsigned char>::Type, const signed char>::value),
"const unsigned char won't signify correctly");
MOZ_STATIC_ASSERT((IsSame<MakeSigned<volatile unsigned short>::Type, volatile signed short>::value),
"volatile unsigned short won't signify correctly");
MOZ_STATIC_ASSERT((IsSame<MakeSigned<const volatile unsigned int>::Type, const volatile signed int>::value),
"const volatile unsigned int won't signify correctly");
MOZ_STATIC_ASSERT((IsSame<MakeSigned<unsigned long>::Type, signed long>::value),
"unsigned long won't signify correctly");
MOZ_STATIC_ASSERT((IsSame<MakeSigned<const signed char>::Type, const signed char>::value),
"const signed char won't signify correctly");
static_assert(IsSame<MakeSigned<const unsigned char>::Type, const signed char>::value,
"const unsigned char won't signify correctly");
static_assert(IsSame<MakeSigned<volatile unsigned short>::Type, volatile signed short>::value,
"volatile unsigned short won't signify correctly");
static_assert(IsSame<MakeSigned<const volatile unsigned int>::Type, const volatile signed int>::value,
"const volatile unsigned int won't signify correctly");
static_assert(IsSame<MakeSigned<unsigned long>::Type, signed long>::value,
"unsigned long won't signify correctly");
static_assert(IsSame<MakeSigned<const signed char>::Type, const signed char>::value,
"const signed char won't signify correctly");
MOZ_STATIC_ASSERT((IsSame<MakeSigned<volatile signed short>::Type, volatile signed short>::value),
"volatile signed short won't signify correctly");
MOZ_STATIC_ASSERT((IsSame<MakeSigned<const volatile signed int>::Type, const volatile signed int>::value),
"const volatile signed int won't signify correctly");
MOZ_STATIC_ASSERT((IsSame<MakeSigned<signed long>::Type, signed long>::value),
"signed long won't signify correctly");
static_assert(IsSame<MakeSigned<volatile signed short>::Type, volatile signed short>::value,
"volatile signed short won't signify correctly");
static_assert(IsSame<MakeSigned<const volatile signed int>::Type, const volatile signed int>::value,
"const volatile signed int won't signify correctly");
static_assert(IsSame<MakeSigned<signed long>::Type, signed long>::value,
"signed long won't signify correctly");
MOZ_STATIC_ASSERT((IsSame<MakeSigned<char>::Type, signed char>::value),
"char won't signify correctly");
MOZ_STATIC_ASSERT((IsSame<MakeSigned<volatile char>::Type, volatile signed char>::value),
"volatile char won't signify correctly");
MOZ_STATIC_ASSERT((IsSame<MakeSigned<const char>::Type, const signed char>::value),
"const char won't signify correctly");
static_assert(IsSame<MakeSigned<char>::Type, signed char>::value,
"char won't signify correctly");
static_assert(IsSame<MakeSigned<volatile char>::Type, volatile signed char>::value,
"volatile char won't signify correctly");
static_assert(IsSame<MakeSigned<const char>::Type, const signed char>::value,
"const char won't signify correctly");
MOZ_STATIC_ASSERT((IsSame<MakeUnsigned<const signed char>::Type, const unsigned char>::value),
"const signed char won't unsignify correctly");
MOZ_STATIC_ASSERT((IsSame<MakeUnsigned<volatile signed short>::Type, volatile unsigned short>::value),
"volatile signed short won't unsignify correctly");
MOZ_STATIC_ASSERT((IsSame<MakeUnsigned<const volatile signed int>::Type, const volatile unsigned int>::value),
"const volatile signed int won't unsignify correctly");
MOZ_STATIC_ASSERT((IsSame<MakeUnsigned<signed long>::Type, unsigned long>::value),
"signed long won't unsignify correctly");
static_assert(IsSame<MakeUnsigned<const signed char>::Type, const unsigned char>::value,
"const signed char won't unsignify correctly");
static_assert(IsSame<MakeUnsigned<volatile signed short>::Type, volatile unsigned short>::value,
"volatile signed short won't unsignify correctly");
static_assert(IsSame<MakeUnsigned<const volatile signed int>::Type, const volatile unsigned int>::value,
"const volatile signed int won't unsignify correctly");
static_assert(IsSame<MakeUnsigned<signed long>::Type, unsigned long>::value,
"signed long won't unsignify correctly");
MOZ_STATIC_ASSERT((IsSame<MakeUnsigned<const unsigned char>::Type, const unsigned char>::value),
"const unsigned char won't unsignify correctly");
static_assert(IsSame<MakeUnsigned<const unsigned char>::Type, const unsigned char>::value,
"const unsigned char won't unsignify correctly");
MOZ_STATIC_ASSERT((IsSame<MakeUnsigned<volatile unsigned short>::Type, volatile unsigned short>::value),
"volatile unsigned short won't unsignify correctly");
MOZ_STATIC_ASSERT((IsSame<MakeUnsigned<const volatile unsigned int>::Type, const volatile unsigned int>::value),
"const volatile unsigned int won't unsignify correctly");
MOZ_STATIC_ASSERT((IsSame<MakeUnsigned<unsigned long>::Type, unsigned long>::value),
"signed long won't unsignify correctly");
static_assert(IsSame<MakeUnsigned<volatile unsigned short>::Type, volatile unsigned short>::value,
"volatile unsigned short won't unsignify correctly");
static_assert(IsSame<MakeUnsigned<const volatile unsigned int>::Type, const volatile unsigned int>::value,
"const volatile unsigned int won't unsignify correctly");
static_assert(IsSame<MakeUnsigned<unsigned long>::Type, unsigned long>::value,
"signed long won't unsignify correctly");
MOZ_STATIC_ASSERT((IsSame<MakeUnsigned<char>::Type, unsigned char>::value),
"char won't unsignify correctly");
MOZ_STATIC_ASSERT((IsSame<MakeUnsigned<volatile char>::Type, volatile unsigned char>::value),
"volatile char won't unsignify correctly");
MOZ_STATIC_ASSERT((IsSame<MakeUnsigned<const char>::Type, const unsigned char>::value),
"const char won't unsignify correctly");
static_assert(IsSame<MakeUnsigned<char>::Type, unsigned char>::value,
"char won't unsignify correctly");
static_assert(IsSame<MakeUnsigned<volatile char>::Type, volatile unsigned char>::value,
"volatile char won't unsignify correctly");
static_assert(IsSame<MakeUnsigned<const char>::Type, const unsigned char>::value,
"const char won't unsignify correctly");
int
main()

View File

@ -52,8 +52,8 @@ struct SeekableZStreamHeader: public Zip::SignedEntity<SeekableZStreamHeader>
};
#pragma pack()
MOZ_STATIC_ASSERT(sizeof(SeekableZStreamHeader) == 5 * 4,
"SeekableZStreamHeader should be 5 32-bits words");
static_assert(sizeof(SeekableZStreamHeader) == 5 * 4,
"SeekableZStreamHeader should be 5 32-bits words");
/**
* Helper class used to decompress Seekable ZStreams.

View File

@ -46,8 +46,8 @@ void
nsDomainEntry::FuncForStaticAsserts(void)
{
#define ETLD_ENTRY(name, ex, wild) \
MOZ_STATIC_ASSERT(ETLD_ENTRY_OFFSET(name) < (1 << ETLD_ENTRY_N_INDEX_BITS), \
"invalid strtab index");
static_assert(ETLD_ENTRY_OFFSET(name) < (1 << ETLD_ENTRY_N_INDEX_BITS), \
"invalid strtab index");
#include "etld_data.inc"
#undef ETLD_ENTRY
}

View File

@ -558,7 +558,7 @@ SpdySession3::EnsureBuffer(nsAutoArrayPtr<T> &buf,
objSize = (newSize + 2048 + 4095) & ~4095;
MOZ_STATIC_ASSERT(sizeof(T) == 1, "sizeof(T) must be 1");
static_assert(sizeof(T) == 1, "sizeof(T) must be 1");
nsAutoArrayPtr<T> tmp(new T[objSize]);
memcpy(tmp, buf, preserve);
buf = tmp;

View File

@ -37,8 +37,8 @@ public:
template <size_t LEN>
nsresult Dispatch(const char (&taskThreadName)[LEN])
{
MOZ_STATIC_ASSERT(LEN <= 15,
"Thread name must be no more than 15 characters");
static_assert(LEN <= 15,
"Thread name must be no more than 15 characters");
return Dispatch(nsDependentCString(taskThreadName));
}

View File

@ -92,7 +92,7 @@ FindAndLoadOneEntry(nsIZipReader * zip,
// Also, keep in mind bug 164695 and that we must leave room for
// null-terminating the buffer.
static const uint32_t MAX_LENGTH = 1024 * 1024;
MOZ_STATIC_ASSERT(MAX_LENGTH < UINT32_MAX, "MAX_LENGTH < UINT32_MAX");
static_assert(MAX_LENGTH < UINT32_MAX, "MAX_LENGTH < UINT32_MAX");
NS_ENSURE_TRUE(len64 < MAX_LENGTH, NS_ERROR_FILE_CORRUPTED);
NS_ENSURE_TRUE(len64 < UINT32_MAX, NS_ERROR_FILE_CORRUPTED); // bug 164695
SECITEM_AllocItem(buf, static_cast<uint32_t>(len64 + 1));

View File

@ -1058,11 +1058,11 @@ nsNSSComponent::InitializeNSS(bool showWarningBox)
PR_LOG(gPIPNSSLog, PR_LOG_DEBUG, ("nsNSSComponent::InitializeNSS\n"));
MOZ_STATIC_ASSERT(nsINSSErrorsService::NSS_SEC_ERROR_BASE == SEC_ERROR_BASE &&
nsINSSErrorsService::NSS_SEC_ERROR_LIMIT == SEC_ERROR_LIMIT &&
nsINSSErrorsService::NSS_SSL_ERROR_BASE == SSL_ERROR_BASE &&
nsINSSErrorsService::NSS_SSL_ERROR_LIMIT == SSL_ERROR_LIMIT,
"You must update the values in nsINSSErrorsService.idl");
static_assert(nsINSSErrorsService::NSS_SEC_ERROR_BASE == SEC_ERROR_BASE &&
nsINSSErrorsService::NSS_SEC_ERROR_LIMIT == SEC_ERROR_LIMIT &&
nsINSSErrorsService::NSS_SSL_ERROR_BASE == SSL_ERROR_BASE &&
nsINSSErrorsService::NSS_SSL_ERROR_LIMIT == SSL_ERROR_LIMIT,
"You must update the values in nsINSSErrorsService.idl");
// variables used for flow control within this function

View File

@ -455,9 +455,9 @@ GenerateDSAKeyPair(PK11SlotInfo * slot,
0x72,0xDF,0xFA,0x89,0x62,0x33,0x39,0x7A
};
MOZ_STATIC_ASSERT(MOZ_ARRAY_LENGTH(P) == 1024 / CHAR_BIT, "bad DSA P");
MOZ_STATIC_ASSERT(MOZ_ARRAY_LENGTH(Q) == 160 / CHAR_BIT, "bad DSA Q");
MOZ_STATIC_ASSERT(MOZ_ARRAY_LENGTH(G) == 1024 / CHAR_BIT, "bad DSA G");
static_assert(MOZ_ARRAY_LENGTH(P) == 1024 / CHAR_BIT, "bad DSA P");
static_assert(MOZ_ARRAY_LENGTH(Q) == 160 / CHAR_BIT, "bad DSA Q");
static_assert(MOZ_ARRAY_LENGTH(G) == 1024 / CHAR_BIT, "bad DSA G");
PQGParams pqgParams = {
NULL /*arena*/,

View File

@ -757,9 +757,9 @@ nsXULAppInfo::GetWidgetToolkit(nsACString& aResult)
// is synchronized with the const unsigned longs defined in
// xpcom/system/nsIXULRuntime.idl.
#define SYNC_ENUMS(a,b) \
MOZ_STATIC_ASSERT(nsIXULRuntime::PROCESS_TYPE_ ## a == \
static_cast<int>(GeckoProcessType_ ## b), \
"GeckoProcessType in nsXULAppAPI.h not synchronized with nsIXULRuntime.idl");
static_assert(nsIXULRuntime::PROCESS_TYPE_ ## a == \
static_cast<int>(GeckoProcessType_ ## b), \
"GeckoProcessType in nsXULAppAPI.h not synchronized with nsIXULRuntime.idl");
SYNC_ENUMS(DEFAULT, Default)
SYNC_ENUMS(PLUGIN, Plugin)
@ -767,8 +767,8 @@ SYNC_ENUMS(CONTENT, Content)
SYNC_ENUMS(IPDLUNITTEST, IPDLUnitTest)
// .. and ensure that that is all of them:
MOZ_STATIC_ASSERT(GeckoProcessType_IPDLUnitTest + 1 == GeckoProcessType_End,
"Did not find the final GeckoProcessType");
static_assert(GeckoProcessType_IPDLUnitTest + 1 == GeckoProcessType_End,
"Did not find the final GeckoProcessType");
NS_IMETHODIMP
nsXULAppInfo::GetProcessType(uint32_t* aResult)

View File

@ -217,10 +217,10 @@ utb__addEntry(/*MODIFIED*/UnwinderThreadBuffer* utb, ProfileEntry ent)
//////////////////////////////////////////////////////////
//// BEGIN type UnwindThreadBuffer
MOZ_STATIC_ASSERT(sizeof(uint32_t) == 4, "uint32_t size incorrect");
MOZ_STATIC_ASSERT(sizeof(uint64_t) == 8, "uint64_t size incorrect");
MOZ_STATIC_ASSERT(sizeof(uintptr_t) == sizeof(void*),
"uintptr_t size incorrect");
static_assert(sizeof(uint32_t) == 4, "uint32_t size incorrect");
static_assert(sizeof(uint64_t) == 8, "uint64_t size incorrect");
static_assert(sizeof(uintptr_t) == sizeof(void*),
"uintptr_t size incorrect");
typedef
struct {

View File

@ -401,18 +401,18 @@ private:
void
GeckoInputReaderPolicy::setDisplayInfo()
{
MOZ_STATIC_ASSERT(nsIScreen::ROTATION_0_DEG ==
DISPLAY_ORIENTATION_0,
"Orientation enums not matched!");
MOZ_STATIC_ASSERT(nsIScreen::ROTATION_90_DEG ==
DISPLAY_ORIENTATION_90,
"Orientation enums not matched!");
MOZ_STATIC_ASSERT(nsIScreen::ROTATION_180_DEG ==
DISPLAY_ORIENTATION_180,
"Orientation enums not matched!");
MOZ_STATIC_ASSERT(nsIScreen::ROTATION_270_DEG ==
DISPLAY_ORIENTATION_270,
"Orientation enums not matched!");
static_assert(nsIScreen::ROTATION_0_DEG ==
DISPLAY_ORIENTATION_0,
"Orientation enums not matched!");
static_assert(nsIScreen::ROTATION_90_DEG ==
DISPLAY_ORIENTATION_90,
"Orientation enums not matched!");
static_assert(nsIScreen::ROTATION_180_DEG ==
DISPLAY_ORIENTATION_180,
"Orientation enums not matched!");
static_assert(nsIScreen::ROTATION_270_DEG ==
DISPLAY_ORIENTATION_270,
"Orientation enums not matched!");
mConfig.setDisplayInfo(0, false, gScreenBounds.width, gScreenBounds.height, nsScreenGonk::GetRotation());
}

View File

@ -594,7 +594,7 @@ private:
inline void SetRawFlags(RawFlags aRawFlags)
{
MOZ_STATIC_ASSERT(sizeof(BaseEventFlags) <= sizeof(RawFlags),
static_assert(sizeof(BaseEventFlags) <= sizeof(RawFlags),
"mozilla::widget::EventFlags must not be bigger than the RawFlags");
memcpy(this, &aRawFlags, sizeof(BaseEventFlags));
}

View File

@ -264,10 +264,10 @@ MapsReporter::ParseMapping(
{
// We need to use native types in order to get good warnings from fscanf, so
// let's make sure that the native types have the sizes we expect.
MOZ_STATIC_ASSERT(sizeof(long long) == sizeof(int64_t),
"size of (long long) is expected to match (int64_t)");
MOZ_STATIC_ASSERT(sizeof(int) == sizeof(int32_t),
"size of (int) is expected to match (int32_t)");
static_assert(sizeof(long long) == sizeof(int64_t),
"size of (long long) is expected to match (int64_t)");
static_assert(sizeof(int) == sizeof(int32_t),
"size of (int) is expected to match (int32_t)");
// Don't bail if FindLibxul fails. We can still gather meaningful stats
// here.
@ -465,8 +465,8 @@ MapsReporter::ParseMapBody(
nsISupports *aClosure,
CategoriesSeen *aCategoriesSeen)
{
MOZ_STATIC_ASSERT(sizeof(long long) == sizeof(int64_t),
"size of (long long) is expected to match (int64_t)");
static_assert(sizeof(long long) == sizeof(int64_t),
"size of (long long) is expected to match (int64_t)");
const int argCount = 2;

View File

@ -674,7 +674,7 @@ private:
Block() : mNext(nullptr) {
// Ensure Block is the right size (see above).
MOZ_STATIC_ASSERT(
static_assert(
sizeof(Block) == 16384 || // 32-bit
sizeof(Block) == 32768, // 64-bit
"ill-sized nsPurpleBuffer::Block"

View File

@ -4,7 +4,7 @@
// No reason to pull in Assertions.h for every single file that includes
// nsError.h, so let's put this in its own .cpp file instead of in the .h.
MOZ_STATIC_ASSERT(((nsresult)0) < ((nsresult)-1),
"nsresult must be an unsigned type");
MOZ_STATIC_ASSERT(sizeof(nsresult) == sizeof(uint32_t),
"nsresult must be 32 bits");
static_assert(((nsresult)0) < ((nsresult)-1),
"nsresult must be an unsigned type");
static_assert(sizeof(nsresult) == sizeof(uint32_t),
"nsresult must be 32 bits");

Some files were not shown because too many files have changed in this diff Show More