You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Improve diagnostic wording for invalid callback attribute uses (#134423)
We were previously telling the user how many arguments were passed to
the attribute rather than saying how many arguments were expected to be
passed to the callback function. This rewords the diagnostic to
hopefully be a bit more clear.
Fixes#47451
__attribute__((callback(1, 1))) voidtoo_many_args_1(void (*callback)(void)) {} // expected-error-re {{'callback' attribute references function of type 'void ({{(void)?}})' which expects 0 arguments but attribute specifies 1 parameter index argument}}
6
+
__attribute__((callback(1, -1))) voidtoo_many_args_2(double (*callback)(void)); // expected-error-re {{'callback' attribute references function of type 'double ({{(void)?}})' which expects 0 arguments but attribute specifies 1 parameter index argument}}
7
+
__attribute__((callback(1, 2, 2))) voidtoo_many_args_3(void (*callback)(int), int); // expected-error {{'callback' attribute references function of type 'void (int)' which expects 1 argument but attribute specifies 2 parameter index arguments}}
__attribute__((callback(1, 2))) voidtoo_few_args_1(void (*callback)(int, int), int); // expected-error {{'callback' attribute references function of type 'void (int, int)' which expects 2 arguments but attribute specifies 1 parameter index argument}}
10
+
__attribute__((callback(1))) voidtoo_few_args_2(int (*callback)(int)); // expected-error {{'callback' attribute references function of type 'int (int)' which expects 1 argument but attribute specifies 0 parameter index arguments}}
11
+
__attribute__((callback(1, -1))) voidtoo_few_args_3(void (*callback)(int, int)) {} // expected-error {{'callback' attribute references function of type 'void (int, int)' which expects 2 arguments but attribute specifies 1 parameter index argument}}
__attribute__((callback(1, -1))) voidvararg_cb_1(void (*callback)(int, ...)) {} // expected-error {{'callback' attribute callee may not be variadic}}
34
34
__attribute__((callback(1, 1))) voidvararg_cb_2(void (*callback)(int, ...), inta); // expected-error {{'callback' attribute callee may not be variadic}}
__attribute__((callback(1, -1, 1))) voidself_arg_1(void (*callback)(int, ...)) {} // expected-error {{'callback' attribute references function of type 'void (int, ...)' which expects 1 argument but attribute specifies 2 parameter index arguments}}
40
+
__attribute__((callback(1, -1, 1, -1, -1, 1))) voidself_arg_2(void (*callback)(int, ...)); // expected-error {{'callback' attribute references function of type 'void (int, ...)' which expects 1 argument but attribute specifies 5 parameter index arguments}}
41
41
42
42
__attribute__((callback(cb))) voidunknown_name1(void (*callback)(void)) {} // expected-error {{'callback' attribute argument 'cb' is not a known function parameter}}
43
43
__attribute__((callback(cb, ab))) voidunknown_name2(void (*cb)(int), inta) {} // expected-error {{'callback' attribute argument 'ab' is not a known function parameter}}
__attribute__((callback(callback, 1))) voidtoo_many_args_1b(void (*callback)(void)) {} // expected-error-re {{'callback' attribute references function of type 'void ({{(void)?}})' which expects 0 arguments but attribute specifies 1 parameter index argument}}
46
+
__attribute__((callback(callback, __))) voidtoo_many_args_2b(double (*callback)(void)); // expected-error-re {{'callback' attribute references function of type 'double ({{(void)?}})' which expects 0 arguments but attribute specifies 1 parameter index argument}}
47
+
__attribute__((callback(callback, 2, 2))) voidtoo_many_args_3b(void (*callback)(int), int); // expected-error {{'callback' attribute references function of type 'void (int)' which expects 1 argument but attribute specifies 2 parameter index arguments}}
__attribute__((callback(callback, a))) voidtoo_few_args_1b(void (*callback)(int, int), inta); // expected-error {{'callback' attribute references function of type 'void (int, int)' which expects 2 arguments but attribute specifies 1 parameter index argument}}
50
+
__attribute__((callback(callback))) voidtoo_few_args_2b(int (*callback)(int)); // expected-error {{'callback' attribute references function of type 'int (int)' which expects 1 argument but attribute specifies 0 parameter index arguments}}
51
+
__attribute__((callback(callback, __))) voidtoo_few_args_3b(void (*callback)(int, int)) {} // expected-error {{'callback' attribute references function of type 'void (int, int)' which expects 2 arguments but attribute specifies 1 parameter index argument}}
__attribute__((callback(callback, __))) voidvararg_cb_1b(void (*callback)(int, ...)) {} // expected-error {{'callback' attribute callee may not be variadic}}
69
69
__attribute__((callback(1, a))) voidvararg_cb_2b(void (*callback)(int, ...), inta); // expected-error {{'callback' attribute callee may not be variadic}}
__attribute__((callback(1, __, callback))) voidself_arg_1b(void (*callback)(int, ...)) {} // expected-error {{'callback' attribute references function of type 'void (int, ...)' which expects 1 argument but attribute specifies 2 parameter index arguments}}
75
+
__attribute__((callback(callback, __, callback, __, __, callback))) voidself_arg_2b(void (*callback)(int, ...)); // expected-error {{'callback' attribute references function of type 'void (int, ...)' which expects 1 argument but attribute specifies 5 parameter index arguments}}
0 commit comments