diff options
Diffstat (limited to 'test/CXX/class.access')
-rw-r--r-- | test/CXX/class.access/class.friend/p1.cpp | 41 | ||||
-rw-r--r-- | test/CXX/class.access/class.friend/p11.cpp | 19 | ||||
-rw-r--r-- | test/CXX/class.access/p4.cpp | 62 | ||||
-rw-r--r-- | test/CXX/class.access/p6.cpp | 29 |
4 files changed, 146 insertions, 5 deletions
diff --git a/test/CXX/class.access/class.friend/p1.cpp b/test/CXX/class.access/class.friend/p1.cpp index 277b70b..1668155 100644 --- a/test/CXX/class.access/class.friend/p1.cpp +++ b/test/CXX/class.access/class.friend/p1.cpp @@ -258,13 +258,12 @@ namespace test7 { namespace test8 { class A { typedef int I; // expected-note 4 {{declared private here}} - static const I x = 0; + static const I x = 0; // expected-note {{implicitly declared private here}} friend I f(I i); template<typename T> friend I g(I i); }; - // FIXME: This should be on line 264. - const A::I A::x; // expected-note {{declared private here}} + const A::I A::x; A::I f(A::I i = A::x) {} template<typename T> A::I g(A::I i) { T t; @@ -306,3 +305,39 @@ namespace test10 { NS::bar->foo(); // expected-error {{private member}} } } + +// PR8705 +namespace test11 { + class A { + void test0(int); + void test1(int); + void test2(int); + void test3(int); + }; + + class B { + typedef int private_type; // expected-note 2 {{implicitly declared private here}} + friend void A::test0(int); + friend void A::test1(int); + }; + + void A::test0(B::private_type x) {} + void A::test1(int x = B::private_type()) {} + void A::test2(B::private_type x) {} // expected-error {{'private_type' is a private member of 'test11::B'}} + void A::test3(int x = B::private_type()) {} // expected-error {{'private_type' is a private member of 'test11::B'}} +} + + +// PR9221 +namespace test12 { + struct A { + void foo(); + }; + class B : private A { + friend void A::foo(); + void *mem; + }; + void A::foo() { + void *var = static_cast<B*>(this)->mem; + } +} diff --git a/test/CXX/class.access/class.friend/p11.cpp b/test/CXX/class.access/class.friend/p11.cpp new file mode 100644 index 0000000..a05b2d2 --- /dev/null +++ b/test/CXX/class.access/class.friend/p11.cpp @@ -0,0 +1,19 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +// rdar://problem/8540720 +namespace test0 { + void foo() { + void bar(); + class A { + friend void bar(); + }; + } +} + +namespace test1 { + void foo() { + class A { + friend void bar(); // expected-error {{no matching function found in local scope}} + }; + } +} diff --git a/test/CXX/class.access/p4.cpp b/test/CXX/class.access/p4.cpp index 115a22a..84b7b19 100644 --- a/test/CXX/class.access/p4.cpp +++ b/test/CXX/class.access/p4.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s +// RUN: %clang_cc1 -fexceptions -fsyntax-only -verify %s // C++0x [class.access]p4: @@ -201,7 +201,7 @@ namespace test4 { // Implicit copy assignment operator uses. namespace test5 { class A { - void operator=(const A &); // expected-note 2 {{declared private here}} + void operator=(const A &); // expected-note 2 {{implicitly declared private here}} }; class Test1 { A a; }; // expected-error {{private member}} @@ -450,3 +450,61 @@ namespace test18 { A<int> member; }; } + +// PR8325 +namespace test19 { + class A { ~A(); }; + // The destructor is not implicitly referenced here. Contrast to test16, + // testing PR7281, earlier in this file. + void b(A* x) { throw x; } +} + +// PR7930 +namespace test20 { + class Foo { + Foo(); // expected-note {{implicitly declared private here}} + }; + Foo::Foo() {} + + void test() { + Foo a; // expected-error {{calling a private constructor}} + } +} + +namespace test21 { + template <class T> class A { + void foo(); + void bar(); + class Inner; // expected-note {{implicitly declared private here}} + public: + void baz(); + }; + template <class T> class A<T>::Inner {}; + class B { + template <class T> class A<T>::Inner; + }; + + void test() { + A<int>::Inner i; // expected-error {{'Inner' is a private member}} + } +} + +namespace rdar8876150 { + struct A { operator bool(); }; + struct B : private A { using A::operator bool; }; + + bool f() { + B b; + return !b; + } +} + +namespace test23 { + template <typename T> class A { + A(); + static A instance; + }; + + template <typename T> A<T> A<T>::instance; + template class A<int>; +} diff --git a/test/CXX/class.access/p6.cpp b/test/CXX/class.access/p6.cpp index 8795708..fe3304a 100644 --- a/test/CXX/class.access/p6.cpp +++ b/test/CXX/class.access/p6.cpp @@ -139,3 +139,32 @@ namespace test5 { template <A::Enum en> class bar {}; // expected-error {{'Enum' is a private member of 'test5::A'}} }; } + +namespace test6 { + class A { + public: class public_inner {}; + protected: class protected_inner {}; + private: class private_inner {}; // expected-note {{declared private here}} + }; + + class B : A { + public_inner a; + protected_inner b; + private_inner c; // expected-error {{ 'private_inner' is a private member of 'test6::A'}} + }; +} + +// PR9229 +namespace test7 { + void foo(int arg[1]); + class A { + void check(); + }; + class B { + friend class A; + A ins; + }; + void A::check() { + void foo(int arg[__builtin_offsetof(B, ins)]); + } +} |