mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 14:42:11 +02:00
Bug 533822 - Support void* as an argument type for the GNU sync builtins
Change-Id: Idabea11af3ae00cc9bf63070b5b211e2c1242e97
This commit is contained in:
parent
a3211e7cf6
commit
e17354be5c
2 changed files with 25 additions and 3 deletions
|
@ -11269,6 +11269,15 @@ public class AST2CPPTests extends AST2CPPTestBase {
|
||||||
parseAndCheckBindings(getAboveComment(), CPP, true);
|
parseAndCheckBindings(getAboveComment(), CPP, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// int main() {
|
||||||
|
// void* p;
|
||||||
|
// __sync_bool_compare_and_swap(&p, p, p);
|
||||||
|
// __sync_fetch_and_add(&p, p, 2);
|
||||||
|
// }
|
||||||
|
public void testGNUSyncBuiltinsOnVoidPtr_533822() throws Exception {
|
||||||
|
parseAndCheckBindings(getAboveComment(), CPP, true);
|
||||||
|
}
|
||||||
|
|
||||||
// // __int128_t and __uint128_t are available but are not keywords.
|
// // __int128_t and __uint128_t are available but are not keywords.
|
||||||
// void a() {
|
// void a() {
|
||||||
// __int128_t s;
|
// __int128_t s;
|
||||||
|
|
|
@ -128,10 +128,10 @@ public class GCCBuiltinSymbolProvider implements IBuiltinBindingsProvider {
|
||||||
function("void*", "__builtin_frame_address", "unsigned int");
|
function("void*", "__builtin_frame_address", "unsigned int");
|
||||||
|
|
||||||
// __sync Builtins (https://gcc.gnu.org/onlinedocs/gcc/_005f_005fsync-Builtins.html)
|
// __sync Builtins (https://gcc.gnu.org/onlinedocs/gcc/_005f_005fsync-Builtins.html)
|
||||||
String[] types= {"int", "long", "long long", "unsigned int", "unsigned long", "unsigned long long"};
|
String[] types= {"int", "long", "long long", "unsigned int", "unsigned long", "unsigned long long", "void*"};
|
||||||
for (String type : types) {
|
for (String type : types) {
|
||||||
// Manual does not mention volatile, however functions can be used for ptr to volatile
|
// Manual does not mention volatile, however functions can be used for ptr to volatile
|
||||||
String typePtr= "volatile " + type + "*";
|
String typePtr= type + " volatile *";
|
||||||
function(type, "__sync_fetch_and_add", typePtr, type, "...");
|
function(type, "__sync_fetch_and_add", typePtr, type, "...");
|
||||||
function(type, "__sync_fetch_and_sub", typePtr, type, "...");
|
function(type, "__sync_fetch_and_sub", typePtr, type, "...");
|
||||||
function(type, "__sync_fetch_and_or", typePtr, type, "...");
|
function(type, "__sync_fetch_and_or", typePtr, type, "...");
|
||||||
|
@ -154,7 +154,7 @@ public class GCCBuiltinSymbolProvider implements IBuiltinBindingsProvider {
|
||||||
// __atomic Builtins (https://gcc.gnu.org/onlinedocs/gcc/_005f_005fatomic-Builtins.html)
|
// __atomic Builtins (https://gcc.gnu.org/onlinedocs/gcc/_005f_005fatomic-Builtins.html)
|
||||||
for (String type : types) {
|
for (String type : types) {
|
||||||
// Manual does not mention volatile, however functions can be used for ptr to volatile
|
// Manual does not mention volatile, however functions can be used for ptr to volatile
|
||||||
String typePtr= "volatile " + type + "*";
|
String typePtr= type + " volatile *";
|
||||||
function(type, "__atomic_load_n", typePtr, "int");
|
function(type, "__atomic_load_n", typePtr, "int");
|
||||||
function("void", "__atomic_load", typePtr, typePtr, "int");
|
function("void", "__atomic_load", typePtr, typePtr, "int");
|
||||||
function("void", "__atomic_store_n", typePtr, type, "int");
|
function("void", "__atomic_store_n", typePtr, type, "int");
|
||||||
|
@ -544,10 +544,18 @@ public class GCCBuiltinSymbolProvider implements IBuiltinBindingsProvider {
|
||||||
isConst= true;
|
isConst= true;
|
||||||
tstr= tstr.substring(6);
|
tstr= tstr.substring(6);
|
||||||
}
|
}
|
||||||
|
if (tstr.endsWith("const")) {
|
||||||
|
isConst= true;
|
||||||
|
tstr= tstr.substring(0, tstr.length() - 5).trim();
|
||||||
|
}
|
||||||
if (tstr.startsWith("volatile ")) {
|
if (tstr.startsWith("volatile ")) {
|
||||||
isVolatile= true;
|
isVolatile= true;
|
||||||
tstr= tstr.substring(9);
|
tstr= tstr.substring(9);
|
||||||
}
|
}
|
||||||
|
if (tstr.endsWith("volatile")) {
|
||||||
|
isVolatile= true;
|
||||||
|
tstr= tstr.substring(0, tstr.length() - 8).trim();
|
||||||
|
}
|
||||||
int q= 0;
|
int q= 0;
|
||||||
if (tstr.startsWith("signed ")) {
|
if (tstr.startsWith("signed ")) {
|
||||||
q |= IBasicType.IS_SIGNED;
|
q |= IBasicType.IS_SIGNED;
|
||||||
|
@ -601,6 +609,11 @@ public class GCCBuiltinSymbolProvider implements IBuiltinBindingsProvider {
|
||||||
new CPointerType(new CFunctionType(rt, IType.EMPTY_TYPE_ARRAY), 0);
|
new CPointerType(new CFunctionType(rt, IType.EMPTY_TYPE_ARRAY), 0);
|
||||||
} else if (tstr.equals("size_t")) {
|
} else if (tstr.equals("size_t")) {
|
||||||
t= toType("unsigned long");
|
t= toType("unsigned long");
|
||||||
|
} else if (tstr.equals("void*")) {
|
||||||
|
// This can occur inside a qualifier type in which case it's not handled
|
||||||
|
// by the general '*' check above.
|
||||||
|
t= fCpp ? new CPPPointerType(new CPPBasicType(Kind.eVoid, q))
|
||||||
|
: new CPointerType(new CBasicType(Kind.eVoid, q), 0);
|
||||||
} else {
|
} else {
|
||||||
throw new IllegalArgumentException(type);
|
throw new IllegalArgumentException(type);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue