This is an archive of the discontinued LLVM Phabricator instance.

[Clang] Correctly expand pack in binary subscript expression.
ClosedPublic

Authored by cor3ntin on May 2 2023, 1:36 AM.

Details

Summary

When constructing an array expression where the index expression
was a pack expansion, we would construct an ArraySubscriptExpr
instead of an CreateOverloadedArraySubscriptExpr, and pack
expansion would not occur - leading a crash during code gen
or a failure during constant evaluation

Diff Detail

Event Timeline

cor3ntin created this revision.May 2 2023, 1:36 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 2 2023, 1:36 AM
cor3ntin requested review of this revision.May 2 2023, 1:36 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 2 2023, 1:36 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
cor3ntin edited reviewers, added: shafik; removed: shaffar.
erichkeane accepted this revision.May 2 2023, 6:10 AM
This revision is now accepted and ready to land.May 2 2023, 6:10 AM
shafik accepted this revision.May 2 2023, 8:06 AM

LGTM, other than my comment on the diagnostic wording

clang/test/SemaCXX/cxx2b-overloaded-operator.cpp
101

The diagnostic is not great.

cor3ntin added inline comments.May 2 2023, 8:12 AM
clang/test/SemaCXX/cxx2b-overloaded-operator.cpp
101

Indeed. The issue is that we only add the built-in to the set of candidates if there are two args (ie one index, after expansion).
So we cannot produce a nice error with mismatching arity.
I looked into changing that but it requires some refactor to how we add built-in to the overload set and diagnose built-ins.

cor3ntin updated this revision to Diff 518776.May 2 2023, 9:48 AM

Add release note

This revision was landed with ongoing or failed builds.May 2 2023, 12:22 PM
This revision was automatically updated to reflect the committed changes.