From 0b07e9267102642fa28343cf45e2384406f5df7a Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Sun, 27 Oct 2019 22:12:41 -0400 Subject: [PATCH] ctf: Remove redundant declarations of lexer/parser functions MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit I get these warnings: CC libctf_parser_la-lexer.lo lexer.c:857:17: error: redundant redeclaration of ‘yyunput’ [-Werror=redundant-decls] 857 | | ^ /home/simark/src/babeltrace/src/plugins/ctf/common/metadata/lexer.l:55:13: note: previous declaration of ‘yyunput’ was here 55 | static void yyunput (int c, register char * yy_bp , yyscan_t yyscanner) | ^~~~~~~ CC libctf_parser_la-lexer.lo lexer.c:871:12: error: redundant redeclaration of ‘input’ [-Werror=redundant-decls] 871 | #else | ^ /home/simark/src/babeltrace/src/plugins/ctf/common/metadata/lexer.l:55:12: note: previous declaration of ‘input’ was here 55 | static int input (yyscan_t yyscanner) __attribute__((unused)); | ^~~~~ CC libctf_parser_la-parser.lo /home/simark/src/babeltrace/src/plugins/ctf/common/metadata/parser.y:63:5: error: redundant redeclaration of ‘yyparse’ [-Werror=redundant-decls] 63 | int yyparse(struct ctf_scanner *scanner, yyscan_t yyscanner); | ^~~~~~~ In file included from /home/simark/src/babeltrace/src/plugins/ctf/common/metadata/parser-wrap.h:41, from /home/simark/src/babeltrace/src/plugins/ctf/common/metadata/parser.y:47: parser.h:192:5: note: previous declaration of ‘yyparse’ was here 192 | int yyparse (struct ctf_scanner *scanner, yyscan_t yyscanner); | ^~~~~~~ Because of the __attribute__((unused)), when removing the declarations of yyunput and input from lexer.l, I expected to get a "-Wunused-function" warning. But that doesn't seem to be the case (even when manually enabling -Wunused-function), so I'm giving a shot at removing those declarations, since they may not be essential. The yyparse declaration is not essential, since there's one already in the generated parser.h. There is a slight possibility that older bison versions (I'm using 3.4.2) produce different results, but I can't easily test right now. Change-Id: I73ff02896db1f40d476757b3207629a3ff20ac39 Signed-off-by: Simon Marchi Reviewed-on: https://review.lttng.org/c/babeltrace/+/2274 Reviewed-by: Francis Deslauriers --- configure.ac | 1 - src/plugins/ctf/common/metadata/lexer.l | 4 ---- src/plugins/ctf/common/metadata/parser.y | 2 -- 3 files changed, 7 deletions(-) diff --git a/configure.ac b/configure.ac index b9edbf54..b7a3f336 100644 --- a/configure.ac +++ b/configure.ac @@ -674,7 +674,6 @@ AX_COMPILER_FLAGS( -Wno-undef dnl -Wno-missing-prototypes dnl -Wno-missing-declarations dnl - -Wno-redundant-decls dnl -Wno-double-promotion dnl -Wno-cast-align dnl ]) diff --git a/src/plugins/ctf/common/metadata/lexer.l b/src/plugins/ctf/common/metadata/lexer.l index 4f268dc6..55a42d61 100644 --- a/src/plugins/ctf/common/metadata/lexer.l +++ b/src/plugins/ctf/common/metadata/lexer.l @@ -52,10 +52,6 @@ BT_HIDDEN void setstring(struct ctf_scanner *scanner, YYSTYPE *lvalp, const char *src); -static void yyunput (int c, register char * yy_bp , yyscan_t yyscanner) - __attribute__((unused)); -static int input (yyscan_t yyscanner) __attribute__((unused)); - BT_HIDDEN int import_string(struct ctf_scanner *scanner, YYSTYPE *lvalp, const char *src, char delim); diff --git a/src/plugins/ctf/common/metadata/parser.y b/src/plugins/ctf/common/metadata/parser.y index 71f2d5fe..54d28b6f 100644 --- a/src/plugins/ctf/common/metadata/parser.y +++ b/src/plugins/ctf/common/metadata/parser.y @@ -59,8 +59,6 @@ _bt_list_splice_tail (struct bt_list_head *add, struct bt_list_head *head) } } -BT_HIDDEN -int yyparse(struct ctf_scanner *scanner, yyscan_t yyscanner); BT_HIDDEN int yylex(union YYSTYPE *yyval, yyscan_t yyscanner); BT_HIDDEN -- 2.34.1