On 3/23/20 8:49 AM, Jason Merrill wrote: > On 3/21/20 5:59 PM, Martin Sebor wrote: >> +      /* Diagnose class/struct/union mismatches.  IS_DECLARATION is >> false >> +     for alias definition.  */ >> +      bool decl_class = (is_declaration >> +             && cp_parser_declares_only_class_p (parser)); >>         cp_parser_check_class_key (parser, key_loc, tag_type, type, >> false, >>                    cp_parser_declares_only_class_p (parser)); > > Don't you need to use the new variable? > > Don't your testcases exercise this? Of course they do. This was a leftover from an experiment after I put the initial updated patch together. On final review I decided to adjust some comments and forgot to restore the original use of the variable. >> +      /* When TYPE is the use of an implicit specialization of a >> previously >> +     declared template set TYPE_DECL to the type of the primary template >> +     for the specialization and look it up in CLASS2LOC below.  For uses >> +     of explicit or partial specializations TYPE_DECL already points to >> +     the declaration of the specialization. >> +     IS_USE is clear so that the type of an implicit instantiation >> rather >> +     than that of a partial specialization is determined.  */ >> +      type_decl = TREE_TYPE (type_decl); >> +      if (TREE_CODE (type_decl) != TEMPLATE_DECL) >> +    type_decl = TYPE_MAIN_DECL (type_decl); > > The comment is no longer relevant to the code.  The remaining code also > seems like it would have no effect; we already know type_decl is > TYPE_MAIN_DECL (type). I removed the block of code. Martin PS I would have preferred to resolve just the reported problem in this patch and deal with the template specializations more fully (and with aliases) in a followup. As it is, it has grown bigger and more complex than I'm comfortable with, especially with the template specializations, harder for me to follow, and obviously a lot more time-consuming not just to put together but also to review. Although this revision handles many more template specialization cases correctly, there still are other (arguably corner) cases that it doesn't. I suspect getting those right might even require a design change, which I see as out of scope at this time (not to mention my ability).