brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.0 KiB · 8d319d9 Raw
34 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// Test that _LIBCPP_ALIGNOF acts the same as the C++11 keyword `alignof`, and10// not as the GNU extension `__alignof`. The former returns the minimal required11// alignment for a type, whereas the latter returns the preferred alignment.12//13// See llvm.org/PR3971314 15#include <type_traits>16#include "test_macros.h"17 18template <class T>19void test() {20  static_assert(_LIBCPP_ALIGNOF(T) == std::alignment_of<T>::value, "");21  static_assert(_LIBCPP_ALIGNOF(T) == TEST_ALIGNOF(T), "");22#ifdef TEST_COMPILER_CLANG23  static_assert(_LIBCPP_ALIGNOF(T) == _Alignof(T), "");24#endif25}26 27int main(int, char**) {28  test<int>();29  test<long long>();30  test<double>();31  test<long double>();32  return 0;33}34