This is an archive of the discontinued LLVM Phabricator instance.

[Concepts] Fix placeholder constraints when references are involved
ClosedPublic

Authored by royjacobson on Mar 19 2022, 2:24 PM.

Details

Summary

Placeholder types were not checked for constraint satisfaction when modified by references or pointers.
The behavior now matches that of GCC and MSVC.

Are there other modifiers we might need to "peel"? I'm not sure my approach to this is the 'right' way to fix this, the loop feels a bit clunky.

GitHub issues #54443, #53911

Diff Detail

Event Timeline

royjacobson created this revision.Mar 19 2022, 2:24 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 19 2022, 2:24 PM
royjacobson requested review of this revision.Mar 19 2022, 2:24 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 19 2022, 2:24 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript
royjacobson edited the summary of this revision. (Show Details)Mar 19 2022, 2:26 PM
royjacobson added a reviewer: ldionne.
royjacobson edited the summary of this revision. (Show Details)

I noticed issue #53911 which is very similar so I fixed it as well.

royjacobson edited the summary of this revision. (Show Details)Mar 20 2022, 3:18 PM
royjacobson added a reviewer: Quuxplusone.
royjacobson edited the summary of this revision. (Show Details)Mar 23 2022, 4:29 AM
royjacobson edited reviewers, added: erichkeane, aaron.ballman; removed: Quuxplusone.

Can you add some tests for the OTHER forms of 'auto' as well? We have decltype(auto) and auto_type, and I want to make sure whatever we do with those 'looks right'.

clang/lib/Sema/SemaTemplateDeduction.cpp
4773

We don't do curley braces on single-line blocks.

Remove the curly brackets from one line loop.

royjacobson marked an inline comment as done.Mar 23 2022, 6:55 AM

Can you add some tests for the OTHER forms of 'auto' as well? We have decltype(auto) and auto_type, and I want to make sure whatever we do with those 'looks right'.

Can we have constraints on __auto_type? As far as I understand it, it's a C extension with very limited C++ support.
About decltype(auto) - we can't have */& modifiers with it, and that's already covered by tests like p7-cxx14.

So (I think?) it's always invalid code and it fails earlier during parsing.

erichkeane accepted this revision.Mar 23 2022, 7:02 AM

Can you add some tests for the OTHER forms of 'auto' as well? We have decltype(auto) and auto_type, and I want to make sure whatever we do with those 'looks right'.

Can we have constraints on __auto_type? As far as I understand it, it's a C extension with very limited C++ support.

I tried a couple and cannot convince GCC to let me deduce it.

About decltype(auto) - we can't have */& modifiers with it, and that's already covered by tests like p7-cxx14.

Ah, right, thanks!

So (I think?) it's always invalid code and it fails earlier during parsing.

Yep, thanks for that.

1 more test I'd like to see that doesn't seem covered (ref to ptr), AND according to @aaron.ballman we need "Release Notes" for this. Otherwise LGTM. Do you have commit rights yet?

clang/test/SemaTemplate/concepts.cpp
207–211

would also like C auto*&

This revision is now accepted and ready to land.Mar 23 2022, 7:02 AM

Add test for auto**& combination

1 more test I'd like to see that doesn't seem covered (ref to ptr),

Added, good idea.

AND according to @aaron.ballman we need "Release Notes" for this. Otherwise LGTM. Do you have commit rights yet?

Yeah, I got commit rights :)
This should go into "Bug Fixes" section in clang/docs/ReleaseNotes.rst, right? Or "C++20 Feature Support"?

1 more test I'd like to see that doesn't seem covered (ref to ptr),

Added, good idea.

AND according to @aaron.ballman we need "Release Notes" for this. Otherwise LGTM. Do you have commit rights yet?

Yeah, I got commit rights :)
This should go into "Bug Fixes" section in clang/docs/ReleaseNotes.rst, right? Or "C++20 Feature Support"?

I'd suggest 'bug fixes'.

Added release notes.

erichkeane accepted this revision.Mar 23 2022, 7:55 AM

LGTM, thanks!

This revision was landed with ongoing or failed builds.Mar 23 2022, 8:15 AM
This revision was automatically updated to reflect the committed changes.