Skip to content

Commit eda5ae9

Browse files
[libc++] Test LWG4113: Disallow has_unique_object_representations<Incomplete[]>
We have been rejecting `has_unique_object_representations<Incomplete[]>` since LLVM 6. Some related change landed in Clang 19 due to 6451806, and then a follow-up change ae9990e 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.
1 parent a086fb2 commit eda5ae9

File tree

2 files changed

+49
-1
lines changed

2 files changed

+49
-1
lines changed

libcxx/docs/Status/Cxx2cIssues.csv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@
9292
"`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>`__",""
9393
"`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>`__",""
9494
"`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>`__",""
95-
"`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>`__",""
95+
"`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>`__",""
9696
"`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>`__",""
9797
"`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>`__",""
9898
"`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>`__",""
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
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+
constexpr bool v2 = std::has_unique_object_representations<IC[]>::value;
23+
constexpr bool v3 = std::has_unique_object_representations<IC[1]>::value;
24+
constexpr bool v4 = std::has_unique_object_representations<IC[][1]>::value;
25+
26+
constexpr bool v5 = std::has_unique_object_representations_v<IC>;
27+
constexpr bool v6 = std::has_unique_object_representations_v<IC[]>;
28+
constexpr bool v7 = std::has_unique_object_representations_v<IC[1]>;
29+
constexpr bool v8 = std::has_unique_object_representations_v<IC[][1]>;
30+
31+
// expected-error@*:* 8 {{incomplete type 'IC' used in type trait expression}}
32+
33+
enum E {
34+
v9 = std::has_unique_object_representations<E>::value,
35+
v10 = std::has_unique_object_representations<E[]>::value,
36+
v11 = std::has_unique_object_representations<E[1]>::value,
37+
v12 = std::has_unique_object_representations<E[][1]>::value,
38+
39+
v13 = std::has_unique_object_representations_v<E>,
40+
v14 = std::has_unique_object_representations_v<E[]>,
41+
v15 = std::has_unique_object_representations_v<E[1]>,
42+
v16 = std::has_unique_object_representations_v<E[][1]>,
43+
44+
// TODO: Remove the guard once https://llvm.org/PR169472 is resolved.
45+
#ifndef _MSC_VER // In Clang-cl mode, E is incorrectly considered complete here.
46+
// expected-error@*:* 8 {{incomplete type 'E' used in type trait expression}}
47+
#endif
48+
};

0 commit comments

Comments
 (0)