Implement comparison of C++0x scoped enumeration types. Fixes PR9333.

llvm-svn: 126752
This commit is contained in:
Douglas Gregor 2011-03-01 17:16:20 +00:00
parent 9760a666d6
commit 48e6bbffa1
2 changed files with 13 additions and 0 deletions

View File

@ -7024,6 +7024,12 @@ QualType Sema::CheckCompareOperands(Expr *&lex, Expr *&rex, SourceLocation Loc,
ImpCastExprToType(rex, T, CK_BitCast);
return ResultTy;
}
// Handle scoped enumeration types specifically, since they don't promote
// to integers.
if (lex->getType()->isEnumeralType() &&
Context.hasSameUnqualifiedType(lex->getType(), rex->getType()))
return ResultTy;
}
// Handle block pointer types.
@ -7123,6 +7129,7 @@ QualType Sema::CheckCompareOperands(Expr *&lex, Expr *&rex, SourceLocation Loc,
ImpCastExprToType(lex, rType, CK_NullToPointer);
return ResultTy;
}
return InvalidOperands(Loc, lex, rex);
}

View File

@ -103,3 +103,9 @@ enum : long {
enum : long x; // expected-error{{unnamed enumeration must be a definition}} \
// expected-warning{{declaration does not declare anything}}
void PR9333() {
enum class scoped_enum { yes, no, maybe };
scoped_enum e = scoped_enum::yes;
if (e == scoped_enum::no) { }
}