For friend class template within dependent context:
- Should not do structure matching checking. This fixes importing failure of template with non-type parm;
- Should not be added into redecls chain.
See Sema::CheckClassTemplate().
Differential D155661
[clang][ASTImporter] Fix friend class template import within dependent context danix800 on Jul 18 2023, 5:06 PM. Authored by
Details For friend class template within dependent context:
See Sema::CheckClassTemplate().
Diff Detail
Event TimelineComment Actions The changes seem correct to me, but it'd be great if one of the more regular AST importer maintainers could verify just in case I missed something. This should probably have a release note, though.
Comment Actions The fix looks OK, but the test could be improved and cleaned up (for example FromClass is the same as FromD in the test, and DeclContext is not checked, can be done like in the test UndeclaredFriendClassShouldNotBeVisible but the AST is different). Probably there are other similar cases, and there is a related problem shown in D156693 (the fix in that patch is not correct, the solution here is not good for that case, it is possible that the same code as here needs to be changed again or a better fix is found). I am accepting this code but probably will create a new patch to improve and add tests for similar cases (if not done before by somebody else). Comment Actions Testcase will be cleaned up in the final commit.
Confirmed, but I'll not touch this issue in this commit. |
The code seems to work but I was confused by the different conditions used (is it possible that IsFriendTemplate and ShouldAddRedecl is true at the same time?). I had the observation that if ShouldAddRedecl is false we do not need the whole search for previous decl. At a friend template we shall not find a definition, the loop would just find the last declaration (this value is not used). So I have the idea of this code (could not find the "suggest edit" command):