1 /* Based on objc/execute/va_method.m, by Nicola Pero */
4 /* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */
5 #include "../objc-obj-c++-shared/Object1.h"
9 /* Test methods with "C-style" trailing arguments, with or without ellipsis. */
11 @interface MathClass: Object
12 /* sum positive numbers; -1 ends the list */
13 + (int) sum: (int) firstNumber, int secondNumber, ...;
14 + (int) prod: (int) firstNumber, int secondNumber, int thirdNumber;
15 + (int) minimum: (int) firstNumber, ...;
18 extern "C" int some_func(id self, SEL _cmd, int firstN, int secondN, int thirdN, ...) {
19 return firstN + secondN + thirdN;
22 @implementation MathClass
23 + (int) sum: (int) firstNumber, int secondNumber, ...
26 int sum = 0, number = 0;
28 va_start (ap, secondNumber);
29 number = firstNumber + secondNumber;
34 number = va_arg (ap, int);
41 + (int) prod: (int) firstNumber, int secondNumber, int thirdNumber {
42 return firstNumber * secondNumber * thirdNumber;
44 + (int) minimum: (int) firstNumber, ...
47 int minimum = 999, number = 0;
49 va_start (ap, firstNumber);
54 minimum = (minimum < number ? minimum: number);
55 number = va_arg (ap, int);
66 if ([MathClass sum: 1, 2, 3, 4, 5, -1] != 15)
68 if ([MathClass prod: 4, 5, 6] != 120)
70 if ([MathClass minimum: 17, 9, 133, 84, 35, -1] != 9)
75 #include "../objc-obj-c++-shared/Object1-implementation.h"