This is an archive of the discontinued LLVM Phabricator instance.

[clang] Remove overly restrictive aggregate paren init logic
ClosedPublic

Authored by ayzhao on Dec 19 2022, 11:08 AM.

Details

Summary

Previously, we would only attempt to perform a parenthesized aggregate
initialization if constructor initialization failed for only the default
constructor, default copy constructor, and default move constructor. The
original intent of this logic was to reject initializing objects that
have failed resolving a user-defined constructor. However, this check is
redundant because we check for isAggregate() before attempting to
perform a parenthesized aggregate initialization, and classes that have
user-defined or user-declared constructors are not aggregates.
Furthermore, this check is too restrictive - the following valid
examples fail:

The solution therefore is to remove this logic; existing tests still
pass, and the previously failing examples now compile.

Diff Detail

Event Timeline

ayzhao created this revision.Dec 19 2022, 11:08 AM
Herald added a project: Restricted Project. · View Herald TranscriptDec 19 2022, 11:08 AM
ayzhao requested review of this revision.Dec 19 2022, 11:08 AM
Herald added a project: Restricted Project. · View Herald TranscriptDec 19 2022, 11:08 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
This revision is now accepted and ready to land.Dec 21 2022, 8:19 AM