This is an archive of the discontinued LLVM Phabricator instance.

[Clang] Implement multidimentional subscript operator
ClosedPublic

Authored by cor3ntin on Jan 23 2022, 10:05 AM.

Details

Summary

Implement P2128R6 in C++23 mode.

Unlike GCC's implementation, this doesn't try
to recover when a user meant to use a comma expression.

Because the syntax changes meaning in C++23, the patch is
*NOT* implemented as an extension. Instead, declaring an array
with not exactly 1 parameter is an error in older languages
modes. There is an off-by-default extension warning in C++23 mode.

Unlike the standard, we supports default arguments;

Ie, we assume, based on conversations in WG21, that
the proposed resolution to CWG2507 will be accepted.

We allow arrays OpenMP sections and C++23 multidimensional array
to cohexist:

[a , b] multi dimensional array
[a : b]
open mp section
[a, b: c] // error

The rest of the patch is relatively straight forward: we
take care to support arbitrary number of argument everywhere.

Diff Detail

Event Timeline

cor3ntin created this revision.Jan 23 2022, 10:05 AM
cor3ntin requested review of this revision.Jan 23 2022, 10:05 AM
Herald added projects: Restricted Project, Restricted Project. · View Herald Transcript
cor3ntin updated this revision to Diff 402349.Jan 23 2022, 10:09 AM

Fix formatting

cor3ntin updated this revision to Diff 402353.Jan 23 2022, 10:15 AM

Fix typos in commit message

I've not had the chance to review yet, but adding some more reviewers for better visibility (I've got WG14 meetings coming up so my availability is a bit limited at the moment).

cor3ntin updated this revision to Diff 402610.Jan 24 2022, 11:26 AM

Fix another typo in the commit message

cor3ntin edited the summary of this revision. (Show Details)Jan 24 2022, 11:27 AM

I don't have sufficient experience to approve this, but I DID look through it and found 1 suspicious thing.

clang/lib/Sema/SemaAccess.cpp
1799

So should the 'end' be ArgExprs.back()->getEndLoc()?

cor3ntin updated this revision to Diff 402780.Jan 25 2022, 12:28 AM
This comment was removed by cor3ntin.
cor3ntin updated this revision to Diff 402781.Jan 25 2022, 12:30 AM
cor3ntin marked an inline comment as done.

Address Erich's feedback: A source range was only constructed from the
first element

cor3ntin added inline comments.Jan 25 2022, 12:31 AM
clang/lib/Sema/SemaAccess.cpp
1799

It should, thanks!

erichkeane accepted this revision.Feb 8 2022, 6:34 AM

I spent some more time looking at this, and don't see anything suspicious, and since the others didn't have anything to say (AND it is early in the cycle), I think I'm OK accepting this.

This revision is now accepted and ready to land.Feb 8 2022, 6:34 AM
cor3ntin updated this revision to Diff 406841.Feb 8 2022, 8:23 AM
  • Rebase
  • Update cxx_status as we are now targetting clang 15 instead of 14.

@erichkeane Thanks for the review! I had to rebase. I also updated the cxx_status page.
@aaron.ballman If it looks good to you to, feel free to commit whenever you can. Thanks :D

aaron.ballman closed this revision.Feb 8 2022, 9:12 AM

Thanks! I've commit on your behalf in c1512250960bd247519a9f959ad4af202402dcc4