summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark de Wever <koraq@xs4all.nl>2019-11-05 20:39:55 +0100
committerMark de Wever <koraq@xs4all.nl>2019-11-05 21:46:42 +0100
commit743461090a2027058cd438ed643ed5ed939cf1ca (patch)
treec59b3fd1a1469a4ef3206fb2d967554465e77e55
parent3ac6863efbbfa27175588670e3b3715b0351ff4e (diff)
downloadbcm5719-llvm-743461090a2027058cd438ed643ed5ed939cf1ca.tar.gz
bcm5719-llvm-743461090a2027058cd438ed643ed5ed939cf1ca.zip
[Sema] Fixes templated friend member assertion
Fixes PR41792: Clang assertion failure on templated friend member function Differential Revision: https://reviews.llvm.org/D69481
-rw-r--r--clang/lib/Sema/SemaTemplate.cpp3
-rw-r--r--clang/test/CXX/temp/temp.spec/temp.expl.spec/p20.cpp11
2 files changed, 13 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp
index 3f2d38630c3..a85fb6c1dc8 100644
--- a/clang/lib/Sema/SemaTemplate.cpp
+++ b/clang/lib/Sema/SemaTemplate.cpp
@@ -2549,6 +2549,9 @@ struct DependencyChecker : RecursiveASTVisitor<DependencyChecker> {
/// list.
static bool
DependsOnTemplateParameters(QualType T, TemplateParameterList *Params) {
+ if (!Params->size())
+ return false;
+
DependencyChecker Checker(Params, /*IgnoreNonTypeDependent*/false);
Checker.TraverseType(T);
return Checker.Match;
diff --git a/clang/test/CXX/temp/temp.spec/temp.expl.spec/p20.cpp b/clang/test/CXX/temp/temp.spec/temp.expl.spec/p20.cpp
index 86cdcf80cbe..0283dba63b1 100644
--- a/clang/test/CXX/temp/temp.spec/temp.expl.spec/p20.cpp
+++ b/clang/test/CXX/temp/temp.spec/temp.expl.spec/p20.cpp
@@ -3,7 +3,7 @@ template<typename T>
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 @@ struct X {
friend void f<float>(float); // okay
friend class A<float>; // okay
};
+
+struct PR41792 {
+ // expected-error@+1{{cannot declare an explicit specialization in a friend}}
+ template <> friend void f<>(int);
+
+ // expected-error@+2{{template specialization declaration cannot be a friend}}
+ // expected-error@+1{{too few template arguments for class template 'A'}}
+ template <> friend class A<>;
+};
OpenPOWER on IntegriCloud