diff --git a/nala/inspect.py b/nala/inspect.py index 4e1c2bc..09a5b7c 100644 --- a/nala/inspect.py +++ b/nala/inspect.py @@ -362,6 +362,16 @@ def parse(self): if self.functions: return + # PATCH BEGIN + # It turns out that at least gcc 15.2 outputs typedefs using '__int128' during preproccesing + # step which is not parsable by pycparser. For this reason we simply removeall 128-bit typedefs here! + typedefs_code = [] + for elem in self.typedefs_code: + if "__int128" in elem: + continue + typedefs_code.append(elem) + self.typedefs_code = typedefs_code + # PATCH END code = '\n'.join( self.typedefs_code + self.structs_code + self.func_signatures) self.file_ast = self.cparser.parse(code) @@ -374,7 +384,7 @@ def parse(self): # not the AST list is searched for the first 'c_ast.FuncDecl' starting from the # calculated `func_offset`. The index of the first detected 'c_ast.FuncDecl' is # then used as new `func_offset`! - if not isinstance(self.file_ast.ext[func_offset].type, c_ast.FuncDecl): + if func_offset < len(self.file_ast.ext) and not isinstance(self.file_ast.ext[func_offset].type, c_ast.FuncDecl): for i in range(func_offset, len(self.file_ast.ext)): if isinstance(self.file_ast.ext[i].type, c_ast.FuncDecl): func_offset = i diff --git a/tests/test_command_line.py b/tests/test_command_line.py index 78ec6d2..027955d 100644 --- a/tests/test_command_line.py +++ b/tests/test_command_line.py @@ -31,6 +31,7 @@ def remove_optput(): def pre_process_file(name): command = [ 'gcc', + '-std=c17', # this avoids gcc to use gnu extensions, which are not supported by pycparser '-E', '-I', 'nala/dist', '-o', f'tests/files/{name}/test_tests.pp.c',