Re: Bison 3.5 - y.tab.c generates compiler warnings

Andy Fiddaman <[email protected]>
Newsgroups gmane.comp.parsers.bison.bugs
Message-ID <[email protected]>
On Wed, 18 Dec 2019, Paul Eggert wrote:

; On 12/18/19 10:22 PM, Akim Demaille wrote:
; > I was unable to reproduce that warning (https://travis-ci.org/akimd/bison/builds/626034753)
;
; I suspect you need a platform where plain 'char' is unsigned, so that 'typedef
; yytype_uint8 yy_state_t;' is treated as if it were 'typedef char yy_state_t;'
; which means yy_state_t indexes provoke the diagnostic. (A GCC bug, if you ask me.)

Given this in the template:

	#if defined __UINT_LEAST8_MAX__ && __UINT_LEAST8_MAX__ <= __INT_MAX__
	typedef __UINT_LEAST8_TYPE__ yytype_uint8;
	#elif (!defined __UINT_LEAST8_MAX__ && defined YY_STDINT_H \
	       && UINT_LEAST8_MAX <= INT_MAX)
	typedef uint_least8_t yytype_uint8;
	#elif !defined __UINT_LEAST8_MAX__ && UCHAR_MAX <= INT_MAX
	typedef unsigned char yytype_uint8;
	#else
	typedef short yytype_uint8;
	#endif

and this from gcc:

	#define __UINT_LEAST8_MAX__ 0xff
	#define __INT_MAX__ 0x7fffffff
	#define __UINT_LEAST8_TYPE__ unsigned char

It's the first part of the clause that is being selected and ending up with

	typedef unsigned char yytype_uint8;

Andy
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.