__attribute__((callback(4))) gives confusing error message · Issue #47451 · llvm/llvm-project (original) (raw)

Bugzilla Link 48107
Version 11.0
OS Linux
Reporter LLVM Bugzilla Contributor
CC @DougGregor,@jdoerfert,@zygoloid

Extended Description

I am trying to use the callback attribute to annotate functions in my code.
I tried to annotate qmail in my libc header with it. Here is a minimal test case to illustrate my problem:

typedef int pthread_t; typedef int pthread_attr_t; typedef unsigned long size_t;

attribute((callback (3, 4))) int pthread_create(pthread_t *thread, const pthread_attr_t *attr, void *(*start_routine) (void *), void *arg);

attribute((callback (4))) void qsort(void *base, size_t nmemb, size_t size, int (*compar)(const void *, const void *));

Compiling this gives:

% clang -c y.c
y.c:9:16: error: 'callback' attribute takes no arguments
__attribute__((callback (4)))
               ^
1 error generated.

Uh, wot? I'm not sure what is happening here. As I understand the documentation, having just one argument to callback is OK here. But I tried putting it as (4,1) instead, but that also does not compile, with this error message:

y.c:9:16: error: 'callback' attribute takes one argument
__attribute__((callback (4, 1)))

What is going on here?