|
| 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-exception |
| 6 | +// |
| 7 | +//===----------------------------------------------------------------------===// |
| 8 | + |
| 9 | +// REQUIRES: std-at-least-c++17 |
| 10 | + |
| 11 | +// <type_traits> |
| 12 | + |
| 13 | +// has_unique_object_representations |
| 14 | + |
| 15 | +// Verify that has_unique_object_representations(_v) rejects incomplete class and enumeration types and arrays thereof. |
| 16 | + |
| 17 | +#include <type_traits> |
| 18 | + |
| 19 | +class IC; |
| 20 | + |
| 21 | +constexpr bool v1 = std::has_unique_object_representations<IC>::value; |
| 22 | +// expected-error@-1 {{incomplete type 'IC' used in type trait expression}} |
| 23 | +constexpr bool v2 = std::has_unique_object_representations<IC[]>::value; |
| 24 | +// expected-error@-1 {{incomplete type 'IC' used in type trait expression}} |
| 25 | +constexpr bool v3 = std::has_unique_object_representations<IC[1]>::value; |
| 26 | +// expected-error@-1 {{incomplete type 'IC' used in type trait expression}} |
| 27 | +constexpr bool v4 = std::has_unique_object_representations<IC[][1]>::value; |
| 28 | +// expected-error@-1 {{incomplete type 'IC' used in type trait expression}} |
| 29 | + |
| 30 | +constexpr bool v5 = std::has_unique_object_representations_v<IC>; |
| 31 | +// expected-error@-1 {{incomplete type 'IC' used in type trait expression}} |
| 32 | +constexpr bool v6 = std::has_unique_object_representations_v<IC[]>; |
| 33 | +// expected-error@-1 {{incomplete type 'IC' used in type trait expression}} |
| 34 | +constexpr bool v7 = std::has_unique_object_representations_v<IC[1]>; |
| 35 | +// expected-error@-1 {{incomplete type 'IC' used in type trait expression}} |
| 36 | +constexpr bool v8 = std::has_unique_object_representations_v<IC[][1]>; |
| 37 | +// expected-error@-1 {{incomplete type 'IC' used in type trait expression}} |
| 38 | + |
| 39 | +enum E { |
| 40 | + v9 = std::has_unique_object_representations<E>::value, |
| 41 | + // expected-error@-1 {{incomplete type 'E' used in type trait expression}} |
| 42 | + v10 = std::has_unique_object_representations<E[]>::value, |
| 43 | + // expected-error@-1 {{incomplete type 'E' used in type trait expression}} |
| 44 | + v11 = std::has_unique_object_representations<E[1]>::value, |
| 45 | + // expected-error@-1 {{incomplete type 'E' used in type trait expression}} |
| 46 | + v12 = std::has_unique_object_representations<E[][1]>::value, |
| 47 | + // expected-error@-1 {{incomplete type 'E' used in type trait expression}} |
| 48 | + |
| 49 | + v13 = std::has_unique_object_representations_v<E>, |
| 50 | + // expected-error@-1 {{incomplete type 'E' used in type trait expression}} |
| 51 | + v14 = std::has_unique_object_representations_v<E[]>, |
| 52 | + // expected-error@-1 {{incomplete type 'E' used in type trait expression}} |
| 53 | + v15 = std::has_unique_object_representations_v<E[1]>, |
| 54 | + // expected-error@-1 {{incomplete type 'E' used in type trait expression}} |
| 55 | + v16 = std::has_unique_object_representations_v<E[][1]>, |
| 56 | + // expected-error@-1 {{incomplete type 'E' used in type trait expression}} |
| 57 | +}; |
0 commit comments