[PATCH] D113874: [clang] Propagate requires-clause from constructor template to implicit deduction guide
Sam McCall via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Mar 21 03:00:52 PDT 2022
sammccall accepted this revision.
sammccall added a comment.
This revision is now accepted and ready to land.
Fantastic, thank you!
================
Comment at: clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp:794
+TEST(DiagnosticsTest, ConstrainedImplicitDeductionGuides) {
+ Annotations Header(R"cpp(
----------------
Having solved and tested this in the AST, this test is arguably redundant (it's not like there's anything interesting going on in de/serialization).
Happy if you want to keep it as a regression test, maybe leave a comment that we used to crash here or linking to the bug?
================
Comment at: clang/test/SemaTemplate/deduction-guide.cpp:219
+
+template <typename T> F(T) -> F<>;
+
----------------
Before your patch, clang requires this explicit deduction guide in order to accept the code.
Without it, it says the two implicit deduction guides from the constructor are ambiguous. But this is precisely because they lack the constraints!
After your patch, clang accepts this code without the explicit deduction guide.
So I think omitting the guide (and having no `expected-error...`) makes it a better test - in addition to verifying the guides can be dumped, it checks they are used.
(Kadir and I spent some time poking at variations of this example to understand how CTAD works in the AST, so thanks for this!)
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D113874/new/
https://reviews.llvm.org/D113874
More information about the cfe-commits
mailing list