diff --git a/clang/CodeGen/CGExpr.cpp b/clang/CodeGen/CGExpr.cpp index 3e23c9ad162c..1b89e2be511f 100644 --- a/clang/CodeGen/CGExpr.cpp +++ b/clang/CodeGen/CGExpr.cpp @@ -338,7 +338,12 @@ RValue CodeGenFunction::EmitExpr(const Expr *E) { // l-values. case Expr::DeclRefExprClass: - // FIXME: EnumConstantDecl's are not lvalues. This is wrong for them. + // DeclRef's of EnumConstantDecl's are simple rvalues. + if (const EnumConstantDecl *EC = + dyn_cast(cast(E)->getDecl())) + return RValue::get(ConstantInt::get(EC->getInitVal())); + + // FALLTHROUGH case Expr::ArraySubscriptExprClass: return EmitLoadOfLValue(E); case Expr::StringLiteralClass: