From 169d2bd06003c39970bc94c99669a34b61bb7e45 Mon Sep 17 00:00:00 2001 From: dim Date: Mon, 8 Apr 2013 18:41:23 +0000 Subject: Vendor import of llvm trunk r178860: http://llvm.org/svn/llvm-project/llvm/trunk@178860 --- unittests/Support/AlignOfTest.cpp | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) (limited to 'unittests/Support/AlignOfTest.cpp') diff --git a/unittests/Support/AlignOfTest.cpp b/unittests/Support/AlignOfTest.cpp index f01e660..40f7295 100644 --- a/unittests/Support/AlignOfTest.cpp +++ b/unittests/Support/AlignOfTest.cpp @@ -9,19 +9,29 @@ #include "llvm/Support/AlignOf.h" #include "llvm/Support/Compiler.h" - #include "gtest/gtest.h" using namespace llvm; namespace { - // Disable warnings about questionable type definitions. // We're testing that even questionable types work with the alignment utilities. #ifdef _MSC_VER #pragma warning(disable:4584) #endif +// Suppress direct base '{anonymous}::S1' inaccessible in '{anonymous}::D9' +// due to ambiguity warning. +// +// Pragma based warning suppression was introduced in GGC 4.2. Additionally +// this warning is "enabled by default". The warning still appears if -Wall is +// suppressed. Apparently GCC suppresses it when -w is specifed, which is odd. +// At any rate, clang on the other hand gripes about -Wunknown-pragma, so +// leaving it out of this. +#if ((__GNUC__ * 100) + __GNUC_MINOR__) >= 402 && !defined(__clang__) +#pragma GCC diagnostic warning "-w" +#endif + // Define some fixed alignment types to use in these tests. #if __has_feature(cxx_alignas) struct alignas(1) A1 { }; @@ -310,6 +320,16 @@ TEST(AlignOfTest, BasicAlignedArray) { #ifndef _MSC_VER EXPECT_EQ(sizeof(V8), sizeof(AlignedCharArrayUnion)); #endif -} + EXPECT_EQ(1u, (alignOf >())); + EXPECT_EQ(2u, (alignOf >())); + EXPECT_EQ(4u, (alignOf >())); + EXPECT_EQ(8u, (alignOf >())); + EXPECT_EQ(16u, (alignOf >())); + + EXPECT_EQ(1u, sizeof(AlignedCharArray<1, 1>)); + EXPECT_EQ(7u, sizeof(AlignedCharArray<1, 7>)); + EXPECT_EQ(2u, sizeof(AlignedCharArray<2, 2>)); + EXPECT_EQ(16u, sizeof(AlignedCharArray<2, 16>)); +} } -- cgit v1.1