diff options
author | Douglas Gregor <dgregor@apple.com> | 2009-10-13 14:39:41 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2009-10-13 14:39:41 +0000 |
commit | 3a88c1d784d818afbcec58af6b4a44678ae09d00 (patch) | |
tree | 880a7a14d0eadfcc0aae1732a03af6b555982111 /clang/test | |
parent | 87876a00537f7be696cc34f516da268bb8de4397 (diff) | |
download | bcm5719-llvm-3a88c1d784d818afbcec58af6b4a44678ae09d00.tar.gz bcm5719-llvm-3a88c1d784d818afbcec58af6b4a44678ae09d00.zip |
Improve the internal representation and semantic analysis of friend
function templates.
This commit ensures that friend function templates are constructed as
FunctionTemplateDecls rather than partial FunctionDecls (as they
previously were). It then implements template instantiation for friend
function templates, injecting the friend function template only when
no previous declaration exists at the time of instantiation.
Oh, and make sure that explicit specialization declarations are not
friends.
llvm-svn: 83970
Diffstat (limited to 'clang/test')
-rw-r--r-- | clang/test/CXX/temp/temp.spec/temp.expl.spec/p20.cpp | 14 | ||||
-rw-r--r-- | clang/test/SemaTemplate/friend-template.cpp | 18 |
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); |