[gdb/build] Fix YYSTYPE and yyalloc odr violation
authorTom de Vries <tdevries@suse.de>
Mon, 14 Aug 2023 20:52:52 +0000 (22:52 +0200)
committerTom de Vries <tdevries@suse.de>
Mon, 14 Aug 2023 20:52:52 +0000 (22:52 +0200)
When building gdb with -O2 -flto I run into:
...
ada-exp.c.tmp:576:7: error: type ‘union YYSTYPE’ violates the C++ One \
  Definition Rule [-Werror=odr]
...

Fix this by renaming to ada_exp_YYSTYPE and likewise for other .y files.

Likewise for yyalloc.

Tested on x86_64-linux.  Also tested with byacc rather than bison on
suggestion of Tom Tromey.

Approved-By: Tom Tromey <tom@tromey.com>
PR build/22395
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=22395

gdb/Makefile.in

index 8521e8d11c80f38b5f7bb79f4f3ed2ea46650212..ccdd84beea63b21c7e7bffb2e57dbb4cd585af30 100644 (file)
@@ -2509,6 +2509,8 @@ po/$(PACKAGE).pot: force
             -e 's/\([ \t;,(]\)free$$/\1xfree/g' \
             -e '/^#line.*y.tab.c/d' \
             -e 's/YY_NULL/YY_NULLPTR/g' \
+            -e "s/YYSTYPE/$(subst -,_,$*)_YYSTYPE/g" \
+            -e "s/yyalloc/$(subst -,_,$*)_yyalloc/g" \
          < $@.tmp > $@.new && \
          rm -f $@.tmp && \
          mv $@.new $@