Drop warning-free support for Flex 2.5.35
authorPeter Eisentraut <[email protected]>
Wed, 15 Jan 2025 14:35:08 +0000 (15:35 +0100)
committerPeter Eisentraut <[email protected]>
Wed, 15 Jan 2025 14:35:08 +0000 (15:35 +0100)
This removes all the various workarounds for avoiding compiler
warnings with Flex 2.5.35.  Several recent es have added
additional warnings that would either need to be fixed along the lines
of the existing workarounds, or we decide to no longer care about
this, which we do here.

Flex 2.5.35 is extremely outdated, and you can't even download it
anymore from any of the Flex project sites, so it's nearly impossible
to support.

After this, using Flex 2.5.35 will still work, but the generated code
will produce numerous compiler warnings.

Reviewed-by: Tom Lane <[email protected]>
Discussion: https://www.postgresql.org/message-id/1a204ccd-7ae6-478c-a431-407b5c48ccc6@eisentraut.org

13 files changed:
src/Makefile.global.in
src/backend/parser/Makefile
src/backend/parser/meson.build
src/backend/parser/scan.l
src/bin/pgbench/exprscan.l
src/bin/psql/Makefile
src/bin/psql/meson.build
src/bin/psql/psqlscanslash.l
src/fe_utils/Makefile
src/fe_utils/meson.build
src/fe_utils/psqlscan.l
src/tools/fix-old-flex-code.pl[deleted file]
src/tools/pgflex

index eac3d0012113d0b1a5ba2234dba1aab90339847f..1278b7744f460f7ed18a06e3e14382ec373f8aa1 100644 (file)
@@ -788,7 +788,6 @@ TAS         = @TAS@
 %.c: %.l
    $(FLEX) $(if $(FLEX_NO_BACKUP),-b) $(FLEXFLAGS) -o'$@' $<
    @$(if $(FLEX_NO_BACKUP),if [ `wc -l <lex.backup` -eq 1 ]; then rm lex.backup; else echo "Scanner requires backup; see lex.backup." 1>&2; exit 1; fi)
-   $(if $(FLEX_FIX_WARNING),$(PERL) $(top_srcdir)/src/tools/fix-old-flex-code.pl '$@')
 
 %.c: %.y
    $(if $(BISON_CHECK_CMD),$(BISON_CHECK_CMD))
index 3162a01f302d486f570e8f3705350b33a2545ea1..8c0fe28d63f5917eb977cffeb08c74d8f6a26f2d 100644 (file)
@@ -59,7 +59,6 @@ gram.c: BISON_CHECK_CMD = $(PERL) $(srcdir)/check_keywords.pl $< $(top_srcdir)/s
 
 scan.c: FLEXFLAGS = -CF -p -p
 scan.c: FLEX_NO_BACKUP=yes
-scan.c: FLEX_FIX_WARNING=yes
 
 
 # Force these dependencies to be known even without dependency info built:
index 4c3ca25dd49f60e6a507b1a5b1e60aeb8c923013..874aa749aa69a1112ad67cfa1bcb63da82f42311 100644 (file)
@@ -30,7 +30,7 @@ parser_sources = files('parser.c')
 backend_scanner = custom_target('scan',
   input: 'scan.l',
   output: 'scan.c',
-  command: [flex_cmd, '--no-backup', '--fix-warnings', '--', '-CF', '-p', '-p'],
+  command: [flex_cmd, '--no-backup', '--', '-CF', '-p', '-p'],
 )
 generated_sources += backend_scanner
 parser_sources += backend_scanner
index 8031a78b9085356a7daff496b564de16b10727af..08990831fe81ad463bceb8a8fcd52e63d230d81c 100644 (file)
@@ -130,15 +130,6 @@ static void addunicode(pg_wchar c, yyscan_t yyscanner);
 static void check_string_escape_warning(unsigned char ychar, core_yyscan_t yyscanner);
 static void check_escape_warning(core_yyscan_t yyscanner);
 
-/*
- * Work around a bug in flex 2.5.35: it emits a couple of functions that
- * it forgets to emit declarations for.  Since we use -Wmissing-s,
- * this would cause warnings.  Providing our own declarations should be
- * harmless even when the bug gets fixed.
- */
-extern int core_yyget_column(yyscan_t yyscanner);
-extern void core_yyset_column(int column_no, yyscan_t yyscanner);
-
 %}
 
 %option reentrant
index a1cd232248f8f3156786358012c1bf171738f1a9..46f6ea0512106708e4819bc70923111cc3a0b708 100644 (file)
@@ -44,15 +44,6 @@ static const char *expr_command = NULL;
 /* indicates whether last yylex() call read a newline */
 static bool last_was_newline = false;
 
-/*
- * Work around a bug in flex 2.5.35: it emits a couple of functions that
- * it forgets to emit declarations for.  Since we use -Wmissing-s,
- * this would cause warnings.  Providing our own declarations should be
- * harmless even when the bug gets fixed.
- */
-extern int expr_yyget_column(yyscan_t yyscanner);
-extern void expr_yyset_column(int column_no, yyscan_t yyscanner);
-
 /* LCOV_EXCL_START */
 
 %}
index e9e4ade1d2ea8d2c2017bb087aba7801d613ad8a..5b1545d9948adee3e1fa953bf83e31f4b4e88eae 100644 (file)
@@ -60,7 +60,6 @@ sql_help.h: create_help.pl $(wildcard $(REFDOCDIR)/*.sgml)
 
 psqlscanslash.c: FLEXFLAGS = -Cfe -p -p
 psqlscanslash.c: FLEX_NO_BACKUP=yes
-psqlscanslash.c: FLEX_FIX_WARNING=yes
 
 tab-complete.c: gen_tabcomplete.pl tab-complete.in.c
    $(PERL) $^ --outfile $@
index c2ef14ccead6e18d5482524cf895cc19dcf6417d..f795ff282711c05282e0ff9bb92759f22b32f9e0 100644 (file)
@@ -19,7 +19,7 @@ psql_sources = files(
 psqlscanslash = custom_target('psqlscanslash',
   input: 'psqlscanslash.l',
   output: 'psqlscanslash.c',
-  command: [flex_cmd, '--no-backup', '--fix-warnings', '--', '-Cfe', '-p', '-p'])
+  command: [flex_cmd, '--no-backup', '--', '-Cfe', '-p', '-p'])
 generated_sources += psqlscanslash
 psql_sources += psqlscanslash
 
index f76b7722ac7c7e7eae97263207159e7915798243..ae7602a61dfc1d30bfc2df4f86287d7521ec03c3 100644 (file)
@@ -57,15 +57,6 @@ static void evaluate_backtick(PsqlScanState state);
 
 #define ECHO psqlscan_emit(cur_state, yytext, yyleng)
 
-/*
- * Work around a bug in flex 2.5.35: it emits a couple of functions that
- * it forgets to emit declarations for.  Since we use -Wmissing-s,
- * this would cause warnings.  Providing our own declarations should be
- * harmless even when the bug gets fixed.
- */
-extern int slash_yyget_column(yyscan_t yyscanner);
-extern void slash_yyset_column(int column_no, yyscan_t yyscanner);
-
 /* LCOV_EXCL_START */
 
 %}
index f9ca5de280503e0af114a11cfbac96711c5ff06d..28196ce0f6ae69c9a0860cbf8d42a457553e8709 100644 (file)
@@ -51,7 +51,6 @@ libpgfeutils.a: $(OBJS)
 
 psqlscan.c: FLEXFLAGS = -Cfe -p -p
 psqlscan.c: FLEX_NO_BACKUP=yes
-psqlscan.c: FLEX_FIX_WARNING=yes
 
 # libpgfeutils could be useful to contrib, so install it
 install: all installdirs
index 171268d65e120aee42744bb858dbc28bf7f4cfd1..a18cbc939e4124ebb3092db437f53f3a29d69efd 100644 (file)
@@ -23,7 +23,7 @@ fe_utils_sources = files(
 psqlscan = custom_target('psqlscan',
   input: 'psqlscan.l',
   output: 'psqlscan.c',
-  command: [flex_cmd, '--no-backup', '--fix-warnings', '--', '-Cfe', '-p', '-p'],
+  command: [flex_cmd, '--no-backup', '--', '-Cfe', '-p', '-p'],
 )
 generated_sources += psqlscan
 fe_utils_sources += psqlscan
index e1cb726f326554677a787f8bde107d965b6dfa37..b3c6b88e9ca87419ca75692a052a29ea9190779f 100644 (file)
@@ -61,15 +61,6 @@ typedef int YYSTYPE;
 
 #define ECHO psqlscan_emit(cur_state, yytext, yyleng)
 
-/*
- * Work around a bug in flex 2.5.35: it emits a couple of functions that
- * it forgets to emit declarations for.  Since we use -Wmissing-s,
- * this would cause warnings.  Providing our own declarations should be
- * harmless even when the bug gets fixed.
- */
-extern int psql_yyget_column(yyscan_t yyscanner);
-extern void psql_yyset_column(int column_no, yyscan_t yyscanner);
-
 %}
 
 %option reentrant
diff --git a/src/tools/fix-old-flex-code.pl b/src/tools/fix-old-flex-code.pl
deleted file mode 100644 (file)
index c1c91db..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-#!/usr/bin/perl
-#----------------------------------------------------------------------
-#
-# fix-old-flex-code.pl
-#
-# flex versions before 2.5.36, with certain option combinations, produce
-# code that causes an "unused variable" warning.  That's annoying, so
-# let's suppress it by inserting a dummy reference to the variable.
-# (That's exactly what 2.5.36 and later do ...)
-#
-# Portions Copyright (c) 1996-2025, PostgreSQL Global Development Group
-# Portions Copyright (c) 1994, Regents of the University of California
-#
-# src/tools/fix-old-flex-code.pl
-#
-#----------------------------------------------------------------------
-
-use strict;
-use warnings FATAL => 'all';
-
-# Get command line argument.
-usage() if $#ARGV != 0;
-my $filename = shift;
-
-# Suck in the whole file.
-local $/ = undef;
-my $cfile;
-open($cfile, '<', $filename) || die "opening $filename for reading: $!";
-my $ccode = <$cfile>;
-close($cfile);
-
-# No need to do anything if it's not flex 2.5.x for x < 36.
-exit 0 if $ccode !~ m/^#define YY_FLEX_MAJOR_VERSION 2$/m;
-exit 0 if $ccode !~ m/^#define YY_FLEX_MINOR_VERSION 5$/m;
-exit 0 if $ccode !~ m/^#define YY_FLEX_SUBMINOR_VERSION (\d+)$/m;
-exit 0 if $1 >= 36;
-
-# Apply the desired .
-$ccode =~
-  s|(struct yyguts_t \* yyg = \(struct yyguts_t\*\)yyscanner; /\* This var may be unused depending upon options. \*/
-.*?)
-   return yy_is_jam \? 0 : yy_current_state;
-|$1
-   (void) yyg;
-   return yy_is_jam ? 0 : yy_current_state;
-|s;
-
-# Write the modified file back out.
-open($cfile, '>', $filename) || die "opening $filename for writing: $!";
-print $cfile $ccode;
-close($cfile);
-
-exit 0;
-
-
-sub usage
-{
-   die <<EOM;
-Usage: fix-old-flex-code.pl c-file-name
-
-fix-old-flex-code.pl modifies a flex output file to suppress
-an unused-variable warning that occurs with older flex versions.
-
-Report bugs to <pgsql-bugs\@lists.postgresql.org>.
-EOM
-}
index baabe2df1c8eb0ffba360a29ea7d62863d833adf..3986b06874e759112c3964d7cdb115bab4ee4136 100755 (executable)
@@ -4,7 +4,6 @@
 # Wrapper around flex that:
 # - ensures lex.backup is created in a private directory
 # - can error out if lex.backup is created (--no-backup)
-# - can fix warnings (--fix-warnings)
 # - works around concurrency issues with win_flex.exe:
 #   https://.com/lexxmark/winflexbison/issues/86
 
@@ -28,8 +27,6 @@ parser.add_argument('-o', dest='output_file', type=abspath, required=True,
 parser.add_argument('-i', dest='input_file', type=abspath, help='input file')
 
 
-parser.add_argument('--fix-warnings', action='store_true',
-                    help='whether to fix warnings in generated file')
 parser.add_argument('--no-backup', action='store_true',
                     help='whether no_backup is enabled or not')
 
@@ -72,14 +69,4 @@ if args.no_backup:
             sys.exit('Scanner requires backup; see lex.backup.')
     os.remove('lex.backup')
 
-# fix warnings
-if args.fix_warnings:
-    fix_warning_script = os.path.join(args.srcdir,
-                                      'src/tools/fix-old-flex-code.pl')
-
-    command = [args.perl, fix_warning_script, args.output_file]
-    sp = subprocess.run(command)
-    if sp.returncode != 0:
-        sys.exit(sp.returncode)
-
 sys.exit(0)