mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-01 06:05:24 +02:00
Allow const-qualified arg for __atomic builtins which accept that
This commit is contained in:
parent
3b72e60406
commit
6ea3d70456
2 changed files with 31 additions and 19 deletions
|
@ -7719,6 +7719,14 @@ public class AST2Tests extends AST2TestBase {
|
|||
parseAndCheckBindings(ScannerKind.GNU);
|
||||
}
|
||||
|
||||
// const volatile int cv_var = 0;
|
||||
// int get() {
|
||||
// return __atomic_load_n(&cv_var, 0);
|
||||
// }
|
||||
public void testAtomicLoadNOfConstVolatile() throws Exception {
|
||||
parseAndCheckBindings(ScannerKind.GNU);
|
||||
}
|
||||
|
||||
// void waldo(...);
|
||||
public void testVariadicCFunction_452416() throws Exception {
|
||||
BindingAssertionHelper bh = getAssertionHelper(C);
|
||||
|
|
|
@ -160,14 +160,15 @@ public class GCCBuiltinSymbolProvider implements IBuiltinBindingsProvider {
|
|||
for (String type : types) {
|
||||
// Manual does not mention volatile, however functions can be used for ptr to volatile
|
||||
String typePtr = type + " volatile *";
|
||||
function(type, "__atomic_load_n", typePtr, "int");
|
||||
function("void", "__atomic_load", typePtr, typePtr, "int");
|
||||
String typeConstPtr = type + " const volatile *";
|
||||
function(type, "__atomic_load_n", typeConstPtr, "int");
|
||||
function("void", "__atomic_load", typeConstPtr, typePtr, "int");
|
||||
function("void", "__atomic_store_n", typePtr, type, "int");
|
||||
function("void", "__atomic_store", typePtr, typePtr, "int");
|
||||
function(type, "__atomic_exchange_n", typePtr, type, "int");
|
||||
function("void", "__atomic_exchange", typePtr, typePtr, typePtr, "int");
|
||||
function("bool", "__atomic_compare_exchange_n", typePtr, typePtr, type, "int", "int", "int");
|
||||
function("bool", "__atomic_compare_exchange", typePtr, typePtr, typePtr, "int", "int", "int");
|
||||
function("bool", "__atomic_compare_exchange_n", typePtr, typeConstPtr, type, "int", "int", "int");
|
||||
function("bool", "__atomic_compare_exchange", typePtr, typeConstPtr, typePtr, "int", "int", "int");
|
||||
function(type, "__atomic_add_fetch", typePtr, type, "int");
|
||||
function(type, "__atomic_sub_fetch", typePtr, type, "int");
|
||||
function(type, "__atomic_and_fetch", typePtr, type, "int");
|
||||
|
@ -608,22 +609,25 @@ public class GCCBuiltinSymbolProvider implements IBuiltinBindingsProvider {
|
|||
|
||||
boolean isConst = false;
|
||||
boolean isVolatile = false;
|
||||
if (tstr.startsWith("const ")) {
|
||||
isConst = true;
|
||||
tstr = tstr.substring(6);
|
||||
}
|
||||
if (tstr.endsWith("const")) {
|
||||
isConst = true;
|
||||
tstr = tstr.substring(0, tstr.length() - 5).trim();
|
||||
}
|
||||
if (tstr.startsWith("volatile ")) {
|
||||
isVolatile = true;
|
||||
tstr = tstr.substring(9);
|
||||
}
|
||||
if (tstr.endsWith("volatile")) {
|
||||
isVolatile = true;
|
||||
tstr = tstr.substring(0, tstr.length() - 8).trim();
|
||||
|
||||
while (true) {
|
||||
if (tstr.startsWith("const ")) {
|
||||
isConst = true;
|
||||
tstr = tstr.substring(6);
|
||||
} else if (tstr.endsWith("const")) {
|
||||
isConst = true;
|
||||
tstr = tstr.substring(0, tstr.length() - 5).trim();
|
||||
} else if (tstr.startsWith("volatile ")) {
|
||||
isVolatile = true;
|
||||
tstr = tstr.substring(9);
|
||||
} else if (tstr.endsWith("volatile")) {
|
||||
isVolatile = true;
|
||||
tstr = tstr.substring(0, tstr.length() - 8).trim();
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
int q = 0;
|
||||
if (tstr.startsWith("signed ")) {
|
||||
q |= IBasicType.IS_SIGNED;
|
||||
|
|
Loading…
Add table
Reference in a new issue