summaryrefslogtreecommitdiff
path: root/test/CXX/class.access
diff options
context:
space:
mode:
Diffstat (limited to 'test/CXX/class.access')
-rw-r--r--test/CXX/class.access/class.friend/p1.cpp24
-rw-r--r--test/CXX/class.access/class.friend/p3-cxx0x.cpp26
-rw-r--r--test/CXX/class.access/class.protected/p1-cxx11.cpp1
-rw-r--r--test/CXX/class.access/class.protected/p1.cpp2
4 files changed, 48 insertions, 5 deletions
diff --git a/test/CXX/class.access/class.friend/p1.cpp b/test/CXX/class.access/class.friend/p1.cpp
index 7cb192b5a1f3f..19d94cfdd5f6f 100644
--- a/test/CXX/class.access/class.friend/p1.cpp
+++ b/test/CXX/class.access/class.friend/p1.cpp
@@ -20,7 +20,7 @@ void test1() {
g()->f();
S::f();
X::g(); // expected-error{{no member named 'g' in 'X'}}
- X::S x_s; // expected-error{{no member named 'S' in 'X'}}
+ X::S x_s; // expected-error{{no type named 'S' in 'X'}}
X x;
x.g(); // expected-error{{no member named 'g' in 'X'}}
}
@@ -44,16 +44,16 @@ namespace N {
S s;
S::f();
X::g(); // expected-error{{no member named 'g' in 'N::X'}}
- X::S x_s; // expected-error{{no member named 'S' in 'N::X'}}
+ X::S x_s; // expected-error{{no type named 'S' in 'N::X'}}
X x;
x.g(); // expected-error{{no member named 'g' in 'N::X'}}
g2();
S2 s2;
::g2(); // expected-error{{no member named 'g2' in the global namespace}}
- ::S2 g_s2; // expected-error{{no member named 'S2' in the global namespace}}
+ ::S2 g_s2; // expected-error{{no type named 'S2' in the global namespace}}
X::g2(); // expected-error{{no member named 'g2' in 'N::X'}}
- X::S2 x_s2; // expected-error{{no member named 'S2' in 'N::X'}}
+ X::S2 x_s2; // expected-error{{no type named 'S2' in 'N::X'}}
x.g2(); // expected-error{{no member named 'g2' in 'N::X'}}
}
}
@@ -356,3 +356,19 @@ namespace PR9103 {
}
};
}
+
+// PR13642. When computing the effective context, we were walking up
+// the DC chain for the canonical decl, which is unfortunate if that's
+// (e.g.) a friend declaration.
+namespace test14 {
+ class A {
+ class B { // expected-note {{implicitly declared private here}}
+ static int i;
+ friend void c();
+ };
+ };
+
+ void c() {
+ A::B::i = 5; // expected-error {{'B' is a private member of 'test14::A'}}
+ }
+}
diff --git a/test/CXX/class.access/class.friend/p3-cxx0x.cpp b/test/CXX/class.access/class.friend/p3-cxx0x.cpp
index 00fc0a33bef28..e4d5fd55b0b64 100644
--- a/test/CXX/class.access/class.friend/p3-cxx0x.cpp
+++ b/test/CXX/class.access/class.friend/p3-cxx0x.cpp
@@ -27,3 +27,29 @@ struct Y3 {
X1<Y2> x1a;
X1<Y3> x1b;
X1<Y1> x1c; // expected-note{{in instantiation of template class 'X1<Y1>' requested here}}
+
+template<typename T>
+class A {
+ T x;
+public:
+ class foo {};
+ static int y;
+};
+
+struct {
+ // Ill-formed
+ int friend; // expected-error {{'friend' must appear first in a non-function declaration}}
+ unsigned friend int; // expected-error {{'friend' must appear first in a non-function declaration}}
+ const volatile friend int; // expected-error {{'friend' must appear first in a non-function declaration}}
+ int
+ friend; // expected-error {{'friend' must appear first in a non-function declaration}}
+
+ // OK
+ int friend foo(void);
+ friend int;
+ friend const volatile int;
+ friend
+
+ float;
+ template<typename T> friend class A<T>::foo;
+} a;
diff --git a/test/CXX/class.access/class.protected/p1-cxx11.cpp b/test/CXX/class.access/class.protected/p1-cxx11.cpp
index dc9b20d17c0e3..c1cf047aadb46 100644
--- a/test/CXX/class.access/class.protected/p1-cxx11.cpp
+++ b/test/CXX/class.access/class.protected/p1-cxx11.cpp
@@ -1,4 +1,5 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
+// expected-no-diagnostics
// PR12497
namespace test0 {
diff --git a/test/CXX/class.access/class.protected/p1.cpp b/test/CXX/class.access/class.protected/p1.cpp
index c9491e1196f9a..132ff6176c01b 100644
--- a/test/CXX/class.access/class.protected/p1.cpp
+++ b/test/CXX/class.access/class.protected/p1.cpp
@@ -423,7 +423,7 @@ namespace test12 {
// This friendship is not considered because a public member of A is
// inaccessible in C.
namespace test13 {
- class A { protected: int foo(); }; // expected-note {{can only access this member on an object of type}}
+ class A { protected: int foo(); }; // expected-note {{declared protected here}}
class B : private virtual A {};
class C : private B { friend void test(); };
class D : public virtual A {};