On Wed, Jan 18, 2023 at 12:45:50AM +0000, Bjarni Ingi Gislason wrote:
> Package: byacc
> Version: byacc - 2.0 20221229
> Severity: normal
> 
> Dear Maintainer,
> 
>    * What led up to the situation?
> 
>   Compiling groff

(in a quick check, I compiled the version from 2022/12/28
on my Debian/oldstable without seeing this problem - but I see
the issue is compiler options).
 
> ####
> 
> output.c:       putl_code(fp, "#if !(defined(yylex) || defined(YYSTATE))\n");
> 
>   "yylex" is a name of a function but "#... defined(...)" applies to
> macros not functions(?).

That's intentional (not a bug).  It's done to allow changing the function
signature -- but not if there's already a macro to confuse things.

Here's more context:

        /* Parameters sent to lex. */
        #ifdef YYLEX_PARAM
        # define YYLEX_DECL() yylex(void *YYLEX_PARAM)
        # define YYLEX yylex(YYLEX_PARAM)
        #else
        # define YYLEX_DECL() yylex(void)
        # define YYLEX yylex()
        #endif

        #if !(defined(yylex) || defined(YYSTATE))
        int YYLEX_DECL();
        #endif

Changing that YYSTATE to YYLEX will turn off the declaration.

YYSTATE is a lex symbol (#define'd), so it seemed a better choice than
the flex-specific FLEX_SCANNER symbol which Guy Harris used in the first
version of this ifdef.

The intent here is to not use the declaration if the lex/flex code is
inserted before that point (reducing redefinition problems).

> ####
> 
>   When compiling, a warning is issued:
> 
>   CXX      src/preproc/eqn/eqn-eqn.o
> src/preproc/eqn/eqn.cpp:73:23: warning: redundant redeclaration of 'int
> yylex()' in same scope [-Wredundant-decls]
>    73 | # define YYLEX_DECL() yylex(void)
>       |                       ^~~~~

yes - that's a problem.  There's been no universally-guaranteed prototype
for yylex, so applications add one.  (There was some update on the Austin
review a couple of years ago, but the recommendation from that would run
into the same problem -- and it introduced other problems).

For this case, I could add a third symbol, which would "only" be set by
the caller (not a lex/flex symbol that one might trip over).

> src/preproc/eqn/eqn.cpp:78:5: note: in expansion of macro 'YYLEX_DECL'
>    78 | int YYLEX_DECL();
>       |     ^~~~~~~~~~
> ../src/preproc/eqn/eqn.ypp:31:5: note: previous declaration of 'int
> yylex()'
>    31 | int yylex(void);
>       |     ^~~~~
>   CXXLD    eqn
> 
> ####
> 
>   When I change "yylex" to "YYLEX" in the "putl_code(...)" line there
> is no warning.
> 
> -- System Information:
> Debian Release: bookworm/sid
>   APT prefers testing
>   APT policy: (500, 'testing')
> Architecture: amd64 (x86_64)
> 
> Kernel: Linux 6.0.12-1 (SMP w/2 CPU threads; PREEMPT)
> Kernel taint flags: TAINT_WARN
> Locale: LANG=is_IS.iso88591, LC_CTYPE=is_IS.iso88591 (charmap=ISO-8859-1), 
> LANGUAGE not set
> Shell: /bin/sh linked to /usr/bin/dash
> Init: sysvinit (via /sbin/init)
> 
> Versions of packages byacc depends on:
> ii  libc6  2.36-8
> 
> byacc recommends no packages.
> 
> byacc suggests no packages.

-- 
Thomas E. Dickey <dic...@invisible-island.net>
https://invisible-island.net

Attachment: signature.asc
Description: PGP signature

Reply via email to