[llvm] r284812 - [Support] Fix AlignOf test on i386-linux.
Benjamin Kramer via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 21 02:15:57 PDT 2016
Author: d0k
Date: Fri Oct 21 04:15:57 2016
New Revision: 284812
URL: http://llvm.org/viewvc/llvm-project?rev=284812&view=rev
Log:
[Support] Fix AlignOf test on i386-linux.
On i386 alignof(double) = 8 is not the same as alignof(struct { double
}) = 4. This used to be not an issue because the old implementation
always measured alignment inside of structs. Wrap a dummy struct around
the test to avoid this issue.
Modified:
llvm/trunk/unittests/Support/AlignOfTest.cpp
Modified: llvm/trunk/unittests/Support/AlignOfTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Support/AlignOfTest.cpp?rev=284812&r1=284811&r2=284812&view=diff
==============================================================================
--- llvm/trunk/unittests/Support/AlignOfTest.cpp (original)
+++ llvm/trunk/unittests/Support/AlignOfTest.cpp Fri Oct 21 04:15:57 2016
@@ -89,6 +89,8 @@ V6::~V6() {}
V7::~V7() {}
V8::~V8() {}
+template <typename M> struct T { M m; };
+
TEST(AlignOfTest, BasicAlignedArray) {
EXPECT_LE(1u, alignof(AlignedCharArrayUnion<A1>));
EXPECT_LE(2u, alignof(AlignedCharArrayUnion<A2>));
@@ -124,19 +126,20 @@ TEST(AlignOfTest, BasicAlignedArray) {
// For other tests we simply assert that the alignment of the union mathes
// that of the fundamental type and hope that we have any weird type
// productions that would trigger bugs.
- EXPECT_EQ(alignof(char), alignof(AlignedCharArrayUnion<char>));
- EXPECT_EQ(alignof(short), alignof(AlignedCharArrayUnion<short>));
- EXPECT_EQ(alignof(int), alignof(AlignedCharArrayUnion<int>));
- EXPECT_EQ(alignof(long), alignof(AlignedCharArrayUnion<long>));
- EXPECT_EQ(alignof(long long), alignof(AlignedCharArrayUnion<long long>));
- EXPECT_EQ(alignof(float), alignof(AlignedCharArrayUnion<float>));
- EXPECT_EQ(alignof(double), alignof(AlignedCharArrayUnion<double>));
- EXPECT_EQ(alignof(long double), alignof(AlignedCharArrayUnion<long double>));
- EXPECT_EQ(alignof(void *), alignof(AlignedCharArrayUnion<void *>));
- EXPECT_EQ(alignof(int *), alignof(AlignedCharArrayUnion<int *>));
- EXPECT_EQ(alignof(double (*)(double)),
+ EXPECT_EQ(alignof(T<char>), alignof(AlignedCharArrayUnion<char>));
+ EXPECT_EQ(alignof(T<short>), alignof(AlignedCharArrayUnion<short>));
+ EXPECT_EQ(alignof(T<int>), alignof(AlignedCharArrayUnion<int>));
+ EXPECT_EQ(alignof(T<long>), alignof(AlignedCharArrayUnion<long>));
+ EXPECT_EQ(alignof(T<long long>), alignof(AlignedCharArrayUnion<long long>));
+ EXPECT_EQ(alignof(T<float>), alignof(AlignedCharArrayUnion<float>));
+ EXPECT_EQ(alignof(T<double>), alignof(AlignedCharArrayUnion<double>));
+ EXPECT_EQ(alignof(T<long double>),
+ alignof(AlignedCharArrayUnion<long double>));
+ EXPECT_EQ(alignof(T<void *>), alignof(AlignedCharArrayUnion<void *>));
+ EXPECT_EQ(alignof(T<int *>), alignof(AlignedCharArrayUnion<int *>));
+ EXPECT_EQ(alignof(T<double (*)(double)>),
alignof(AlignedCharArrayUnion<double (*)(double)>));
- EXPECT_EQ(alignof(double (S6::*)()),
+ EXPECT_EQ(alignof(T<double (S6::*)()>),
alignof(AlignedCharArrayUnion<double (S6::*)()>));
EXPECT_EQ(alignof(S1), alignof(AlignedCharArrayUnion<S1>));
EXPECT_EQ(alignof(S2), alignof(AlignedCharArrayUnion<S2>));
More information about the llvm-commits
mailing list