brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.0 KiB · b898b37 Raw
65 lines · cpp
1//===----------------------------------------------------------------------===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//===----------------------------------------------------------------------===//8 9// enum class align_val_t : size_t {}10 11// UNSUPPORTED: c++03, c++11, c++1412 13// Libc++ when built for z/OS doesn't contain the aligned allocation functions,14// nor does the dynamic library shipped with z/OS.15// XFAIL: target={{.+}}-zos{{.*}}16 17#include <new>18#include <cassert>19#include <cstddef>20#include <string>21#include <type_traits>22#include <typeinfo>23 24#include "test_macros.h"25 26constexpr bool test() {27  static_assert(std::is_enum<std::align_val_t>::value, "");28  static_assert(std::is_same<std::underlying_type<std::align_val_t>::type, std::size_t>::value, "");29  static_assert(!std::is_constructible<std::align_val_t, std::size_t>::value, "");30  static_assert(!std::is_constructible<std::size_t, std::align_val_t>::value, "");31 32  {33    auto a = std::align_val_t(0);34    auto b = std::align_val_t(32);35    auto c = std::align_val_t(-1);36    assert(a != b);37    assert(a == std::align_val_t(0));38    assert(b == std::align_val_t(32));39    assert(static_cast<std::size_t>(c) == static_cast<std::size_t>(-1));40  }41 42  return true;43}44 45int main(int, char**) {46  test();47  static_assert(test(), "");48 49#if defined(_LIBCPP_VERSION) && !defined(TEST_HAS_NO_RTTI)50  {51    // Check that libc++ doesn't define align_val_t in a versioning namespace.52    // And that it mangles the same in C++03 through C++1753#  ifdef _MSC_VER54    // MSVC uses a different C++ ABI with a different name mangling scheme.55    // The type id name doesn't seem to contain the mangled form at all.56    assert(typeid(std::align_val_t).name() == std::string("enum std::align_val_t"));57#  else58    assert(typeid(std::align_val_t).name() == std::string("St11align_val_t"));59#  endif60  }61#endif62 63  return 0;64}65