ResultTy, RParenLoc));
delete [] MethodArgs;
+ // We may have default arguments. If so, we need to allocate more
+ // slots in the call for them.
+ if (NumArgs < NumArgsInProto)
+ TheCall->setNumArgs(NumArgsInProto + 1);
+ else if (NumArgs > NumArgsInProto)
+ NumArgsToCheck = NumArgsInProto;
+
// Initialize the implicit object parameter.
- if (!PerformObjectArgumentInitialization(Object, Method))
+ if (PerformObjectArgumentInitialization(Object, Method))
return true;
TheCall->setArg(0, Object);
// Check the argument types.
for (unsigned i = 0; i != NumArgsToCheck; i++) {
- QualType ProtoArgType = Proto->getArgType(i);
-
Expr *Arg;
- if (i < NumArgs)
+ if (i < NumArgs) {
Arg = Args[i];
- else
+
+ // Pass the argument.
+ QualType ProtoArgType = Proto->getArgType(i);
+ if (PerformCopyInitialization(Arg, ProtoArgType, "passing"))
+ return true;
+ } else {
Arg = new CXXDefaultArgExpr(Method->getParamDecl(i));
- QualType ArgType = Arg->getType();
-
- // Pass the argument.
- if (PerformCopyInitialization(Arg, ProtoArgType, "passing"))
- return true;
+ }
TheCall->setArg(i + 1, Arg);
}
X& xr = (x, x);
}
-
struct Callable {
int& operator()(int, double = 2.71828); // expected-note{{candidate function}}
float& operator()(int, double, long, ...); // expected-note{{candidate function}}
+
+ double& operator()(float); // expected-note{{candidate function}}
+};
+
+struct Callable2 {
+ int& operator()(int i = 0);
+ double& operator()(...) const;
};
-void test_callable(Callable c) {
+void test_callable(Callable c, Callable2 c2, const Callable2& c2c) {
int &ir = c(1);
float &fr = c(1, 3.14159, 17, 42);
c(); // expected-error{{no matching function for call to object of type 'struct Callable'; candidates are:}}
+
+ double &dr = c(1.0f);
+
+ int &ir2 = c2();
+ int &ir3 = c2(1);
+ double &fr2 = c2c();
}
typedef float FLOAT;