This is an archive of the discontinued LLVM Phabricator instance.

[Sema] Mark explicit specialization declaration in a friend invalid
ClosedPublic

Authored by ychen on Nov 5 2021, 12:22 AM.

Details

Summary

Down the path, if there is a implicit instantiation, this may trigger
the assertion "Member specialization must be an explicit specialization"
in clang::FunctionDecl::setFunctionTemplateSpecialization.

Diff Detail

Event Timeline

ychen requested review of this revision.Nov 5 2021, 12:22 AM
ychen created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptNov 5 2021, 12:22 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript

Hi @aaron.ballman, does this make sense to you? Thanks.

Thanks for the fix for this -- I think the changes look like they're correct, but the test coverage needs a bit of work.

clang/lib/Sema/SemaDecl.cpp
9205

Alternatively, we could set Invalid = true; here and let the code on 9207 do its thing. We do both in this function, and I believe either approach is equivalent for this specific code path.

clang/test/CXX/temp/temp.spec/temp.expl.spec/p20.cpp
16–28 ↗(On Diff #384976)

I don't think you should coop the existing test for an unrelated bug; can you add a new test to either SemaCXX or SemaTemplate?

ychen updated this revision to Diff 394351.Dec 14 2021, 12:28 PM
  • Address Aaron's comments.
ychen updated this revision to Diff 394352.Dec 14 2021, 12:28 PM
  • format
aaron.ballman accepted this revision.Dec 15 2021, 4:29 AM

LGTM! The failing precommit CI tests look to be unrelated to this patch.

This revision is now accepted and ready to land.Dec 15 2021, 4:29 AM

@aaron.ballman Thanks for the review!

This revision was landed with ongoing or failed builds.Dec 15 2021, 10:27 AM
This revision was automatically updated to reflect the committed changes.