-
Notifications
You must be signed in to change notification settings - Fork 15.3k
[libc++] Test LWG4113: Disallow has_unique_object_representations<Incomplete[]>
#169446
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
frederick-vs-ja
wants to merge
1
commit into
llvm:main
Choose a base branch
from
frederick-vs-ja:test-lwg-4113
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+49
−1
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Member
|
@llvm/pr-subscribers-libcxx Author: A. Jiang (frederick-vs-ja) ChangesLWG4113 can be considered implemented in Clang 19 due to 6451806. A follow-up change e59ed0f simplified error messages. Fixes #147718. Full diff: https://github.com/llvm/llvm-project/pull/169446.diff 2 Files Affected:
diff --git a/libcxx/docs/Status/Cxx2cIssues.csv b/libcxx/docs/Status/Cxx2cIssues.csv
index 859c49af17ec9..66fdf989be7b3 100644
--- a/libcxx/docs/Status/Cxx2cIssues.csv
+++ b/libcxx/docs/Status/Cxx2cIssues.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|","19","`#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/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/has_unique_object_representations.compile.verify.cpp b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/has_unique_object_representations.compile.verify.cpp
new file mode 100644
index 0000000000000..7c6e2f630c364
--- /dev/null
+++ b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/has_unique_object_representations.compile.verify.cpp
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+// 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;
+// expected-error@-1 {{incomplete type 'IC' used in type trait expression}}
+constexpr bool v2 = std::has_unique_object_representations<IC[]>::value;
+// expected-error@-1 {{incomplete type 'IC' used in type trait expression}}
+constexpr bool v3 = std::has_unique_object_representations<IC[1]>::value;
+// expected-error@-1 {{incomplete type 'IC' used in type trait expression}}
+constexpr bool v4 = std::has_unique_object_representations<IC[][1]>::value;
+// expected-error@-1 {{incomplete type 'IC' used in type trait expression}}
+
+constexpr bool v5 = std::has_unique_object_representations_v<IC>;
+// expected-error@-1 {{incomplete type 'IC' used in type trait expression}}
+constexpr bool v6 = std::has_unique_object_representations_v<IC[]>;
+// expected-error@-1 {{incomplete type 'IC' used in type trait expression}}
+constexpr bool v7 = std::has_unique_object_representations_v<IC[1]>;
+// expected-error@-1 {{incomplete type 'IC' used in type trait expression}}
+constexpr bool v8 = std::has_unique_object_representations_v<IC[][1]>;
+// expected-error@-1 {{incomplete type 'IC' used in type trait expression}}
+
+enum E {
+ v9 = std::has_unique_object_representations<E>::value,
+ // expected-error@-1 {{incomplete type 'E' used in type trait expression}}
+ v10 = std::has_unique_object_representations<E[]>::value,
+ // expected-error@-1 {{incomplete type 'E' used in type trait expression}}
+ v11 = std::has_unique_object_representations<E[1]>::value,
+ // expected-error@-1 {{incomplete type 'E' used in type trait expression}}
+ v12 = std::has_unique_object_representations<E[][1]>::value,
+ // expected-error@-1 {{incomplete type 'E' used in type trait expression}}
+
+ v13 = std::has_unique_object_representations_v<E>,
+ // expected-error@-1 {{incomplete type 'E' used in type trait expression}}
+ v14 = std::has_unique_object_representations_v<E[]>,
+ // expected-error@-1 {{incomplete type 'E' used in type trait expression}}
+ v15 = std::has_unique_object_representations_v<E[1]>,
+ // expected-error@-1 {{incomplete type 'E' used in type trait expression}}
+ v16 = std::has_unique_object_representations_v<E[][1]>,
+ // expected-error@-1 {{incomplete type 'E' used in type trait expression}}
+};
|
db5c91f to
c6b2043
Compare
frederick-vs-ja
commented
Nov 25, 2025
…complete[]>` 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.
c6b2043 to
eda5ae9
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Fixes #147718.