Give CanQual<T> an implicit conversion to bool, so that it can be used

in "if" statements like:

  if (CanQual<ReferenceType> RefType = T.getAs<ReferenceType>())

Thanks to Clang for pointing out this mistake :)

llvm-svn: 86995
This commit is contained in:
Douglas Gregor 2009-11-12 16:49:45 +00:00
parent a70ad93f8a
commit 6051c8d344
2 changed files with 4 additions and 1 deletions

View File

@ -71,6 +71,9 @@ public:
/// \brief Implicit conversion to a qualified type.
operator QualType() const { return Stored; }
/// \brief Implicit conversion to bool.
operator bool() const { return !isNull(); }
bool isNull() const {
return Stored.isNull();
}

View File

@ -4014,7 +4014,7 @@ bool Sema::CheckOverloadedOperatorDeclaration(FunctionDecl *FnDecl) {
if (!ResultTy->isDependentType() && ResultTy != Context.VoidPtrTy)
return Diag(FnDecl->getLocation(),
diag::err_operator_new_result_type) << FnDecl->getDeclName()
<< Context.VoidPtrTy;
<< static_cast<QualType>(Context.VoidPtrTy);
return ret;
}