diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2Tests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2Tests.java index 5659a02f42d..c231849c001 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2Tests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2Tests.java @@ -7719,6 +7719,14 @@ public void testAtomicBuiltin_bug456131() throws Exception { 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); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/GCCBuiltinSymbolProvider.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/GCCBuiltinSymbolProvider.java index b8f895c1895..cfe08adf4ba 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/GCCBuiltinSymbolProvider.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/GCCBuiltinSymbolProvider.java @@ -160,14 +160,15 @@ private void addGnuBuiltins() { 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 @@ private IType createType(final String type) { 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;