From 85f21977c90a06318541b0ac547c6e273afabce9 Mon Sep 17 00:00:00 2001 From: Nick Bowler Date: Sun, 14 Jan 2024 23:28:01 -0500 Subject: [PATCH] libcdecl: Silence GCC -Wunused-function warnings in the scanner. Use the GCC unused attribute to avoid warnings in the scanner, and use the flex yyIN_HEADER macro so the static declarations don't leak out to other files (where GCC will give warnings about missing definitions). While we do this, fix a typo and remove an unneeded declaration which were both caught by this warning. --- src/scan.l | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/scan.l b/src/scan.l index e720fcf..f7e1b03 100644 --- a/src/scan.l +++ b/src/scan.l @@ -32,12 +32,18 @@ * functions static, which allows better optimization (especially wrt. * dead code elimination). */ +#if !cdecl__yyIN_HEADER + +#if __GNUC__ +# define static __attribute__((__unused__)) static +#endif + static struct yy_buffer_state *cdecl__yy_create_buffer(FILE *, int, void *); static struct yy_buffer_state *cdecl__yy_scan_bytes(const char *, int, void *); static struct yy_buffer_state *cdecl__yy_scan_buffer(char *, size_t, void *); static void cdecl__yy_switch_to_buffer(struct yy_buffer_state *, void *); static void cdecl__yy_flush_buffer(struct yy_buffer_state *, void *); -static void yypush_buffer_state(struct yy_buffer_state *, void *); +static void cdecl__yypush_buffer_state(struct yy_buffer_state *, void *); static void cdecl__yypop_buffer_state(void *); static void cdecl__yyrestart(FILE *, void *); static int cdecl__yylex_init(void **); @@ -61,11 +67,14 @@ static void cdecl__yyset_out(FILE *, void *); static void cdecl__yyset_debug(int, void *); static void cdecl__yyset_lineno(int, void *); static void cdecl__yyset_column(int, void *); -static void cdecl__yyset_leng(int, void *); static void *cdecl__yyrealloc(void *, size_t, void *); static void *cdecl__yyalloc(size_t, void *); static void cdecl__yyfree(void *, void *); + +#undef static + +#endif } %option nodefault noyywrap bison-locations reentrant never-interactive -- 2.43.2