Subject: 27.1; c++ keyword "final" causes etags to fail to generate tags for that class and its members

From: Martin Stiaszny <[email-masked]>
Date: Thu, 12 Nov 2020 12:21:41 -0800

command:
etags --declarations --language=c++ base.h child.h

base.h:
class base {
  int bar;
}

child.h:
class child final : public base {
  int foo;
}

TAGS file:

base.h,32
class base 1,0
  int bar;2,13

child.h,0

If I delete the "final" keyword from child.h, as such:

class child : public base {
  int foo;
}

The tags are generated correctly:
mstiaszny@5057-desktop:~/src/etags-test$ cat TAGS

base.h,32
class base 1,0
  int bar;2,13

child.h,33
class child 1,0
  int foo;2,28

I did some step-through debugging and created this patch that does indeed
allow tags to be generated for final classes:

mstiaszny@5057-desktop:~/src/emacs/emacs-27.1/lib-src$ diff etags.c
etags.c.orig
3733,3735d3732
<           else if (structdef == stagseen && !cjava && (strncmp(lp - 1,
"final", 5) == 0)) {
<             lp += 4;
<           }

However, that is almost certainly not the correct way to fix this; this is
only here to be a guide for the maintainer.  Bug #43203 -
https://debbugs.gnu.org/cgi/bugreport.cgi?bug=43203 maybe be a symptom of
the same underlying issue.

--- info from M-x report-emacs-bug; probably not relevant, since this is an
etags problem ---

In GNU Emacs 27.1 (build 1, x86_64-pc-linux-gnu, GTK+ Version 2.24.23)
 of 2020-10-26 built on 5057-desktop
System Description: Ubuntu 14.04.6 LTS

Configured features:
XPM JPEG TIFF GIF PNG SOUND DBUS GSETTINGS GLIB NOTIFY INOTIFY GNUTLS
LIBXML2 FREETYPE XFT ZLIB TOOLKIT_SCROLL_BARS GTK2 X11 XDBE XIM MODULES
THREADS PDUMPER

Important settings:
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8-unix

Major mode: Info

Minor modes in effect:
  tooltip-mode: t
  global-eldoc-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  buffer-read-only: t
  column-number-mode: t
  line-number-mode: t
  transient-mark-mode: t

Load-path shadows:
None found.

Features:
(shadow emacsbug sendmail novice sort gnus-cite shr-color color
mail-extr gnus-async gnus-bcklg qp gnus-agent gnus-srvr gnus-score
score-mode nnvirtual nntp gnus-ml gnus-msg disp-table nndoc gnus-cache
gnus-dup gnus-art mm-uu mml2015 mm-view mml-smime smime dig gnus-sum shr
svg dom gnus-group gnus-undo gnus-start gnus-cloud nnimap nnmail
mail-source utf7 netrc nnoo parse-time iso8601 gnus-spec gnus-int
gnus-range gnus-win gnus nnheader crm org ob ob-tangle ob-ref ob-lob
ob-table ob-exp org-macro org-footnote org-src ob-comint org-pcomplete
pcomplete org-list org-faces org-entities noutline outline org-version
ob-emacs-lisp ob-core ob-eval org-table ol org-keys org-compat advice
org-macs org-loaddefs find-func cal-menu calendar cal-loaddefs
debbugs-gnu pcase edmacro kmacro add-log debbugs soap-client warnings
rng-xsd rng-dt rng-util xsd-regexp xml compile comint ansi-color ring
autoload radix-tree tar-mode arc-mode archive-mode cus-edit cus-start
cus-load wid-edit cl-extra mm-archive message dired dired-loaddefs
format-spec rfc822 mml mml-sec epa derived gnus-util rmail
rmail-loaddefs text-property-search time-date mailabbrev gmm-utils
mailheader mm-decode mm-bodies mm-encode mail-utils lisp-mnt help-mode
gnutls network-stream url-http mail-parse rfc2231 rfc2047 rfc2045
mm-util ietf-drums mail-prsvr url-gw nsm rmc puny url-cache url-auth url
url-proxy url-privacy url-expand url-methods url-history url-cookie
url-domsuf url-util mailcap epg epg-config misearch multi-isearch
mule-util jka-compr info vc-git diff-mode easy-mmode term/xterm xterm
finder-inf rx package easymenu browse-url url-handlers url-parse
auth-source cl-seq eieio eieio-core cl-macs eieio-loaddefs
password-cache json subr-x map url-vars seq byte-opt gv bytecomp
byte-compile cconv cl-loaddefs cl-lib tooltip eldoc electric uniquify
ediff-hook vc-hooks lisp-float-type mwheel term/x-win x-win
term/common-win x-dnd tool-bar dnd fontset image regexp-opt fringe
tabulated-list replace newcomment text-mode elisp-mode lisp-mode
prog-mode register page tab-bar menu-bar rfn-eshadow isearch timer
select scroll-bar mouse jit-lock font-lock syntax facemenu font-core
term/tty-colors frame minibuffer cl-generic cham georgian utf-8-lang
misc-lang vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms
cp51932 hebrew greek romanian slovak czech european ethiopic indian
cyrillic chinese composite charscript charprop case-table epa-hook
jka-cmpr-hook help simple abbrev obarray cl-preloaded nadvice loaddefs
button faces cus-face macroexp files text-properties overlay sha1 md5
base64 format env code-pages mule custom widget hashtable-print-readable
backquote threads dbusbind inotify dynamic-setting system-font-setting
font-render-setting move-toolbar gtk x-toolkit x multi-tty
make-network-process emacs)

Memory information:
((conses 16 557294 194503)
 (symbols 48 24597 2)
 (strings 32 127018 26928)
 (string-bytes 1 3504683)
 (vectors 16 33787)
 (vector-slots 8 406071 52780)
 (floats 8 6497 1337)
 (intervals 56 5924 5924)
 (buffers 1000 37)
 (heap 1024 30911 9014))