[PATCH] D69481: [Sema] Fixes templated friend member assertion

Mark de Wever via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Nov 5 12:48:03 PST 2019


This revision was automatically updated to reflect the committed changes.
Closed by commit rG743461090a20: [Sema] Fixes templated friend member assertion (authored by Mordante).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69481

Files:
  clang/lib/Sema/SemaTemplate.cpp
  clang/test/CXX/temp/temp.spec/temp.expl.spec/p20.cpp


Index: clang/test/CXX/temp/temp.spec/temp.expl.spec/p20.cpp
===================================================================
--- clang/test/CXX/temp/temp.spec/temp.expl.spec/p20.cpp
+++ clang/test/CXX/temp/temp.spec/temp.expl.spec/p20.cpp
@@ -3,7 +3,7 @@
 void f(T);
 
 template<typename T>
-struct A { };
+struct A { }; // expected-note{{template is declared here}}
 
 struct X {
   template<> friend void f<int>(int); // expected-error{{in a friend}}
@@ -12,3 +12,12 @@
   friend void f<float>(float); // okay
   friend class A<float>; // okay
 };
+
+struct PR41792 {
+  // expected-error at +1{{cannot declare an explicit specialization in a friend}}
+  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'}}
+  template <> friend class A<>;
+};
Index: clang/lib/Sema/SemaTemplate.cpp
===================================================================
--- clang/lib/Sema/SemaTemplate.cpp
+++ clang/lib/Sema/SemaTemplate.cpp
@@ -2549,6 +2549,9 @@
 /// list.
 static bool
 DependsOnTemplateParameters(QualType T, TemplateParameterList *Params) {
+  if (!Params->size())
+    return false;
+
   DependencyChecker Checker(Params, /*IgnoreNonTypeDependent*/false);
   Checker.TraverseType(T);
   return Checker.Match;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D69481.227950.patch
Type: text/x-patch
Size: 1357 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20191105/5a779444/attachment.bin>


More information about the cfe-commits mailing list