From 7dfd7ca3b421cbecafa3414acf61dffe468a8903 Mon Sep 17 00:00:00 2001 From: Chandler Carruth Date: Thu, 5 Oct 2023 10:36:59 -0700 Subject: [PATCH] Fix minor UB in the treesitter scanner. (#3267) In C, the signature `f()` is distinct from `f(void)` -- dating from K&R style prototype-less functions. We need to use the `f(void)` form for the scanner creation function so that it can be called by function pointer `void *(*)(void)` without UB. This was causing a local test that includes treesitter to fail with our fastbuild that enables most sanitizers. With this, we may be able to enable treesitter on our CI as well, but it at least fixes my local test runs. --- utils/treesitter/src/scanner.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/treesitter/src/scanner.c b/utils/treesitter/src/scanner.c index 36d885029f80..65fd3a26bb52 100644 --- a/utils/treesitter/src/scanner.c +++ b/utils/treesitter/src/scanner.c @@ -11,7 +11,7 @@ enum TokenType { }; // our scanner is stateless -void* tree_sitter_carbon_external_scanner_create() { return NULL; } +void* tree_sitter_carbon_external_scanner_create(void) { return NULL; } unsigned tree_sitter_carbon_external_scanner_serialize( __attribute__((unused)) void* payload,