[llvm-bugs] [Bug 48107] New: __attribute__((callback(4))) gives confusing error message

via llvm-bugs llvm-bugs at lists.llvm.org
Sat Nov 7 09:33:10 PST 2020


https://bugs.llvm.org/show_bug.cgi?id=48107

            Bug ID: 48107
           Summary: __attribute__((callback(4))) gives confusing error
                    message
           Product: clang
           Version: 11.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C
          Assignee: unassignedclangbugs at nondot.org
          Reporter: felix-llvm at fefe.de
                CC: blitzrakete at gmail.com, dgregor at apple.com,
                    erik.pilkington at gmail.com, llvm-bugs at lists.llvm.org,
                    richard-llvm at metafoo.co.uk

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?

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20201107/cef4af7e/attachment.html>


More information about the llvm-bugs mailing list