PR18551: accepts invalid strong enum to bool when operator! is used
llvm-svn: 199627
This commit is contained in:
parent
dbf62e3eee
commit
c620cab8c4
|
@ -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:
|
||||
|
|
|
@ -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 };
|
||||
|
||||
|
|
Loading…
Reference in New Issue