summaryrefslogtreecommitdiffstats
path: root/clang/test
diff options
context:
space:
mode:
Diffstat (limited to 'clang/test')
-rw-r--r--clang/test/CXX/temp/temp.spec/temp.expl.spec/p20.cpp14
-rw-r--r--clang/test/SemaTemplate/friend-template.cpp18
2 files changed, 32 insertions, 0 deletions
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
new file mode 100644
index 00000000000..d270b8167a1
--- /dev/null
+++ b/clang/test/CXX/temp/temp.spec/temp.expl.spec/p20.cpp
@@ -0,0 +1,14 @@
+// RUN: clang-cc -fsyntax-only -verify %s
+template<typename T>
+void f(T);
+
+template<typename T>
+struct A { };
+
+struct X {
+ template<> friend void f<int>(int); // expected-error{{in class scope}}
+ template<> friend class A<int>; // expected-error{{cannot be a friend}}
+
+ friend void f<float>(float); // okay
+ friend class A<float>; // okay
+};
diff --git a/clang/test/SemaTemplate/friend-template.cpp b/clang/test/SemaTemplate/friend-template.cpp
index 9a483aeb5b1..761c13076d2 100644
--- a/clang/test/SemaTemplate/friend-template.cpp
+++ b/clang/test/SemaTemplate/friend-template.cpp
@@ -44,3 +44,21 @@ template<>
struct X0<int> {
template<typename U> friend struct X0;
};
+
+template<typename T>
+struct X1 {
+ template<typename U> friend void f2(U);
+ template<typename U> friend void f3(U);
+};
+
+template<typename U> void f2(U);
+
+X1<int> x1i;
+
+template<> void f2(int);
+
+// FIXME: Should this declaration of f3 be required for the specialization of
+// f3<int> (further below) to work? GCC and EDG don't require it, we do...
+template<typename U> void f3(U);
+
+template<> void f3(int);
OpenPOWER on IntegriCloud