https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99208
--- Comment #1 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Nathan Sidwell <nat...@gcc.gnu.org>: https://gcc.gnu.org/g:47145e6916f58e1cd4f562c06fa7289da49f690c commit r11-7347-g47145e6916f58e1cd4f562c06fa7289da49f690c Author: Nathan Sidwell <nat...@acm.org> Date: Tue Feb 23 07:08:55 2021 -0800 c++: typedef for linkage [PR 99208] Unnamed types with a typedef name for linkage were always troublesome in modules. This is the underlying cause of that trouble -- we were creating incorrect type structures. Classes have an implicit self-reference, and we created that for unnamed classes too. It turns out we make use of this member, so just not generating it turned into a rathole. This member is created using the anonymous name -- because we've not yet met the typedef name. When we retrofit the typedef name we were checking identifier matching and changing all type variants with that identifier. Which meant we ended up with a strange typedef for the self reference. This fixes things to check for DECL identity of the variants, so we don't smash the self-reference -- that continues to have the anonymous name. PR c++/99208 gcc/cp/ * decl.c (name_unnamed_type): Check DECL identity, not IDENTIFIER identity. gcc/testsuite/ * g++.dg/modules/pr99208_a.C: New. * g++.dg/modules/pr99208_b.C: New.