This is an archive of the discontinued LLVM Phabricator instance.

[Sema] Add lvalue-to-rvalue cast in direct-list-initialization of enum
ClosedPublic

Authored by vsk on Feb 8 2017, 11:11 AM.

Details

Summary

After r264564, we allowed direct-list-initialization of an enum from an
integral value in C++1z mode, so long as that value can convert to the
enum's underlying type.

In this kind of initialization, we need a lvalue-to-rvalue conversion
for the initializer value if it is not a rvalue. This lets us accept the
following code:

enum class A : unsigned {};
A foo(unsigned x) { return A{x}; }

Diff Detail

Repository
rL LLVM

Event Timeline

vsk created this revision.Feb 8 2017, 11:11 AM
efriedma added a subscriber: efriedma.

(Resigning as a reviewer; I don't know enough about standard conversion sequences off the top of my head to review this properly.)

rsmith accepted this revision.Feb 15 2017, 4:46 PM
This revision is now accepted and ready to land.Feb 15 2017, 4:46 PM
This revision was automatically updated to reflect the committed changes.