On Mon, Mar 13, 2023 at 04:15:12PM -0400, Jason Merrill wrote: > The r13-6577 change to use tree_code_type_tmpl in earlier C++ dialects broke > gdbhooks, which expects tree_code_type to always be available. I considered > trying to make gdbhooks more robust, but it seemed simpler to define > tree_code_type as a reference to the template. This still ends up with a > definition of the reference in each translation unit, but that's allowed by > the > ODR because it always refers to the same entity, and is much smaller than > having the whole table in each TU. > > PR plugins/108634 > > gcc/ChangeLog: > > * tree-core.h (tree_code_type, tree_code_length): > Define even without inline variable support. > * tree.h (TREE_CODE_CLASS, TREE_CODE_LENGTH): > Only one definition.
I think it would be better to change gdbhooks.py to match what the code does. We should adjust the # extern const enum tree_code_class tree_code_type[]; # #define TREE_CODE_CLASS(CODE) tree_code_type[(int) (CODE)] comment because that isn't true even for new bootstrap compiler. And, I just wonder if val_tree_code_type = gdb.parse_and_eval('tree_code_type') couldn't be replaced with try: val_tree_code_type = gdb.parse_and_eval('tree_code_type') except; val_tree_code_type = gdb.parse_and_eval('tree_code_type_tmpl<0>::tree_code_type') or so. Jakub