This is an archive of the discontinued LLVM Phabricator instance.

[clang] Reland parenthesized aggregate init patches
ClosedPublic

Authored by ayzhao on Jan 11 2023, 2:35 PM.

Details

Summary

This commit relands the patches for implementing P0960R3 and P1975R0,
which describe initializing aggregates via a parenthesized list.

The relanded commits are:

  • 40c52159d3ee - P0960R3 and P1975R0: Allow initializing aggregates from a parenthesized list of values
  • c77a91bb7ba7 - Remove overly restrictive aggregate paren init logic
  • 32d7aae04fdb - Fix a clang crash on invalid code in C++20 mode

This patch also fixes a crash in the original implementation.
Previously, if the input tried to call an implicitly deleted copy or
move constructor of a union, we would then try to initialize the union
by initializing it's first element with a reference to a union. This
behavior is incorrect (we should fail to initialize) and if the type of
the first element has a constructor with a single template typename
parameter, then Clang will explode. This patch fixes that issue by
checking that constructor overload resolution did not result in a
deleted function before attempting parenthesized aggregate
initialization.

Additionally, this patch also includes D140159, which contains some
minor fixes made in response to code review comments in the original
implementation that were made after that patch was submitted.

Co-authored-by: Sheng <ox59616e@gmail.com>

Fixes #54040, Fixes #59675

Diff Detail

Event Timeline

ayzhao created this revision.Jan 11 2023, 2:35 PM
Herald added a project: Restricted Project. · View Herald Transcript
ayzhao requested review of this revision.Jan 11 2023, 2:35 PM
Herald added a project: Restricted Project. · View Herald TranscriptJan 11 2023, 2:35 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript
ayzhao updated this revision to Diff 488486.Jan 11 2023, 11:18 PM

fix spelling + improve diagnostics

ilya-biryukov accepted this revision.Jan 12 2023, 5:55 AM

LGTM, mostly based on the previous review.
I have not noticed any significant changes, so have not looked too cautiously. Let me know if there are any particular places that you someone to take a look at before landing.

This revision is now accepted and ready to land.Jan 12 2023, 5:55 AM
This revision was automatically updated to reflect the committed changes.
ecatmur added a subscriber: ecatmur.Mar 6 2023, 7:00 PM