diff --git a/clang/include/clang/AST/Decl.h b/clang/include/clang/AST/Decl.h index 254e050b77772147a8403e7952c937675fdce433..a23159fcec008b4a8969b1d2d9e09e068979dc85 100644 --- a/clang/include/clang/AST/Decl.h +++ b/clang/include/clang/AST/Decl.h @@ -2482,8 +2482,9 @@ public: /// Returns the minimum number of arguments needed to call this function. This /// may be fewer than the number of function parameters, if some of the - /// parameters have default arguments (in C++). - unsigned getMinRequiredArguments() const; + /// parameters have default arguments (in C++) or contain "this" parameter (in + /// BSC). + unsigned getMinRequiredArguments(bool HasBSCScopeSpec = false) const; /// Determine whether this function has a single parameter, or multiple /// parameters where all but the first have default arguments. diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp index 5eb7167057313e1f15902b64b82a9d154a21e963..5069c6ea574b645218f41efc50517b7e54ddae40 100644 --- a/clang/lib/AST/Decl.cpp +++ b/clang/lib/AST/Decl.cpp @@ -3339,9 +3339,10 @@ void FunctionDecl::setParams(ASTContext &C, /// getMinRequiredArguments - Returns the minimum number of arguments /// needed to call this function. This may be fewer than the number of /// function parameters, if some of the parameters have default -/// arguments (in C++) or are parameter packs (C++11). -unsigned FunctionDecl::getMinRequiredArguments() const { - if (getASTContext().getLangOpts().BSC) { +/// arguments (in C++) or are parameter packs (C++11) or contain "this" +/// parameter (in BSC). +unsigned FunctionDecl::getMinRequiredArguments(bool HasBSCScopeSpec) const { + if (getASTContext().getLangOpts().BSC && !HasBSCScopeSpec) { int num = getNumParams(); if (num > 0 && parameters()[0] && parameters()[0]->IsThisParam) { num--; diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index 7d53cc7cdcce0f3c07deb6a6720c2fb8689135e0..d18a2f80c849aaa242cf4febc906bf45f5d40a92 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -5803,7 +5803,8 @@ Sema::ConvertArgumentsForCall(CallExpr *Call, Expr *Fn, // assignment, to the types of the corresponding parameter, ... unsigned NumParams = Proto->getNumParams(); bool Invalid = false; - unsigned MinArgs = FDecl ? FDecl->getMinRequiredArguments() : NumParams; + unsigned MinArgs = + FDecl ? FDecl->getMinRequiredArguments(Fn->HasBSCScopeSpec) : NumParams; unsigned FnKind = Fn->getType()->isBlockPointerType() ? 1 /* block */ : (IsExecConfig ? 3 /* kernel function (exec config) */ diff --git a/clang/test/BSC/Method/BuiltInType/int_too_few_arguments_call.cbs b/clang/test/BSC/Method/BuiltInType/int_too_few_arguments_call.cbs new file mode 100644 index 0000000000000000000000000000000000000000..9a89f2e6fc0a611ac60e1533c04ce00d94119d8a --- /dev/null +++ b/clang/test/BSC/Method/BuiltInType/int_too_few_arguments_call.cbs @@ -0,0 +1,9 @@ +// RUN: %clang_cc1 -verify %s + +void int::increase(int* this) { // expected-note {{'increase' declared here}} +} + +int main() { + int::increase(); // expected-error {{too few arguments to function call, single argument 'this' was not specified}} + return 0; +} \ No newline at end of file