summaryrefslogtreecommitdiffstats
path: root/clang/test
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2009-09-26 06:47:28 +0000
committerDouglas Gregor <dgregor@apple.com>2009-09-26 06:47:28 +0000
commit3dad842b356adf3435b3ec4af518b4bd4a7b5cd9 (patch)
tree18c8a7accd3d883a972b03ac50863e55439258c9 /clang/test
parentccde96e96baff2447a260d5b00f4bb4c2385265b (diff)
downloadbcm5719-llvm-3dad842b356adf3435b3ec4af518b4bd4a7b5cd9.tar.gz
bcm5719-llvm-3dad842b356adf3435b3ec4af518b4bd4a7b5cd9.zip
Rework the Parse-Sema interaction for friends to better support friend
class templates. We now treat friend class templates much more like normal class templates, except that they still get special name lookup rules. Fixes PR5057 and eliminates a bunch of spurious diagnostics in <iostream>. llvm-svn: 82848
Diffstat (limited to 'clang/test')
-rw-r--r--clang/test/CXX/class/class.friend/p2.cpp4
-rw-r--r--clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.elab/p3.cpp3
-rw-r--r--clang/test/CXX/temp/temp.decls/temp.friend/p3.cpp4
-rw-r--r--clang/test/Parser/cxx-friend.cpp4
-rw-r--r--clang/test/SemaTemplate/friend-template.cpp17
5 files changed, 27 insertions, 5 deletions
diff --git a/clang/test/CXX/class/class.friend/p2.cpp b/clang/test/CXX/class/class.friend/p2.cpp
index f130beb7d2c..98be2049e75 100644
--- a/clang/test/CXX/class/class.friend/p2.cpp
+++ b/clang/test/CXX/class/class.friend/p2.cpp
@@ -1,8 +1,10 @@
// RUN: clang-cc -fsyntax-only -verify %s
+struct B0;
+
class A {
friend class B {}; // expected-error {{cannot define a type in a friend declaration}}
friend int; // expected-error {{friends can only be classes or functions}}
- friend B; // expected-error {{must specify 'class' in a friend class declaration}}
+ friend B0; // expected-error {{must specify 'struct' to befriend}}
friend class C; // okay
};
diff --git a/clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.elab/p3.cpp b/clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.elab/p3.cpp
index 89f938d1f7d..657cf20cf31 100644
--- a/clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.elab/p3.cpp
+++ b/clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.elab/p3.cpp
@@ -13,7 +13,8 @@ class A1 {
friend union A; // expected-error {{use of 'A' with tag type that does not match previous declaration}}
// FIXME: a better error would be something like 'enum types cannot be friends'
- friend enum A; // expected-error {{ISO C++ forbids forward references to 'enum' types}}
+ friend enum A; // expected-error {{ISO C++ forbids forward references to 'enum' types}} \
+ // expected-error{{classes or functions}}
};
template <class T> struct B { // expected-note {{previous use is here}}
diff --git a/clang/test/CXX/temp/temp.decls/temp.friend/p3.cpp b/clang/test/CXX/temp/temp.decls/temp.friend/p3.cpp
index dd856e9cc3b..4615bebe711 100644
--- a/clang/test/CXX/temp/temp.decls/temp.friend/p3.cpp
+++ b/clang/test/CXX/temp/temp.decls/temp.friend/p3.cpp
@@ -7,5 +7,7 @@ template <class T> class A {
class B {
template <class T> friend class A;
template <class T> friend class Undeclared;
- template <class T> friend typename A<T>::Member; // expected-error {{friend type templates must use an elaborated type}}
+
+ // FIXME: Diagnostic below could be (and was) better.
+ template <class T> friend typename A<T>::Member; // expected-error {{classes or functions}}
};
diff --git a/clang/test/Parser/cxx-friend.cpp b/clang/test/Parser/cxx-friend.cpp
index 397894727b7..14b31af761d 100644
--- a/clang/test/Parser/cxx-friend.cpp
+++ b/clang/test/Parser/cxx-friend.cpp
@@ -21,8 +21,8 @@ class B {
// 'A' here should refer to the declaration above.
friend class A;
- friend C; // expected-error {{must specify 'class' in a friend class declaration}}
- friend U; // expected-error {{must specify 'union' in a friend union declaration}}
+ friend C; // expected-error {{must specify 'class' to befriend}}
+ friend U; // expected-error {{must specify 'union' to befriend}}
friend int; // expected-error {{friends can only be classes or functions}}
friend void myfunc();
diff --git a/clang/test/SemaTemplate/friend-template.cpp b/clang/test/SemaTemplate/friend-template.cpp
new file mode 100644
index 00000000000..6268cd89073
--- /dev/null
+++ b/clang/test/SemaTemplate/friend-template.cpp
@@ -0,0 +1,17 @@
+// RUN: clang-cc -fsyntax-only %s
+
+// PR5057
+namespace std {
+ class X {
+ public:
+ template<typename T>
+ friend struct Y;
+ };
+}
+
+namespace std {
+ template<typename T>
+ struct Y
+ {
+ };
+}
OpenPOWER on IntegriCloud