]> granicus.if.org Git - clang/commit
[Sema] Add lvalue-to-rvalue cast in direct-list-initialization of enum
authorVedant Kumar <vsk@apple.com>
Thu, 16 Feb 2017 01:20:00 +0000 (01:20 +0000)
committerVedant Kumar <vsk@apple.com>
Thu, 16 Feb 2017 01:20:00 +0000 (01:20 +0000)
commit7b13e5dedc31dbf841fc548292cac33dc0d0bcd3
tree927ca10c2ebc8b054ebd2d4000347751599066a0
parent73de459c12741844e4f72a5cc6929a4a66a93cb5
[Sema] Add lvalue-to-rvalue cast in direct-list-initialization of enum

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}; }

Differential Revision: https://reviews.llvm.org/D29723

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@295266 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Sema/SemaInit.cpp
test/CXX/dcl.decl/dcl.init/dcl.init.list/p3.cpp