]> granicus.if.org Git - clang/commitdiff
Make sure we perform lvalue-to-rvalue conversions for enum initializers. PR11484.
authorEli Friedman <eli.friedman@gmail.com>
Tue, 6 Dec 2011 00:10:34 +0000 (00:10 +0000)
committerEli Friedman <eli.friedman@gmail.com>
Tue, 6 Dec 2011 00:10:34 +0000 (00:10 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@145874 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaDecl.cpp
test/SemaCXX/enum-scoped.cpp

index fdb2cf5d9641c6e8c22c170493e18a6ca4975109..c90b7492a2fc0104bba366328ce40851c7b3d80a 100644 (file)
@@ -9449,6 +9449,9 @@ EnumConstantDecl *Sema::CheckEnumConstant(EnumDecl *Enum,
   if (Val && DiagnoseUnexpandedParameterPack(Val, UPPC_EnumeratorValue))
     Val = 0;
 
+  if (Val)
+    Val = DefaultLvalueConversion(Val).take();
+
   if (Val) {
     if (Enum->isDependentType() || Val->isTypeDependent())
       EltTy = Context.DependentTy;
index 35ba1b4017aee2c9dbfd9ff65712709e8725bc0d..d9726ac4fc73c9d417aebb572308614efa9ecff2 100644 (file)
@@ -142,3 +142,8 @@ namespace test6 {
     (void) A::e; // expected-error {{incomplete type 'test6::A' named in nested name specifier}}
   }
 }
+
+namespace PR11484 {
+  const int val = 104;
+  enum class test1 { owner_dead = val, };
+}