1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-24 17:35:35 +02:00

Add definitions for integer overflow builtins from GCC

Closes #271
This commit is contained in:
Philipp Wendler 2023-02-02 08:51:11 +01:00 committed by Jonah Graham
parent a4ba7173e8
commit cf834dd838
2 changed files with 23 additions and 0 deletions

View file

@ -474,4 +474,13 @@ public class GCCCompleteParseExtensionsTest extends AST2TestBase {
parseGCC(code);
parseGPP(code);
}
// void test() {
// !__builtin_add_overflow_p(1,2,3);
// }
public void testIntegerOverflowBuiltin_bug271() throws Exception {
String code = getAboveComment();
parseGCC(code);
parseGPP(code);
}
}

View file

@ -190,6 +190,20 @@ public class GCCBuiltinSymbolProvider implements IBuiltinBindingsProvider {
function("bool", "__atomic_always_lock_free", "size_t", "void*");
function("bool", "__atomic_is_lock_free", "size_t", "void*");
// Integer Overflow Builtins (https://gcc.gnu.org/onlinedocs/gcc/Integer-Overflow-Builtins.html)
for (String op : new String[] { "add", "sub", "mul" }) {
function("bool", "__builtin_" + op + "_overflow", "", "", "void*");
function("bool", "__builtin_" + op + "_overflow_p", "", "", "");
function("bool", "__builtin_s" + op + "_overflow", "int", "int", "int*");
function("bool", "__builtin_s" + op + "l_overflow", "long int", "long int", "long int*");
function("bool", "__builtin_s" + op + "ll_overflow", "long long int", "long long int", "long long int*");
function("bool", "__builtin_u" + op + "_overflow", "unsigned int", "unsigned int", "unsigned int*");
function("bool", "__builtin_u" + op + "l_overflow", "unsigned long int", "unsigned long int",
"unsigned long int*");
function("bool", "__builtin_u" + op + "ll_overflow", "unsigned long long int", "unsigned long long int",
"unsigned long long int*");
}
ICPPExecution builtinFfs = new ExecBuiltin(ExecBuiltin.BUILTIN_FFS);
ICPPExecution builtinFfsl = new ExecBuiltin(ExecBuiltin.BUILTIN_FFSL);
ICPPExecution builtinFfsll = new ExecBuiltin(ExecBuiltin.BUILTIN_FFSLL);