llvm/llvm/unittests/Support/AlignOfTest.cpp

//=== - llvm/unittest/Support/AlignOfTest.cpp - Alignment utility tests ---===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#ifdef _MSC_VER
// Disable warnings about alignment-based structure padding.
// This must be above the includes to suppress warnings in included templates.
#pragma warning(disable:4324)
#endif

#include "llvm/Support/AlignOf.h"
#include "llvm/Support/Compiler.h"
#include "gtest/gtest.h"

usingnamespacellvm;

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.
#ifdef __clang__
#pragma clang diagnostic ignored "-Wunknown-pragmas"
#pragma clang diagnostic ignored "-Winaccessible-base"
#elif ((__GNUC__ * 100) + __GNUC_MINOR__) >= 402
// 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.
#pragma GCC diagnostic warning "-w"
#endif

// Define some fixed alignment types to use in these tests.
struct alignas(1) A1 {};
struct alignas(2) A2 {};
struct alignas(4) A4 {};
struct alignas(8) A8 {};

struct S1 {};
struct S2 {};
struct S3 {};
struct S4 {};
struct S5 {};
struct S6 {};
struct D1 : S1 {};
struct D2 : S6 {};
struct D3 : S2 {};
struct D4 : S2 {};
struct D5 : S3 {};
struct D6 : S2, S3 {};
struct D7 : S1, S3 {};
struct D8 : S1, D4, D5 {};
struct D9 : S1, D1 {};
struct V1 {};
struct V2 {};
struct V3 : V1 {};
struct V4 : virtual V2 {};
struct V5 : V4, V3 {};
struct V6 : S1 {};
struct V7 : virtual V2, virtual V6 {};
struct V8 : V5, virtual V6, V7 {};

double S6::f() {}
float D2::g() {}
V1::~V1() {}
V2::~V2() {}
V3::~V3() {}
V4::~V4() {}
V5::~V5() {}
V6::~V6() {}
V7::~V7() {}
V8::~V8() {}

template <typename M> struct T {};

TEST(AlignOfTest, BasicAlignedArray) {}
} // end anonymous namespace