Reduced testcase:
$ cat z.c
void f(volatile int* ptr, int val) {
__sync_fetch_and_add_4(ptr, val);
}
void g(volatile int* ptr, int val) {
__sync_fetch_and_add_4(ptr, val);
}
$ ~/llvm_trunk/Release+Asserts/bin/clang -c z.c
z.c:5:3: error: call to '__sync_fetch_and_add_4' is ambiguous
__sync_fetch_and_add_4(ptr, val);
^~~~~~~~~~~~~~~~~~~~~~
z.c:2:3: note: candidate function
__sync_fetch_and_add_4(ptr, val);
^
z.c:2:3: note: candidate function
1 error generated.
Removing g function the error disappears...
As a side note I've noted this in Builtins.def:
BUILTIN(__sync_fetch_and_add_4, "iiD*i.", "nt")
The signature seems wrong to me: should not it be "iD*i."?
d0k
September 21, 2012, 7:28pm
#2
The signature looks right to me, the first "i" is the return type. There seems to be something wrong with the special handling code for __sync_ builtins in Sema.
- Ben
Reduced testcase:
$ cat z.c
void f(volatile int* ptr, int val) {
__sync_fetch_and_add_4(ptr, val);
}
void g(volatile int* ptr, int val) {
__sync_fetch_and_add_4(ptr, val);
}
$ ~/llvm_trunk/Release+Asserts/bin/clang -c z.c
z.c:5:3: error: call to '__sync_fetch_and_add_4' is ambiguous
__sync_fetch_and_add_4(ptr, val);
^~~~~~~~~~~~~~~~~~~~~~
z.c:2:3: note: candidate function
__sync_fetch_and_add_4(ptr, val);
^
z.c:2:3: note: candidate function
1 error generated.
Removing g function the error disappears...
As a side note I've noted this in Builtins.def:
BUILTIN(__sync_fetch_and_add_4, "iiD*i.", "nt")
The signature seems wrong to me: should not it be "iD*i."?
The signature looks right to me, the first "i" is the return type.
Stupid me! Of course you are right. I've been misleaded by comparison
with __sync_fetch_and_add signature.
There seems to be something wrong with the special handling code for __sync_ builtins in Sema.
Do you have some idea about the causes of that?