diff options
Diffstat (limited to 'clang/lib/Sema')
| -rw-r--r-- | clang/lib/Sema/SemaCXXCast.cpp | 9 | ||||
| -rw-r--r-- | clang/lib/Sema/SemaExpr.cpp | 4 | ||||
| -rw-r--r-- | clang/lib/Sema/SemaStmt.cpp | 6 | 
3 files changed, 19 insertions, 0 deletions
| diff --git a/clang/lib/Sema/SemaCXXCast.cpp b/clang/lib/Sema/SemaCXXCast.cpp index 7b1e34a7c38..fc9ef73a590 100644 --- a/clang/lib/Sema/SemaCXXCast.cpp +++ b/clang/lib/Sema/SemaCXXCast.cpp @@ -146,6 +146,10 @@ Sema::BuildCXXNamedCast(SourceLocation OpLoc, tok::TokenKind Kind,    // FIXME: should we check this in a more fine-grained manner?    bool TypeDependent = DestType->isDependentType() || Ex->isTypeDependent(); +  if (Ex->isBoundMemberFunction(Context)) +    Diag(Ex->getLocStart(), diag::err_invalid_use_of_bound_member_func) +      << Ex->getSourceRange(); +    switch (Kind) {    default: assert(0 && "Unknown C++ cast!"); @@ -1273,6 +1277,11 @@ Sema::CXXCheckCStyleCast(SourceRange R, QualType CastTy, Expr *&CastExpr,                           CastKind &Kind,                            CXXCastPath &BasePath,                           bool FunctionalStyle) { +  if (CastExpr->isBoundMemberFunction(Context)) +    return Diag(CastExpr->getLocStart(), +                diag::err_invalid_use_of_bound_member_func) +        << CastExpr->getSourceRange(); +    // This test is outside everything else because it's the only case where    // a non-lvalue-reference target type does not lead to decay.    // C++ 5.2.9p4: Any expression can be explicitly converted to type "cv void". diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index 6f6d3714e69..9e28172c97e 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -8206,6 +8206,10 @@ bool Sema::CheckBooleanCondition(Expr *&E, SourceLocation Loc) {    DiagnoseAssignmentAsCondition(E);    if (!E->isTypeDependent()) { +    if (E->isBoundMemberFunction(Context)) +      return Diag(E->getLocStart(), diag::err_invalid_use_of_bound_member_func) +        << E->getSourceRange(); +      DefaultFunctionArrayLvalueConversion(E);      QualType T = E->getType(); diff --git a/clang/lib/Sema/SemaStmt.cpp b/clang/lib/Sema/SemaStmt.cpp index ddee9cca6d6..4c586e5e02c 100644 --- a/clang/lib/Sema/SemaStmt.cpp +++ b/clang/lib/Sema/SemaStmt.cpp @@ -74,6 +74,12 @@ void Sema::DiagnoseUnusedExprResult(const Stmt *S) {    if (!E)      return; +  if (E->isBoundMemberFunction(Context)) { +    Diag(E->getLocStart(), diag::err_invalid_use_of_bound_member_func) +      << E->getSourceRange(); +    return; +  } +    SourceLocation Loc;    SourceRange R1, R2;    if (!E->isUnusedResultAWarning(Loc, R1, R2, Context)) | 

