Buildfarm member anchovy has been failing for the last couple of days,
evidently because its owner just couldn't wait to adopt bison 3.0,
which is all of 3 days old.  The failures look like

cubeparse.y:42.1-13: warning: deprecated directive, use '%name-prefix' 
[-Wdeprecated]
 %name-prefix="cube_yy"
 ^^^^^^^^^^^^^

(which looks like 3.0 isn't actually ready for prime time, but at least
it's only a warning)

cubeparse.c:163:5: error: conflicting types for 'cube_yyparse'
 int cube_yyparse (void);
     ^
cubeparse.y:32:5: note: previous declaration of 'cube_yyparse' was here
 int cube_yyparse(void *result);
     ^

A look in the Bison release notes explains this one: they stopped
supporting YYPARSE_PARAM, which contrib/cube and contrib/seg both use.
The recommended replacement is %parse-param, which is certainly a whole
lot cleaner: it lets you specify the datatype of the extra parser
parameter, instead of having it default to "void *".  This option also
changes the signature of yyerror(), but that's not a problem.

At first I thought this was going to make us go through a tool upgrade
exercise, because I couldn't find %parse-param in the documentation for
bison 1.875, which is our oldest supported version.  But further
research shows that %parse-param actually was introduced in 1.875,
they just forgot to document it :-(.

So I propose the attached patch, which I've verified still works with
1.875.  I don't plan to install 3.0 just to test this, but I assume it's
OK there.

I'm thinking we should apply this to all supported branches, in case
somebody gets the idea to build an older branch with bleeding-edge
tools.  Any objections?

                        regards, tom lane

diff --git a/contrib/cube/cube.c b/contrib/cube/cube.c
index ce8eaa870fc760b7c7b4607e0844c38ffd5e56bb..dab0e6e7586e306ecfabb6537789a91f95d656e8 100644
*** a/contrib/cube/cube.c
--- b/contrib/cube/cube.c
*************** PG_MODULE_MAGIC;
*** 26,33 ****
  #define ARRPTR(x)  ( (double *) ARR_DATA_PTR(x) )
  #define ARRNELEMS(x)  ArrayGetNItems( ARR_NDIM(x), ARR_DIMS(x))
  
! extern int	cube_yyparse();
! extern void cube_yyerror(const char *message);
  extern void cube_scanner_init(const char *str);
  extern void cube_scanner_finish(void);
  
--- 26,33 ----
  #define ARRPTR(x)  ( (double *) ARR_DATA_PTR(x) )
  #define ARRNELEMS(x)  ArrayGetNItems( ARR_NDIM(x), ARR_DIMS(x))
  
! extern int	cube_yyparse(NDBOX **result);
! extern void cube_yyerror(NDBOX **result, const char *message);
  extern void cube_scanner_init(const char *str);
  extern void cube_scanner_finish(void);
  
*************** Datum
*** 156,167 ****
  cube_in(PG_FUNCTION_ARGS)
  {
  	char	   *str = PG_GETARG_CSTRING(0);
! 	void	   *result;
  
  	cube_scanner_init(str);
  
  	if (cube_yyparse(&result) != 0)
! 		cube_yyerror("bogus input");
  
  	cube_scanner_finish();
  
--- 156,167 ----
  cube_in(PG_FUNCTION_ARGS)
  {
  	char	   *str = PG_GETARG_CSTRING(0);
! 	NDBOX	   *result;
  
  	cube_scanner_init(str);
  
  	if (cube_yyparse(&result) != 0)
! 		cube_yyerror(&result, "bogus input");
  
  	cube_scanner_finish();
  
diff --git a/contrib/cube/cubeparse.y b/contrib/cube/cubeparse.y
index 21fe5378773da012bd223f4437f02d248da6b6c6..d7205b824cb5c0f21c913b5746552898d8590327 100644
*** a/contrib/cube/cubeparse.y
--- b/contrib/cube/cubeparse.y
***************
*** 1,10 ****
  %{
  /* NdBox = [(lowerleft),(upperright)] */
  /* [(xLL(1)...xLL(N)),(xUR(1)...xUR(n))] */
  
- /* contrib/cube/cubeparse.y */
- 
- #define YYPARSE_PARAM result  /* need this to pass a pointer (void *) to yyparse */
  #define YYSTYPE char *
  #define YYDEBUG 1
  
--- 1,9 ----
  %{
+ /* contrib/cube/cubeparse.y */
+ 
  /* NdBox = [(lowerleft),(upperright)] */
  /* [(xLL(1)...xLL(N)),(xUR(1)...xUR(n))] */
  
  #define YYSTYPE char *
  #define YYDEBUG 1
  
*************** extern int cube_yylex(void);
*** 28,35 ****
  static char *scanbuf;
  static int	scanbuflen;
  
! void cube_yyerror(const char *message);
! int cube_yyparse(void *result);
  
  static int delim_count(char *s, char delim);
  static NDBOX * write_box(unsigned int dim, char *str1, char *str2);
--- 27,34 ----
  static char *scanbuf;
  static int	scanbuflen;
  
! extern int	cube_yyparse(NDBOX **result);
! extern void cube_yyerror(NDBOX **result, const char *message);
  
  static int delim_count(char *s, char delim);
  static NDBOX * write_box(unsigned int dim, char *str1, char *str2);
*************** static NDBOX * write_point_as_box(char *
*** 38,43 ****
--- 37,43 ----
  %}
  
  /* BISON Declarations */
+ %parse-param {NDBOX **result}
  %expect 0
  %name-prefix="cube_yy"
  
*************** box: O_BRACKET paren_list COMMA paren_li
*** 70,76 ****
  			YYABORT;
  		}
  
! 		*((void **)result) = write_box( dim, $2, $4 );
  
  	}
  
--- 70,76 ----
  			YYABORT;
  		}
  
! 		*result = write_box( dim, $2, $4 );
  
  	}
  
*************** box: O_BRACKET paren_list COMMA paren_li
*** 97,103 ****
  			YYABORT;
  		}
  
! 		*((void **)result) = write_box( dim, $1, $3 );
  	}
  
  	| paren_list
--- 97,103 ----
  			YYABORT;
  		}
  
! 		*result = write_box( dim, $1, $3 );
  	}
  
  	| paren_list
*************** box: O_BRACKET paren_list COMMA paren_li
*** 114,120 ****
  			YYABORT;
  		}
  
! 		*((void **)result) = write_point_as_box($1, dim);
  	}
  
  	| list
--- 114,120 ----
  			YYABORT;
  		}
  
! 		*result = write_point_as_box($1, dim);
  	}
  
  	| list
*************** box: O_BRACKET paren_list COMMA paren_li
*** 130,136 ****
  							   CUBE_MAX_DIM)));
  			YYABORT;
  		}
! 		*((void **)result) = write_point_as_box($1, dim);
  	}
  	;
  
--- 130,136 ----
  							   CUBE_MAX_DIM)));
  			YYABORT;
  		}
! 		*result = write_point_as_box($1, dim);
  	}
  	;
  
diff --git a/contrib/cube/cubescan.l b/contrib/cube/cubescan.l
index 8f917cd33adc282ffba11c5d5f9d9703e6d025a0..e383b59d3d0d40f64d7432585e508a0f347f8dfd 100644
*** a/contrib/cube/cubescan.l
--- b/contrib/cube/cubescan.l
*************** float        ({integer}|{real})([eE]{int
*** 61,67 ****
  %%
  
  void __attribute__((noreturn))
! yyerror(const char *message)
  {
  	if (*yytext == YY_END_OF_BUFFER_CHAR)
  	{
--- 61,67 ----
  %%
  
  void __attribute__((noreturn))
! yyerror(NDBOX **result, const char *message)
  {
  	if (*yytext == YY_END_OF_BUFFER_CHAR)
  	{
diff --git a/contrib/seg/seg.c b/contrib/seg/seg.c
index 1c14c49fecab78e7f4da6be9f6e71489f371be6e..0cf9853060b4e127876cd6da267f93dcd0783009 100644
*** a/contrib/seg/seg.c
--- b/contrib/seg/seg.c
***************
*** 23,30 ****
  
  PG_MODULE_MAGIC;
  
! extern int	seg_yyparse();
! extern void seg_yyerror(const char *message);
  extern void seg_scanner_init(const char *str);
  extern void seg_scanner_finish(void);
  
--- 23,30 ----
  
  PG_MODULE_MAGIC;
  
! extern int	seg_yyparse(SEG *result);
! extern void seg_yyerror(SEG *result, const char *message);
  extern void seg_scanner_init(const char *str);
  extern void seg_scanner_finish(void);
  
*************** seg_in(PG_FUNCTION_ARGS)
*** 126,132 ****
  	seg_scanner_init(str);
  
  	if (seg_yyparse(result) != 0)
! 		seg_yyerror("bogus input");
  
  	seg_scanner_finish();
  
--- 126,132 ----
  	seg_scanner_init(str);
  
  	if (seg_yyparse(result) != 0)
! 		seg_yyerror(result, "bogus input");
  
  	seg_scanner_finish();
  
diff --git a/contrib/seg/segparse.y b/contrib/seg/segparse.y
index e6a0bad59125e1bad3324502ef5e153c254c5381..3fad9910bd54d382368a352d466ea2c203aa99c8 100644
*** a/contrib/seg/segparse.y
--- b/contrib/seg/segparse.y
***************
*** 1,5 ****
  %{
! #define YYPARSE_PARAM result  /* need this to pass a pointer (void *) to yyparse */
  
  #include "postgres.h"
  
--- 1,5 ----
  %{
! /* contrib/seg/segparse.y */
  
  #include "postgres.h"
  
*************** extern int seg_yylex(void);
*** 24,31 ****
  
  extern int significant_digits(char *str);		/* defined in seg.c */
  
! void seg_yyerror(const char *message);
! int seg_yyparse(void *result);
  
  static float seg_atof(char *value);
  
--- 24,31 ----
  
  extern int significant_digits(char *str);		/* defined in seg.c */
  
! extern int	seg_yyparse(SEG *result);
! extern void seg_yyerror(SEG *result, const char *message);
  
  static float seg_atof(char *value);
  
*************** static char strbuf[25] = {
*** 40,45 ****
--- 40,46 ----
  %}
  
  /* BISON Declarations */
+ %parse-param {SEG *result}
  %expect 0
  %name-prefix="seg_yy"
  
*************** static char strbuf[25] = {
*** 65,123 ****
  
  range: boundary PLUMIN deviation
  	{
! 		((SEG *)result)->lower = $1.val - $3.val;
! 		((SEG *)result)->upper = $1.val + $3.val;
! 		sprintf(strbuf, "%g", ((SEG *)result)->lower);
! 		((SEG *)result)->l_sigd = Max(Min(6, significant_digits(strbuf)), Max($1.sigd, $3.sigd));
! 		sprintf(strbuf, "%g", ((SEG *)result)->upper);
! 		((SEG *)result)->u_sigd = Max(Min(6, significant_digits(strbuf)), Max($1.sigd, $3.sigd));
! 		((SEG *)result)->l_ext = '\0';
! 		((SEG *)result)->u_ext = '\0';
  	}
  
  	| boundary RANGE boundary
  	{
! 		((SEG *)result)->lower = $1.val;
! 		((SEG *)result)->upper = $3.val;
! 		if ( ((SEG *)result)->lower > ((SEG *)result)->upper ) {
  			ereport(ERROR,
  					(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
  					 errmsg("swapped boundaries: %g is greater than %g",
! 							((SEG *)result)->lower, ((SEG *)result)->upper)));
  
  			YYERROR;
  		}
! 		((SEG *)result)->l_sigd = $1.sigd;
! 		((SEG *)result)->u_sigd = $3.sigd;
! 		((SEG *)result)->l_ext = ( $1.ext ? $1.ext : '\0' );
! 		((SEG *)result)->u_ext = ( $3.ext ? $3.ext : '\0' );
  	}
  
  	| boundary RANGE
  	{
! 		((SEG *)result)->lower = $1.val;
! 		((SEG *)result)->upper = HUGE_VAL;
! 		((SEG *)result)->l_sigd = $1.sigd;
! 		((SEG *)result)->u_sigd = 0;
! 		((SEG *)result)->l_ext = ( $1.ext ? $1.ext : '\0' );
! 		((SEG *)result)->u_ext = '-';
  	}
  
  	| RANGE boundary
  	{
! 		((SEG *)result)->lower = -HUGE_VAL;
! 		((SEG *)result)->upper = $2.val;
! 		((SEG *)result)->l_sigd = 0;
! 		((SEG *)result)->u_sigd = $2.sigd;
! 		((SEG *)result)->l_ext = '-';
! 		((SEG *)result)->u_ext = ( $2.ext ? $2.ext : '\0' );
  	}
  
  	| boundary
  	{
! 		((SEG *)result)->lower = ((SEG *)result)->upper = $1.val;
! 		((SEG *)result)->l_sigd = ((SEG *)result)->u_sigd = $1.sigd;
! 		((SEG *)result)->l_ext = ((SEG *)result)->u_ext = ( $1.ext ? $1.ext : '\0' );
  	}
  	;
  
--- 66,124 ----
  
  range: boundary PLUMIN deviation
  	{
! 		result->lower = $1.val - $3.val;
! 		result->upper = $1.val + $3.val;
! 		sprintf(strbuf, "%g", result->lower);
! 		result->l_sigd = Max(Min(6, significant_digits(strbuf)), Max($1.sigd, $3.sigd));
! 		sprintf(strbuf, "%g", result->upper);
! 		result->u_sigd = Max(Min(6, significant_digits(strbuf)), Max($1.sigd, $3.sigd));
! 		result->l_ext = '\0';
! 		result->u_ext = '\0';
  	}
  
  	| boundary RANGE boundary
  	{
! 		result->lower = $1.val;
! 		result->upper = $3.val;
! 		if ( result->lower > result->upper ) {
  			ereport(ERROR,
  					(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
  					 errmsg("swapped boundaries: %g is greater than %g",
! 							result->lower, result->upper)));
  
  			YYERROR;
  		}
! 		result->l_sigd = $1.sigd;
! 		result->u_sigd = $3.sigd;
! 		result->l_ext = ( $1.ext ? $1.ext : '\0' );
! 		result->u_ext = ( $3.ext ? $3.ext : '\0' );
  	}
  
  	| boundary RANGE
  	{
! 		result->lower = $1.val;
! 		result->upper = HUGE_VAL;
! 		result->l_sigd = $1.sigd;
! 		result->u_sigd = 0;
! 		result->l_ext = ( $1.ext ? $1.ext : '\0' );
! 		result->u_ext = '-';
  	}
  
  	| RANGE boundary
  	{
! 		result->lower = -HUGE_VAL;
! 		result->upper = $2.val;
! 		result->l_sigd = 0;
! 		result->u_sigd = $2.sigd;
! 		result->l_ext = '-';
! 		result->u_ext = ( $2.ext ? $2.ext : '\0' );
  	}
  
  	| boundary
  	{
! 		result->lower = result->upper = $1.val;
! 		result->l_sigd = result->u_sigd = $1.sigd;
! 		result->l_ext = result->u_ext = ( $1.ext ? $1.ext : '\0' );
  	}
  	;
  
diff --git a/contrib/seg/segscan.l b/contrib/seg/segscan.l
index 95139f4631800f5ced1cb21ef24f7839ccb2b840..a3e685488a80706b80ca0a0d17df7b1a7393593d 100644
*** a/contrib/seg/segscan.l
--- b/contrib/seg/segscan.l
*************** float        ({integer}|{real})([eE]{int
*** 60,66 ****
  %%
  
  void __attribute__((noreturn))
! yyerror(const char *message)
  {
  	if (*yytext == YY_END_OF_BUFFER_CHAR)
  	{
--- 60,66 ----
  %%
  
  void __attribute__((noreturn))
! yyerror(SEG *result, const char *message)
  {
  	if (*yytext == YY_END_OF_BUFFER_CHAR)
  	{
-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to