[libc++] Test LWG4113: Disallow `has_unique_object_representations<Incomplete[]>` (#169446) We have been rejecting `has_unique_object_representations<Incomplete[]>` since LLVM 6. Some related change landed in Clang 19 due to 6451806ef73bb033be3f6e1599f3bcb224943206, and then a follow-up change ae9990ed965118e7274a52399b43e3b9fb419a54 simplified error messages. Test coverage for incomplete enumeration types is skipped for Clang-cl mode, because an incomplete enumeration type is incorrectly considered to be complete. See https://llvm.org/PR169472. Co-authored-by: Louis Dionne <ldionne.2@gmail.com> GitOrigin-RevId: 1f13035dd3bec940226402c59bbb086ab703caeb
diff --git a/docs/Status/Cxx26Issues.csv b/docs/Status/Cxx26Issues.csv index b98f3ee..7cb257a 100644 --- a/docs/Status/Cxx26Issues.csv +++ b/docs/Status/Cxx26Issues.csv
@@ -92,7 +92,7 @@ "`LWG4085 <https://wg21.link/LWG4085>`__","``ranges::generate_random``'s helper lambda should specify the return type","2024-11 (Wrocław)","","","`#118347 <https://github.com/llvm/llvm-project/issues/118347>`__","" "`LWG4088 <https://wg21.link/LWG4088>`__","``println`` ignores the locale imbued in ``std::ostream``","2024-11 (Wrocław)","|Complete|","18","`#118348 <https://github.com/llvm/llvm-project/issues/118348>`__","" "`LWG4112 <https://wg21.link/LWG4112>`__","``has-arrow`` should required ``operator->()`` to be ``const``-qualified","2024-11 (Wrocław)","","","`#118349 <https://github.com/llvm/llvm-project/issues/118349>`__","" -"`LWG4113 <https://wg21.link/LWG4113>`__","Disallow ``has_unique_object_representations<Incomplete[]>``","2024-11 (Wrocław)","|Complete|","","`#118350 <https://github.com/llvm/llvm-project/issues/118350>`__","" +"`LWG4113 <https://wg21.link/LWG4113>`__","Disallow ``has_unique_object_representations<Incomplete[]>``","2024-11 (Wrocław)","|Complete|","6","`#118350 <https://github.com/llvm/llvm-project/issues/118350>`__","" "`LWG4119 <https://wg21.link/LWG4119>`__","``generator::promise_type::yield_value(ranges::elements_of<R, Alloc>)``'s nested ``generator`` may be ill-formed","2024-11 (Wrocław)","","","`#118351 <https://github.com/llvm/llvm-project/issues/118351>`__","" "`LWG4124 <https://wg21.link/LWG4124>`__","Cannot format ``zoned_time`` with resolution coarser than ``seconds``","2024-11 (Wrocław)","","","`#118352 <https://github.com/llvm/llvm-project/issues/118352>`__","" "`LWG4126 <https://wg21.link/LWG4126>`__","Some feature-test macros for fully freestanding features are not yet marked freestanding","2024-11 (Wrocław)","","","`#118353 <https://github.com/llvm/llvm-project/issues/118353>`__",""
diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/has_unique_object_representations.verify.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/has_unique_object_representations.verify.cpp new file mode 100644 index 0000000..8f00eb1 --- /dev/null +++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/has_unique_object_representations.verify.cpp
@@ -0,0 +1,48 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +// REQUIRES: std-at-least-c++17 + +// <type_traits> + +// has_unique_object_representations + +// Verify that has_unique_object_representations(_v) rejects incomplete class and enumeration types and arrays thereof. + +#include <type_traits> + +class IC; + +constexpr bool v1 = std::has_unique_object_representations<IC>::value; +constexpr bool v2 = std::has_unique_object_representations<IC[]>::value; +constexpr bool v3 = std::has_unique_object_representations<IC[1]>::value; +constexpr bool v4 = std::has_unique_object_representations<IC[][1]>::value; + +constexpr bool v5 = std::has_unique_object_representations_v<IC>; +constexpr bool v6 = std::has_unique_object_representations_v<IC[]>; +constexpr bool v7 = std::has_unique_object_representations_v<IC[1]>; +constexpr bool v8 = std::has_unique_object_representations_v<IC[][1]>; + +// expected-error@*:* 8 {{incomplete type 'IC' used in type trait expression}} + +enum E { + v9 = std::has_unique_object_representations<E>::value, + v10 = std::has_unique_object_representations<E[]>::value, + v11 = std::has_unique_object_representations<E[1]>::value, + v12 = std::has_unique_object_representations<E[][1]>::value, + + v13 = std::has_unique_object_representations_v<E>, + v14 = std::has_unique_object_representations_v<E[]>, + v15 = std::has_unique_object_representations_v<E[1]>, + v16 = std::has_unique_object_representations_v<E[][1]>, + +// TODO: Remove the guard once https://llvm.org/PR169472 is resolved. +#ifndef _MSC_VER // In Clang-cl mode, E is incorrectly considered complete here. +// expected-error@*:* 8 {{incomplete type 'E' used in type trait expression}} +#endif +};