bug-bison
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

%api.prefix and -Wodr


From: Tom Tromey
Subject: %api.prefix and -Wodr
Date: Fri, 29 Dec 2023 12:48:53 -0700

Hi.

I'm trying to fix a problem with GNU source highlight, where using LTO
and -Wodr emits a number of problems relating to yacc.  This program
uses multiple yacc parsers.

I changed source highlight to require bison and to use %define api.prefix.
However, even with this change, I get some warnings from -Wodr.

I've appended the relevant parts of the error output.

Note that some of these may be GCC problems instead... I think the
"stringdefs" errors are just wrong.

The yyalloc and yysymbol_kind_t errors seem correct, though.

I'm happy to push my WIP branch to savannah if that would help.

I'm using system tools on x86-64 Fedora 38, so:

prentzel. gcc --version
gcc (GCC) 13.2.1 20231011 (Red Hat 13.2.1-4)
Copyright (C) 2023 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

prentzel. bison --version
bison (GNU Bison) 3.8.2
Written by Robert Corbett and Richard Stallman.

Copyright (C) 2021 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Tom

../../../lib/srchilite/styleparser.cc:471:7: warning: type 'union yyalloc' 
violates the C++ One Definition Rule [-Wodr]
  471 | union yyalloc
      |       ^
../../../lib/srchilite/outlangdefparser.cc:478:7: note: a different type is 
defined in another translation unit
  478 | union yyalloc
      |       ^
../../../lib/srchilite/styleparser.cc:474:11: note: the first difference of 
corresponding definitions is field 'yyvs_alloc'
  474 |   YYSTYPE yyvs_alloc;
      |           ^
../../../lib/srchilite/outlangdefparser.cc:481:11: note: a field of same name 
but different type is defined in another translation unit
  481 |   YYSTYPE yyvs_alloc;
      |           ^
../../../lib/srchilite/styleparser.cc:471:7: note: type name 'STYLESC_STYPE' 
should match type name 'OUTLANGDEF_STYPE'
  471 | union yyalloc
      |       ^
../../../lib/srchilite/langdefparser.h:95:7: warning: type 'union 
LANGDEF_STYPE' violates the C++ One Definition Rule [-Wodr]
   95 | union LANGDEF_STYPE
      |       ^
../../../lib/srchilite/langdefparser.h:95:7: note: a different type is defined 
in another translation unit
   95 | union LANGDEF_STYPE
      |       ^
../../../lib/srchilite/langdefparser.yy:102:21: note: the first difference of 
corresponding definitions is field 'stringdefs'
  102 |   class StringDefs *stringdefs;
      |                     ^
../../../lib/srchilite/langdefparser.yy:102:21: note: a field of same name but 
different type is defined in another translation unit
  102 |   class StringDefs *stringdefs;
      |                     ^
../../../lib/srchilite/stringdef.h:110:7: note: type name 
'srchilite::StringDefs' should match type name 'StringDefs'
  110 | class StringDefs : public StringDefsBase {
      |       ^
../../../lib/srchilite/langdefparser.yy:102:9: note: the incompatible type is 
defined here
  102 |   class StringDefs *stringdefs;
      |         ^
../../../lib/srchilite/langdefparser.h:137:22: warning: 'langdef_lval' violates 
the C++ One Definition Rule [-Wodr]
  137 | extern LANGDEF_STYPE langdef_lval;
      |                      ^
../../../lib/srchilite/langdefparser.cc:1151:9: note: type 'union 
LANGDEF_STYPE' itself violates the C++ One Definition Rule
 1151 | YYSTYPE yylval;
      |         ^
../../../lib/srchilite/langdefparser.cc:1151:9: note: 'langdef_lval' was 
previously declared here
../../../lib/srchilite/styleparser.cc:168:6: warning: type 'yysymbol_kind_t' 
violates the C++ One Definition Rule [-Wodr]
  168 | enum yysymbol_kind_t
      |      ^
../../../lib/srchilite/outlangdefparser.cc:164:6: note: an enum with different 
value name is defined in another translation unit
  164 | enum yysymbol_kind_t
      |      ^
../../../lib/srchilite/styleparser.cc:174:3: note: name 'YYSYMBOL_BOLD' differs 
from name 'YYSYMBOL_BEGIN_T' defined in another translation unit
  174 |   YYSYMBOL_BOLD = 3,                       /* BOLD  */
      |   ^
../../../lib/srchilite/outlangdefparser.cc:170:3: note: mismatching definition
  170 |   YYSYMBOL_BEGIN_T = 3,                    /* BEGIN_T  */
      |   ^



reply via email to

[Prev in Thread] Current Thread [Next in Thread]