PR18551: accepts invalid strong enum to bool when operator! is used

llvm-svn: 199627
This commit is contained in:
Alp Toker 2014-01-20 07:20:22 +00:00
parent dbf62e3eee
commit c620cab8c4
2 changed files with 6 additions and 1 deletions

View File

@ -9711,7 +9711,7 @@ ExprResult Sema::CreateBuiltinUnaryOp(SourceLocation OpLoc,
if (resultType->isDependentType())
break;
if (resultType->isScalarType()) {
if (resultType->isScalarType() && !isScopedEnumerationType(resultType)) {
// C99 6.5.3.3p1: ok, fallthrough;
if (Context.getLangOpts().CPlusPlus) {
// C++03 [expr.unary.op]p8, C++0x [expr.unary.op]p9:

View File

@ -272,6 +272,11 @@ namespace PR16900 {
A f(A a) { return -a; } // expected-error {{invalid argument type 'PR16900::A' to unary expression}}
}
namespace PR18551 {
enum class A { A };
bool f() { return !A::A; } // expected-error {{invalid argument type 'PR18551::A' to unary expression}}
}
namespace rdar15124329 {
enum class B : bool { F, T };