Include bison header files into implementation files
authorPeter Eisentraut <peter@eisentraut.org>
Fri, 2 Aug 2024 07:59:35 +0000 (09:59 +0200)
committerPeter Eisentraut <peter@eisentraut.org>
Fri, 2 Aug 2024 08:25:11 +0000 (10:25 +0200)
Before Bison 3.4, the generated parser implementation files run afoul
of -Wmissing-variable-declarations (in spite of commit ab61c40bfa2)
because declarations for yylval and possibly yylloc are missing.  The
generated header files contain an extern declaration, but the
implementation files don't include the header files.  Since Bison 3.4,
the generated implementation files automatically include the generated
header files, so then it works.

To make this work with older Bison versions as well, include the
generated header file from the .y file.

(With older Bison versions, the generated implementation file contains
effectively a copy of the header file pasted in, so including the
header file is redundant.  But we know this works anyway because the
core grammar uses this arrangement already.)

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 fd56d0e16280dfebf627fa75551f5269775e7ed4..52622875cbb883f61fe81d2c198253aa7a2d36dd 100644 (file)
 #include "utils/float.h"
 #include "varatt.h"
 
+/* All grammar constructs return strings */
+#define YYSTYPE char *
+
+#include "cubeparse.h"
+
 /* silence -Wmissing-variable-declarations */
 extern int cube_yychar;
 extern int cube_yynerrs;
 
-/* All grammar constructs return strings */
-#define YYSTYPE char *
-
 /*
  * 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 9635c3af6e62713e0a05fdc03fcf4df4fcf03cea..3e4aa31cada653b80956487edc032cc65eaea5d7 100644 (file)
@@ -12,6 +12,7 @@
 #include "utils/float.h"
 
 #include "segdata.h"
+#include "segparse.h"
 
 /* silence -Wmissing-variable-declarations */
 extern int seg_yychar;
index 58e0878dc8dd31c1e5f292e604f5b7816b9141e4..73a7592fb7167b5559f7b9b91d3a5ae3c403adca 100644 (file)
@@ -32,6 +32,7 @@
 #include "nodes/makefuncs.h"
 #include "utils/memutils.h"
 
+#include "bootparse.h"
 
 /* silence -Wmissing-variable-declarations */
 extern int boot_yychar;
index c46ca395263106298947014449ca44692ff0f24d..06daa9548132d565d1799041fd44017971c069a8 100644 (file)
@@ -22,6 +22,7 @@
 #include "replication/walsender.h"
 #include "replication/walsender_private.h"
 
+#include "repl_gram.h"
 
 /* silence -Wmissing-variable-declarations */
 extern int replication_yychar;
index 5ce4f1bfe73c033705a766a3f687cbbfbde4ea33..e4d9962226c411a5f0f7bfd19b03539e302253da 100644 (file)
@@ -17,6 +17,8 @@
 #include "nodes/pg_list.h"
 #include "replication/syncrep.h"
 
+#include "syncrep_gram.h"
+
 /* Result of parsing is returned in one of these two variables */
 SyncRepConfigData *syncrep_parse_result;
 char      *syncrep_parse_error_msg;
index 571b92f643461d467794395dd67c187c507674da..3790a601d1a9006250ecc8bd9aeb3cb51686f35e 100644 (file)
@@ -5,6 +5,7 @@
 #include "postgres_fe.h"
 
 #include "preproc_extern.h"
+#include "preproc.h"
 #include "ecpg_config.h"
 #include <unistd.h>
 
index 0671ff787229ebb08382f16f601974041dbfa45e..8182ce28aa1f76fa43a40a05afa6c8e0daad3953 100644 (file)
@@ -26,6 +26,7 @@
 
 #include "plpgsql.h"
 
+#include "pl_gram.h"
 
 /* silence -Wmissing-variable-declarations */
 extern int plpgsql_yychar;
index 282a750455651371c6d3d4bdde1d47deb7f7df54..788069d1ba5751804ed68aa33eea9604a4263091 100644 (file)
@@ -13,6 +13,7 @@
 #include "postgres_fe.h"
 
 #include "isolationtester.h"
+#include "specparse.h"
 
 /* silence -Wmissing-variable-declarations */
 extern int spec_yychar;