[PATCH] D113245: [Sema] Mark explicit specialization declaration in a friend invalid

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Dec 14 11:49:14 PST 2021


aaron.ballman added a comment.

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



================
Comment at: clang/lib/Sema/SemaDecl.cpp:9191
             << FixItHint::CreateInsertion(InsertLoc, "<>");
+          NewFD->setInvalidDecl();
         }
----------------
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.


================
Comment at: clang/test/CXX/temp/temp.spec/temp.expl.spec/p20.cpp:16-28
+template<typename T>
 struct PR41792 {
   // expected-error at +1{{cannot declare an explicit specialization in a friend}}
-  template <> friend void f<>(int);
+  template <> friend void f<>(int) {}
 
   // expected-error at +2{{template specialization declaration cannot be a friend}}
   // expected-error at +1{{too few template arguments for class template 'A'}}
----------------
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?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D113245/new/

https://reviews.llvm.org/D113245



More information about the cfe-commits mailing list