On Fri, Mar 16, 2018 at 5:38 PM, Alexandre Oliva <aol...@redhat.com> wrote: > resolve_typename_type may peek into template types that might still be > specialized. In some cases, e.g. g++.dg/template/friend48.C or > g++.dg/template/decl2.C, that is exactly the right thing to do. In > others, like the newly-added testcase g++.dg/template/pr84789.C, it > isn't, and if the qualifying scope happens to resolve to a non-template > type, we resolve to that and then fail the assert that checks we still > have a template-dependent scope.
We're looking inside them because we're trying to parse a declarator; the tentative parse will fail in this case, because we aren't in a declarator, but that doesn't mean it's wrong to peek. Though I'm not sure why cp_parser_parse_and_diagnose_invalid_type_name is passing true for declarator_p to cp_parser_id_expression. I'm going to try changing that to false and see if anything breaks. > It appears to me that, in cases in which the assert would fail, we are > missing the typename keyword, and we ought to report an error; if we > just return the incoming type unchanged, that's exactly what we get. > So, I'm turning such failed asserts into early returns, so that the > parser can recover and report an error. I disagree; it seems to me that the assert should allow the case where the scope was originally dependent, but got resolved earlier in the function. Jason