public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] intl/plural.y: define macros to avoid multiple conflicting declarations of yyerror and yylex
@ 2021-12-12  9:24 Andrea Monaco
  2021-12-21 22:49 ` Arjun Shankar
  0 siblings, 1 reply; 5+ messages in thread
From: Andrea Monaco @ 2021-12-12  9:24 UTC (permalink / raw)
  To: libc-alpha


Hello.


My glibc 2.34 failed building on GNU/Hurd, though the problem may be
independent of the platform.

That's the error in intl/plural.y:

/root/glibc-2.34/build/intl/plural.c:69:25: error: static declaration of '__gettextlex' follows non-static declaration
   69 | #define yylex           __gettextlex
      |                         ^~~~~~~~~~~~
plural.y:57:12: note: in expansion of macro 'yylex'
   57 | static int yylex (YYSTYPE *lval, struct parse_args *arg);
      |            ^~~~~
/root/glibc-2.34/build/intl/plural.c:203:5: note: previous declaration of '__gettextlex' was here
  203 | int __gettextlex (YYSTYPE *yylvalp, struct parse_args *arg);
      |     ^~~~~~~~~~~~
/root/glibc-2.34/build/intl/plural.c:70:25: error: static declaration of '__gettexterror' follows non-static declaration
   70 | #define yyerror         __gettexterror
      |                         ^~~~~~~~~~~~~~
plural.y:58:13: note: in expansion of macro 'yyerror'
   58 | static void yyerror (struct parse_args *arg, const char *str);
      |             ^~~~~~~
/root/glibc-2.34/build/intl/plural.c:200:6: note: previous declaration of '__gettexterror' was here
  200 | void __gettexterror (struct parse_args *arg, const char *msg);
      |      ^~~~~~~~~~~~~~



The reason are these line in the generated build/intl/plural.c:

  #if !defined __gettexterror && !defined YYERROR_IS_DECLARED
  void __gettexterror (struct parse_args *arg, const char *msg);
  #endif
  #if !defined __gettextlex && !defined YYLEX_IS_DECLARED
  int __gettextlex (YYSTYPE *yylvalp, struct parse_args *arg);
  #endif

Those default prototypes provided by bison trigger a conflict between
multiple declarations.  This patch solves the issue.  Thanks.


Andrea Monaco



diff --git a/intl/plural.y b/intl/plural.y
index e02e74541c..8573b56563 100644
--- a/intl/plural.y
+++ b/intl/plural.y
@@ -40,6 +40,11 @@
 # define __gettextparse PLURAL_PARSE
 #endif
 
+/* Later we provide those prototypes. Without these macros, bison may
+   generate its own prototypes with possible conflicts */
+#define YYLEX_IS_DECLARED
+#define YYERROR_IS_DECLARED
+
 %}
 %parse-param {struct parse_args *arg}
 %lex-param {struct parse_args *arg}

^ permalink raw reply	[flat|nested] 5+ messages in thread
* Re: [PATCH] intl/plural.y: define macros to avoid multiple conflicting declarations of yyerror and yylex
@ 2021-12-21 23:54 Andrea Monaco
  2021-12-22 13:45 ` Arjun Shankar
  0 siblings, 1 reply; 5+ messages in thread
From: Andrea Monaco @ 2021-12-21 23:54 UTC (permalink / raw)
  To: arjun; +Cc: libc-alpha


  > I'm trying to reproduce this and have been unable to see these lines
  > generated with bison-3.6.4, 3.7.6, and 3.8.2.


Mine is gnu bison 3.8.  I got the same problem in binutils
(https://lists.gnu.org/archive/html/bug-binutils/2021-11/msg00057.html)
and it was replicated by a person, though we fixed it in a different way.



Let me know,

Andrea Monaco

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-12-22 15:07 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-12  9:24 [PATCH] intl/plural.y: define macros to avoid multiple conflicting declarations of yyerror and yylex Andrea Monaco
2021-12-21 22:49 ` Arjun Shankar
2021-12-21 23:54 Andrea Monaco
2021-12-22 13:45 ` Arjun Shankar
2021-12-22 15:07   ` Arjun Shankar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).