cdf0c2e801
Unfortunately, different runtime libraries and/or compilers differ on whether a class without any copy constructor, move constructor, copy assignment and move assignment operator is considered trivially copyable. See discussion on https://crrev.com/c/941521. This CL adds a comment about this, and deletes a test for this specific case. R=mstarzinger@chromium.org CC=jyan@ca.ibm.com, ivica.bogosavljevic@mips.com Change-Id: Ie07adda370e5e955b782e72356b50121477d4623 Reviewed-on: https://chromium-review.googlesource.com/944081 Commit-Queue: Clemens Hammacher <clemensh@chromium.org> Reviewed-by: Michael Starzinger <mstarzinger@chromium.org> Cr-Commit-Position: refs/heads/master@{#51704}
62 lines
1.9 KiB
C++
62 lines
1.9 KiB
C++
// Copyright 2017 the V8 project authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
#include "src/base/macros.h"
|
|
#include "testing/gtest/include/gtest/gtest.h"
|
|
|
|
namespace v8 {
|
|
namespace base {
|
|
|
|
TEST(AlignedAddressTest, AlignedAddress) {
|
|
EXPECT_EQ(reinterpret_cast<void*>(0xFFFF0),
|
|
AlignedAddress(reinterpret_cast<void*>(0xFFFF0), 16));
|
|
EXPECT_EQ(reinterpret_cast<void*>(0xFFFF0),
|
|
AlignedAddress(reinterpret_cast<void*>(0xFFFF2), 16));
|
|
EXPECT_EQ(reinterpret_cast<void*>(0xFFFF0),
|
|
AlignedAddress(reinterpret_cast<void*>(0xFFFF2), 16));
|
|
EXPECT_EQ(reinterpret_cast<void*>(0xFFFF0),
|
|
AlignedAddress(reinterpret_cast<void*>(0xFFFFF), 16));
|
|
EXPECT_EQ(reinterpret_cast<void*>(0x0),
|
|
AlignedAddress(reinterpret_cast<void*>(0xFFFFF), 0x100000));
|
|
}
|
|
|
|
struct TriviallyCopyable {
|
|
const int i;
|
|
};
|
|
ASSERT_TRIVIALLY_COPYABLE(TriviallyCopyable);
|
|
|
|
struct StillTriviallyCopyable {
|
|
const int i;
|
|
StillTriviallyCopyable(const StillTriviallyCopyable&) = delete;
|
|
};
|
|
ASSERT_TRIVIALLY_COPYABLE(StillTriviallyCopyable);
|
|
|
|
struct NonTrivialDestructor {
|
|
~NonTrivialDestructor() {}
|
|
};
|
|
ASSERT_NOT_TRIVIALLY_COPYABLE(NonTrivialDestructor);
|
|
|
|
struct NonTrivialCopyConstructor {
|
|
NonTrivialCopyConstructor(const NonTrivialCopyConstructor&) {}
|
|
};
|
|
ASSERT_NOT_TRIVIALLY_COPYABLE(NonTrivialCopyConstructor);
|
|
|
|
struct NonTrivialMoveConstructor {
|
|
NonTrivialMoveConstructor(const NonTrivialMoveConstructor&) {}
|
|
};
|
|
ASSERT_NOT_TRIVIALLY_COPYABLE(NonTrivialMoveConstructor);
|
|
|
|
struct NonTrivialCopyAssignment {
|
|
NonTrivialCopyAssignment(const NonTrivialCopyAssignment&) {}
|
|
};
|
|
ASSERT_NOT_TRIVIALLY_COPYABLE(NonTrivialCopyAssignment);
|
|
|
|
struct NonTrivialMoveAssignment {
|
|
NonTrivialMoveAssignment(const NonTrivialMoveAssignment&) {}
|
|
};
|
|
ASSERT_NOT_TRIVIALLY_COPYABLE(NonTrivialMoveAssignment);
|
|
|
|
} // namespace base
|
|
} // namespace v8
|