Add extern declarations for Bison global variables
authorPeter Eisentraut <[email protected]>
Thu, 25 Jul 2024 07:26:08 +0000 (09:26 +0200)
committerPeter Eisentraut <[email protected]>
Thu, 25 Jul 2024 07:26:08 +0000 (09:26 +0200)
This adds extern declarations for some global variables produced by
Bison that are not already declared in its generated header file.
This is a workaround to be able to add -Wmissing-variable-declarations
to the global set of warning options in the near future.

Another longer-term solution would be to convert these grammars to
"pure" parsers in Bison, to avoid global variables altogether.  Note
that the core grammar is already pure, so this patch did not need to
touch it.

Reviewed-by: Andres Freund <[email protected]>
Discussion: https://www.postgresql.org/message-id/flat/e0a62134-83da-4ba4-8cdb-ceb0111c95ce@eisentraut.org

contrib/cube/cubeparse.y
contrib/seg/segparse.y
src/backend/bootstrap/bootparse.y
src/backend/replication/repl_gram.y
src/backend/replication/syncrep_gram.y
src/interfaces/ecpg/preproc/ecpg.header
src/pl/plpgsql/src/pl_gram.y
src/test/isolation/specparse.y

index b39fbe63e6b9519fc5b2dd4797531c8dbea1d91f..fd56d0e16280dfebf627fa75551f5269775e7ed4 100644 (file)
 #include "utils/float.h"
 #include "varatt.h"
 
+/* silence -Wmissing-variable-declarations */
+extern int cube_yychar;
+extern int cube_yynerrs;
+
 /* All grammar constructs return strings */
 #define YYSTYPE char *
 
index bf759dbbd84df435843d94d32754605c9ec23e62..729d4b6390b0a606016db7dbc352bcede1364180 100644 (file)
 
 #include "segdata.h"
 
+/* silence -Wmissing-variable-declarations */
+extern int seg_yychar;
+extern int seg_yynerrs;
+
 /*
  * Bison doesn't allocate anything that needs to live across parser calls,
  * so we can easily have it use palloc instead of malloc.  This prevents
index 3c9c1da0216dbef139b4655c728712ffdc304cd1..58e0878dc8dd31c1e5f292e604f5b7816b9141e4 100644 (file)
 #include "utils/memutils.h"
 
 
+/* silence -Wmissing-variable-declarations */
+extern int boot_yychar;
+extern int boot_yynerrs;
+
+
 /*
  * Bison doesn't allocate anything that needs to live across parser calls,
  * so we can easily have it use palloc instead of malloc.  This prevents
index 53780bbf29701477fcd6348c21e831b59c88fa38..c46ca395263106298947014449ca44692ff0f24d 100644 (file)
 #include "replication/walsender_private.h"
 
 
+/* silence -Wmissing-variable-declarations */
+extern int replication_yychar;
+extern int replication_yynerrs;
+
+
 /* Result of the parsing is returned here */
 Node *replication_parse_result;
 
index a14f63b6582c40985f0bf48992d8fd3a1f794e85..5ce4f1bfe73c033705a766a3f687cbbfbde4ea33 100644 (file)
@@ -24,6 +24,10 @@ char    *syncrep_parse_error_msg;
 static SyncRepConfigData *create_syncrep_config(const char *num_sync,
                    List *members, uint8 syncrep_method);
 
+/* silence -Wmissing-variable-declarations */
+extern int syncrep_yychar;
+extern int syncrep_yynerrs;
+
 /*
  * Bison doesn't allocate anything that needs to live across parser calls,
  * so we can easily have it use palloc instead of malloc.  This prevents
index 595028942560c13707b16156254e4e161b8503f0..571b92f643461d467794395dd67c187c507674da 100644 (file)
@@ -8,6 +8,10 @@
 #include "ecpg_config.h"
 #include <unistd.h>
 
+/* silence -Wmissing-variable-declarations */
+extern int base_yychar;
+extern int base_yynerrs;
+
 /* Location tracking support --- simpler than bison's default */
 #define YYLLOC_DEFAULT(Current, Rhs, N) \
    do { \
index 97be9239e3761ed0399addd61bb6079f9335196a..0671ff787229ebb08382f16f601974041dbfa45e 100644 (file)
 #include "plpgsql.h"
 
 
+/* silence -Wmissing-variable-declarations */
+extern int plpgsql_yychar;
+extern int plpgsql_yynerrs;
+
 /* Location tracking support --- simpler than bison's default */
 #define YYLLOC_DEFAULT(Current, Rhs, N) \
    do { \
index 0e8b166a53ecc898c84f72672f1454a83903a4e4..282a750455651371c6d3d4bdde1d47deb7f7df54 100644 (file)
@@ -14,6 +14,9 @@
 
 #include "isolationtester.h"
 
+/* silence -Wmissing-variable-declarations */
+extern int spec_yychar;
+extern int spec_yynerrs;
 
 TestSpec       parseresult;            /* result of parsing is left here */