diff options
author | rdivacky <rdivacky@FreeBSD.org> | 2010-05-04 16:12:48 +0000 |
---|---|---|
committer | rdivacky <rdivacky@FreeBSD.org> | 2010-05-04 16:12:48 +0000 |
commit | 8aaf5818a64e9f7687798852af5945b053c68a54 (patch) | |
tree | d6a70c3518b8dea8be7062438d7e8676820ed17f /test/CXX | |
parent | 71438373cd57f0d5d8c93bb5cf690844a0fbc9d0 (diff) | |
download | FreeBSD-src-8aaf5818a64e9f7687798852af5945b053c68a54.zip FreeBSD-src-8aaf5818a64e9f7687798852af5945b053c68a54.tar.gz |
Update clang to r103004.
Diffstat (limited to 'test/CXX')
45 files changed, 1170 insertions, 67 deletions
diff --git a/test/CXX/basic/basic.lookup/basic.lookup.argdep/p2.cpp b/test/CXX/basic/basic.lookup/basic.lookup.argdep/p2.cpp index ee01416..0e262f3 100644 --- a/test/CXX/basic/basic.lookup/basic.lookup.argdep/p2.cpp +++ b/test/CXX/basic/basic.lookup/basic.lookup.argdep/p2.cpp @@ -71,3 +71,18 @@ namespace O { } } +extern "C" { + struct L { }; +} + +void h(L); // expected-note{{candidate function}} + +namespace P { + void h(L); // expected-note{{candidate function}} + void test_transparent_context_adl(L l) { + { + h(l); // expected-error {{call to 'h' is ambiguous}} + } + } +} + diff --git a/test/CXX/basic/basic.lookup/basic.lookup.elab/p2.cpp b/test/CXX/basic/basic.lookup/basic.lookup.elab/p2.cpp new file mode 100644 index 0000000..004d1e4 --- /dev/null +++ b/test/CXX/basic/basic.lookup/basic.lookup.elab/p2.cpp @@ -0,0 +1,60 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +namespace test0 { + struct A { + static int foo; + }; + + namespace i0 { + typedef int A; // expected-note {{declared here}} + + int test() { + struct A a; // expected-error {{elaborated type refers to a typedef}} + return a.foo; + } + } + + namespace i1 { + template <class> class A; // expected-note {{declared here}} + + int test() { + struct A a; // expected-error {{elaborated type refers to a template}} + return a.foo; + } + } + + namespace i2 { + int A; + + int test() { + struct A a; + return a.foo; + } + } + + namespace i3 { + void A(); + + int test() { + struct A a; + return a.foo; + } + } + + namespace i4 { + template <class T> void A(); + + int test() { + struct A a; + return a.foo; + } + } + + // This should magically be okay; see comment in SemaDecl.cpp. + // rdar://problem/7898108 + typedef struct A A; + int test() { + struct A a; + return a.foo; + } +} diff --git a/test/CXX/basic/basic.lookup/basic.lookup.qual/namespace.qual/p2.cpp b/test/CXX/basic/basic.lookup/basic.lookup.qual/namespace.qual/p2.cpp index f9bac40..3039396 100644 --- a/test/CXX/basic/basic.lookup/basic.lookup.qual/namespace.qual/p2.cpp +++ b/test/CXX/basic/basic.lookup/basic.lookup.qual/namespace.qual/p2.cpp @@ -36,7 +36,7 @@ namespace Numbers { double d; }; Number zero(0.0f); - void g(Number); + void g(Number); // expected-note 2{{passing argument to parameter here}} } void test2() { diff --git a/test/CXX/basic/basic.lookup/basic.lookup.unqual/p7.cpp b/test/CXX/basic/basic.lookup/basic.lookup.unqual/p7.cpp index e579546..d2afd5d 100644 --- a/test/CXX/basic/basic.lookup/basic.lookup.unqual/p7.cpp +++ b/test/CXX/basic/basic.lookup/basic.lookup.unqual/p7.cpp @@ -32,6 +32,6 @@ namespace test1 { // Test that we don't find the injected class name when parsing base // specifiers. namespace test2 { - template <class T> struct bar {}; // expected-note {{template parameter is declared here}} - template <class T> struct foo : bar<foo> {}; // expected-error {{template argument for template type parameter must be a type}} + template <class T> struct bar {}; + template <class T> struct foo : bar<foo> {}; // expected-error {{use of class template foo requires template arguments}} expected-note {{template is declared here}} } diff --git a/test/CXX/class.access/class.access.base/p1.cpp b/test/CXX/class.access/class.access.base/p1.cpp index 1bbcedb..0988431 100644 --- a/test/CXX/class.access/class.access.base/p1.cpp +++ b/test/CXX/class.access/class.access.base/p1.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fsyntax-only -faccess-control -verify %s +// RUN: %clang_cc1 -fsyntax-only -verify %s // C++0x [class.access.base]p1(a): // If a class is declared to be a base class for another class using diff --git a/test/CXX/class.access/class.access.base/p5.cpp b/test/CXX/class.access/class.access.base/p5.cpp index 96037e7..938d9fb 100644 --- a/test/CXX/class.access/class.access.base/p5.cpp +++ b/test/CXX/class.access/class.access.base/p5.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -faccess-control -verify %s +// RUN: %clang_cc1 -verify %s namespace test0 { struct A { diff --git a/test/CXX/class.access/class.access.nest/p1.cpp b/test/CXX/class.access/class.access.nest/p1.cpp index d2644c6..eceffcf 100644 --- a/test/CXX/class.access/class.access.nest/p1.cpp +++ b/test/CXX/class.access/class.access.nest/p1.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fsyntax-only -faccess-control -verify %s +// RUN: %clang_cc1 -fsyntax-only -verify %s // Derived from GNU's std::string namespace test0 { diff --git a/test/CXX/class.access/class.friend/p1.cpp b/test/CXX/class.access/class.friend/p1.cpp index 22266cd..991698d 100644 --- a/test/CXX/class.access/class.friend/p1.cpp +++ b/test/CXX/class.access/class.friend/p1.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fsyntax-only -faccess-control -verify %s +// RUN: %clang_cc1 -fsyntax-only -verify %s // C++'0x [class.friend] p1: // A friend of a class is a function or class that is given permission to use @@ -192,3 +192,98 @@ namespace test4 { return a == b; // expected-note {{requested here}} } } + + +// PR6174 +namespace test5 { + namespace ns { + class A; + } + + class ns::A { + private: int x; + friend class B; + }; + + namespace ns { + class B { + int test(A *p) { return p->x; } + }; + } +} + +// PR6207 +namespace test6 { + struct A {}; + + struct B { + friend A::A(); + friend A::~A(); + friend A &A::operator=(const A&); + }; +} + +namespace test7 { + template <class T> struct X { + X(); + ~X(); + void foo(); + void bar(); + }; + + class A { + friend void X<int>::foo(); + friend X<int>::X(); + friend X<int>::X(const X&); + + private: + A(); // expected-note 2 {{declared private here}} + }; + + template<> void X<int>::foo() { + A a; + } + + template<> void X<int>::bar() { + A a; // expected-error {{calling a private constructor}} + } + + template<> X<int>::X() { + A a; + } + + template<> X<int>::~X() { + A a; // expected-error {{calling a private constructor}} + } +} + +// Return types, parameters and default arguments to friend functions. +namespace test8 { + class A { + typedef int I; // expected-note 4 {{declared private here}} + static const I x = 0; + 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}} + A::I f(A::I i = A::x) {} + template<typename T> A::I g(A::I i) { + T t; + } + template A::I g<A::I>(A::I i); + + A::I f2(A::I i = A::x) {} // expected-error 3 {{is a private member of}} + template<typename T> A::I g2(A::I i) { // expected-error 2 {{is a private member of}} + T t; + } + template A::I g2<A::I>(A::I i); +} + +// PR6885 +namespace test9 { + class B { + friend class test9; + }; +} diff --git a/test/CXX/class.access/class.friend/p2-cxx03.cpp b/test/CXX/class.access/class.friend/p2-cxx03.cpp new file mode 100644 index 0000000..0391c4b --- /dev/null +++ b/test/CXX/class.access/class.friend/p2-cxx03.cpp @@ -0,0 +1,13 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s +template<typename T> +class X0 { + friend T; // expected-warning{{non-class type 'T' cannot be a friend}} +}; + +class X1 { }; +enum E1 { }; +X0<X1> x0a; +X0<X1 *> x0b; +X0<int> x0c; +X0<E1> x0d; + diff --git a/test/CXX/class.access/class.friend/p3-cxx0x.cpp b/test/CXX/class.access/class.friend/p3-cxx0x.cpp new file mode 100644 index 0000000..4f55e53 --- /dev/null +++ b/test/CXX/class.access/class.friend/p3-cxx0x.cpp @@ -0,0 +1,29 @@ +// RUN: %clang_cc1 -fsyntax-only -std=c++0x -verify %s +template<typename T> +class X0 { + friend T; +}; + +class Y1 { }; +enum E1 { }; +X0<Y1> x0a; +X0<Y1 *> x0b; +X0<int> x0c; +X0<E1> x0d; + +template<typename T> +class X1 { + friend typename T::type; // expected-error{{no type named 'type' in 'Y1'}} +}; + +struct Y2 { + struct type { }; +}; + +struct Y3 { + typedef int type; +}; + +X1<Y2> x1a; +X1<Y3> x1b; +X1<Y1> x1c; // expected-note{{in instantiation of template class 'X1<Y1>' requested here}} diff --git a/test/CXX/class.access/class.protected/p1.cpp b/test/CXX/class.access/class.protected/p1.cpp new file mode 100644 index 0000000..6ff630c --- /dev/null +++ b/test/CXX/class.access/class.protected/p1.cpp @@ -0,0 +1,387 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +namespace test0 { + class A { + protected: int x; // expected-note 3 {{declared}} + static int sx; // expected-note 3 {{declared}} + }; + class B : public A { + }; + class C : protected A { // expected-note {{declared}} + }; + class D : private B { // expected-note 3 {{constrained}} + }; + + void test(A &a) { + (void) a.x; // expected-error {{'x' is a protected member}} + (void) a.sx; // expected-error {{'sx' is a protected member}} + } + void test(B &b) { + (void) b.x; // expected-error {{'x' is a protected member}} + (void) b.sx; // expected-error {{'sx' is a protected member}} + } + void test(C &c) { + (void) c.x; // expected-error {{'x' is a protected member}} expected-error {{protected base class}} + (void) c.sx; // expected-error {{'sx' is a protected member}} + } + void test(D &d) { + (void) d.x; // expected-error {{'x' is a private member}} expected-error {{private base class}} + (void) d.sx; // expected-error {{'sx' is a private member}} + } +} + +namespace test1 { + class A { + protected: int x; + static int sx; + static void test(A&); + }; + class B : public A { + static void test(B&); + }; + class C : protected A { + static void test(C&); + }; + class D : private B { + static void test(D&); + }; + + void A::test(A &a) { + (void) a.x; + (void) a.sx; + } + void B::test(B &b) { + (void) b.x; + (void) b.sx; + } + void C::test(C &c) { + (void) c.x; + (void) c.sx; + } + void D::test(D &d) { + (void) d.x; + (void) d.sx; + } +} + +namespace test2 { + class A { + protected: int x; // expected-note 3 {{declared}} + static int sx; + static void test(A&); + }; + class B : public A { + static void test(A&); + }; + class C : protected A { + static void test(A&); + }; + class D : private B { + static void test(A&); + }; + + void A::test(A &a) { + (void) a.x; + (void) a.sx; + } + void B::test(A &a) { + (void) a.x; // expected-error {{'x' is a protected member}} + (void) a.sx; + } + void C::test(A &a) { + (void) a.x; // expected-error {{'x' is a protected member}} + (void) a.sx; + } + void D::test(A &a) { + (void) a.x; // expected-error {{'x' is a protected member}} + (void) a.sx; + } +} + +namespace test3 { + class B; + class A { + protected: int x; // expected-note {{declared}} + static int sx; + static void test(B&); + }; + class B : public A { + static void test(B&); + }; + class C : protected A { + static void test(B&); + }; + class D : private B { + static void test(B&); + }; + + void A::test(B &b) { + (void) b.x; + (void) b.sx; + } + void B::test(B &b) { + (void) b.x; + (void) b.sx; + } + void C::test(B &b) { + (void) b.x; // expected-error {{'x' is a protected member}} + (void) b.sx; + } + void D::test(B &b) { + (void) b.x; + (void) b.sx; + } +} + +namespace test4 { + class C; + class A { + protected: int x; // expected-note 2 {{declared}} + static int sx; + static void test(C&); + }; + class B : public A { + static void test(C&); + }; + class C : protected A { // expected-note 4 {{constrained}} expected-note 3 {{declared}} + static void test(C&); + }; + class D : private B { + static void test(C&); + }; + + void A::test(C &c) { + (void) c.x; // expected-error {{'x' is a protected member}} \ + // expected-error {{protected base class}} + (void) c.sx; // expected-error {{'sx' is a protected member}} + } + void B::test(C &c) { + (void) c.x; // expected-error {{'x' is a protected member}} \ + // expected-error {{protected base class}} + (void) c.sx; // expected-error {{'sx' is a protected member}} + } + void C::test(C &c) { + (void) c.x; + (void) c.sx; + } + void D::test(C &c) { + (void) c.x; // expected-error {{'x' is a protected member}} \ + // expected-error {{protected base class}} + (void) c.sx; // expected-error {{'sx' is a protected member}} + } +} + +namespace test5 { + class D; + class A { + protected: int x; + static int sx; + static void test(D&); + }; + class B : public A { + static void test(D&); + }; + class C : protected A { + static void test(D&); + }; + class D : private B { // expected-note 9 {{constrained}} + static void test(D&); + }; + + void A::test(D &d) { + (void) d.x; // expected-error {{'x' is a private member}} \ + // expected-error {{cannot cast}} + (void) d.sx; // expected-error {{'sx' is a private member}} + } + void B::test(D &d) { + (void) d.x; // expected-error {{'x' is a private member}} \ + // expected-error {{cannot cast}} + (void) d.sx; // expected-error {{'sx' is a private member}} + } + void C::test(D &d) { + (void) d.x; // expected-error {{'x' is a private member}} \ + // expected-error {{cannot cast}} + (void) d.sx; // expected-error {{'sx' is a private member}} + } + void D::test(D &d) { + (void) d.x; + (void) d.sx; + } +} + +namespace test6 { + class Static {}; + class A { + protected: + void foo(int); // expected-note 3 {{declared}} + void foo(long); + static void foo(Static); + + static void test(A&); + }; + class B : public A { + static void test(A&); + }; + class C : protected A { + static void test(A&); + }; + class D : private B { + static void test(A&); + }; + + void A::test(A &a) { + a.foo(10); + a.foo(Static()); + } + void B::test(A &a) { + a.foo(10); // expected-error {{'foo' is a protected member}} + a.foo(Static()); + } + void C::test(A &a) { + a.foo(10); // expected-error {{'foo' is a protected member}} + a.foo(Static()); + } + void D::test(A &a) { + a.foo(10); // expected-error {{'foo' is a protected member}} + a.foo(Static()); + } +} + +namespace test7 { + class Static {}; + class A { + protected: + void foo(int); // expected-note 3 {{declared}} + void foo(long); + static void foo(Static); + + static void test(); + }; + class B : public A { + static void test(); + }; + class C : protected A { + static void test(); + }; + class D : private B { + static void test(); + }; + + void A::test() { + void (A::*x)(int) = &A::foo; + void (*sx)(Static) = &A::foo; + } + void B::test() { + void (A::*x)(int) = &A::foo; // expected-error {{'foo' is a protected member}} + void (*sx)(Static) = &A::foo; + } + void C::test() { + void (A::*x)(int) = &A::foo; // expected-error {{'foo' is a protected member}} + void (*sx)(Static) = &A::foo; + } + void D::test() { + void (A::*x)(int) = &A::foo; // expected-error {{'foo' is a protected member}} + void (*sx)(Static) = &A::foo; + } +} + +namespace test8 { + class Static {}; + class A { + protected: + void foo(int); // expected-note 3 {{declared}} + void foo(long); + static void foo(Static); + + static void test(); + }; + class B : public A { + static void test(); + }; + class C : protected A { + static void test(); + }; + class D : private B { + static void test(); + }; + void call(void (A::*)(int)); + void calls(void (*)(Static)); + + void A::test() { + call(&A::foo); + calls(&A::foo); + } + void B::test() { + call(&A::foo); // expected-error {{'foo' is a protected member}} + calls(&A::foo); + } + void C::test() { + call(&A::foo); // expected-error {{'foo' is a protected member}} + calls(&A::foo); + } + void D::test() { + call(&A::foo); // expected-error {{'foo' is a protected member}} + calls(&A::foo); + } +} + +namespace test9 { + class A { + protected: int foo(); // expected-note 8 {{declared}} + }; + + class B : public A { + friend class D; + }; + + class C : protected B { // expected-note {{declared}} \ + // expected-note 6 {{constrained}} + }; + + class D : public A { + static void test(A &a) { + a.foo(); // expected-error {{'foo' is a protected member}} + a.A::foo(); // expected-error {{'foo' is a protected member}} + a.B::foo(); + a.C::foo(); // expected-error {{'foo' is a protected member}} + } + + static void test(B &b) { + b.foo(); + b.A::foo(); // expected-error {{'foo' is a protected member}} + b.B::foo(); + b.C::foo(); // expected-error {{'foo' is a protected member}} + } + + static void test(C &c) { + c.foo(); // expected-error {{'foo' is a protected member}} \ + // expected-error {{cannot cast}} + c.A::foo(); // expected-error {{'foo' is a protected member}} \ + // expected-error {{'A' is a protected member}} \ + // expected-error {{cannot cast}} + c.B::foo(); // expected-error {{'B' is a protected member}} \ + // expected-error {{cannot cast}} + c.C::foo(); // expected-error {{'foo' is a protected member}} \ + // expected-error {{cannot cast}} + } + + static void test(D &d) { + d.foo(); + d.A::foo(); + d.B::foo(); + d.C::foo(); // expected-error {{'foo' is a protected member}} + } + }; +} + +namespace test10 { + template<typename T> class A { + protected: + int foo(); + int foo() const; + + ~A() { foo(); } + }; + + template class A<int>; +} diff --git a/test/CXX/class.access/p4.cpp b/test/CXX/class.access/p4.cpp index 3bbdbab8..1cd8966 100644 --- a/test/CXX/class.access/p4.cpp +++ b/test/CXX/class.access/p4.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fsyntax-only -faccess-control -verify %s +// RUN: %clang_cc1 -fsyntax-only -verify %s // C++0x [class.access]p4: @@ -88,13 +88,24 @@ namespace test1 { namespace test2 { class A { private: - A(); // expected-note {{declared private here}} + A(); // expected-note 3 {{declared private here}} static A foo; }; A a; // expected-error {{calling a private constructor}} A A::foo; // okay + + class B : A { }; // expected-error {{base class 'test2::A' has private constructor}} + B b; + + class C : virtual A { + public: + C(); + }; + + class D : C { }; // expected-error {{inherited virtual base class 'test2::A' has private constructor}} + D d; } // Implicit destructor calls. @@ -191,13 +202,13 @@ namespace test5 { void operator=(const A &); // expected-note 2 {{declared private here}} }; - class Test1 { A a; }; // expected-error {{field of type 'test5::A' has private copy assignment operator}} + class Test1 { A a; }; // expected-error {{private member}} void test1() { Test1 a; a = Test1(); } - class Test2 : A {}; // expected-error {{base class 'test5::A' has private copy assignment operator}} + class Test2 : A {}; // expected-error {{private member}} void test2() { Test2 a; a = Test2(); @@ -327,3 +338,83 @@ namespace test13 { (void) d->x; } } + +// Destructors for temporaries. +namespace test14 { + class A { + private: ~A(); // expected-note {{declared private here}} + }; + A foo(); + + void test() { + foo(); // expected-error {{temporary of type 'test14::A' has private destructor}} + } + + class X { + ~X(); // expected-note {{declared private here}} + }; + + struct Y1 { + operator X(); + }; + + void g() { + const X &xr = Y1(); // expected-error{{temporary of type 'test14::X' has private destructor}} + } +} + +// PR 7024 +namespace test15 { + template <class T> class A { + private: + int private_foo; // expected-note {{declared private here}} + static int private_sfoo; // expected-note {{declared private here}} + protected: + int protected_foo; // expected-note 4 {{declared protected here}} + static int protected_sfoo; // expected-note 3 {{declared protected here}} + + int test1(A<int> &a) { + return a.private_foo; // expected-error {{private member}} + } + + int test2(A<int> &a) { + return a.private_sfoo; // expected-error {{private member}} + } + + int test3(A<int> &a) { + return a.protected_foo; // expected-error {{protected member}} + } + + int test4(A<int> &a) { + return a.protected_sfoo; // expected-error {{protected member}} + } + }; + + template class A<int>; + template class A<long>; // expected-note 4 {{in instantiation}} + + template <class T> class B : public A<T> { + // TODO: These first two accesses can be detected as ill-formed at + // definition time because they're member accesses and A<int> can't + // be a subclass of B<T> for any T. + + int test1(A<int> &a) { + return a.protected_foo; // expected-error 2 {{protected member}} + } + + int test2(A<int> &a) { + return a.protected_sfoo; // expected-error {{protected member}} + } + + int test3(B<int> &b) { + return b.protected_foo; // expected-error {{protected member}} + } + + int test4(B<int> &b) { + return b.protected_sfoo; // expected-error {{protected member}} + } + }; + + template class B<int>; // expected-note {{in instantiation}} + template class B<long>; // expected-note 4 {{in instantiation}} +} diff --git a/test/CXX/class.access/p6.cpp b/test/CXX/class.access/p6.cpp index aaf510a..734a4d8 100644 --- a/test/CXX/class.access/p6.cpp +++ b/test/CXX/class.access/p6.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fsyntax-only -faccess-control -verify %s +// RUN: %clang_cc1 -fsyntax-only -verify %s // C++0x [class.access]p6: // All access controls in [class.access] affect the ability to @@ -52,3 +52,70 @@ namespace test1 { A apriv = priv; // expected-error {{private constructor}} } } + +// PR6967 +namespace test2 { + class A { + public: + template <class T> static void set(T &t, typename T::type v) { + t.value = v; + } + template <class T> static typename T::type get(const T &t) { + return t.value; + } + }; + + class B { + friend class A; + + private: + typedef int type; + type value; + }; + + int test() { + B b; + A::set(b, 0); + return A::get(b); + } +} + +namespace test3 { + class Green {}; class Blue {}; + + // We have to wrap this in a class because a partial specialization + // isn't actually in the context of the template. + struct Outer { + template <class T, class Nat> class A { + }; + }; + + template <class T> class Outer::A<T, typename T::nature> { + public: + static void foo(); + }; + + class B { + private: typedef Green nature; + friend class Outer; + }; + + void test() { + Outer::A<B, Green>::foo(); + Outer::A<B, Blue>::foo(); // expected-error {{no member named 'foo'}} + } +} + +namespace test4 { + template <class T> class A { + private: typedef int type; + template <class U> friend void foo(U &, typename U::type); + }; + + template <class U> void foo(U &, typename U::type) {} + + void test() { + A<int> a; + foo(a, 0); + } +} diff --git a/test/CXX/class/class.friend/p2.cpp b/test/CXX/class/class.friend/p2.cpp index 9fe2b17..eb5036f 100644 --- a/test/CXX/class/class.friend/p2.cpp +++ b/test/CXX/class/class.friend/p2.cpp @@ -4,7 +4,7 @@ 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 B0; // expected-error {{must specify 'struct' to befriend}} + friend int; // expected-warning {{non-class type 'int' cannot be a friend}} + friend B0; // expected-warning {{must specify 'struct' to befriend}} friend class C; // okay }; diff --git a/test/CXX/class/class.local/p2.cpp b/test/CXX/class/class.local/p2.cpp index 2b1359c..db4c90f 100644 --- a/test/CXX/class/class.local/p2.cpp +++ b/test/CXX/class/class.local/p2.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -faccess-control +// RUN: %clang_cc1 -fsyntax-only -verify %s struct A { }; diff --git a/test/CXX/class/class.mfct/class.mfct.non-static/p3.cpp b/test/CXX/class/class.mfct/class.mfct.non-static/p3.cpp index f5fbf7a..c81e4ef 100644 --- a/test/CXX/class/class.mfct/class.mfct.non-static/p3.cpp +++ b/test/CXX/class/class.mfct/class.mfct.non-static/p3.cpp @@ -50,7 +50,7 @@ namespace test1 { } namespace test2 { - class Unrelated { + struct Unrelated { void foo(); }; diff --git a/test/CXX/conv/conv.mem/p4.cpp b/test/CXX/conv/conv.mem/p4.cpp index 42f6343..e0748d8 100644 --- a/test/CXX/conv/conv.mem/p4.cpp +++ b/test/CXX/conv/conv.mem/p4.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fsyntax-only -faccess-control -verify %s +// RUN: %clang_cc1 -fsyntax-only -verify %s struct Base { int data; diff --git a/test/CXX/dcl.dcl/basic.namespace/namespace.def/namespace.memdef/p3.cpp b/test/CXX/dcl.dcl/basic.namespace/namespace.def/namespace.memdef/p3.cpp index a5f314d..ddcbe78 100644 --- a/test/CXX/dcl.dcl/basic.namespace/namespace.def/namespace.memdef/p3.cpp +++ b/test/CXX/dcl.dcl/basic.namespace/namespace.def/namespace.memdef/p3.cpp @@ -53,4 +53,16 @@ struct Y { friend union X1; }; +namespace N { + namespace M { + template<typename T> class X; + } +} + +namespace N3 { + class Y { + template<typename T> friend class N::M::X; + }; +} + // FIXME: Woefully inadequate for testing diff --git a/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p1.cpp b/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p1.cpp index 89e9c89..bb1d67f 100644 --- a/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p1.cpp +++ b/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p1.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fsyntax-only -faccess-control -verify %s +// RUN: %clang_cc1 -fsyntax-only -verify %s // We have to avoid ADL for this test. @@ -12,7 +12,8 @@ namespace Test0 { test<1> foo(class foo); namespace A { - test<2> foo(class ::foo); // expected-note {{candidate}} + test<2> foo(class ::foo); // expected-note {{candidate}} \ + // expected-note{{passing argument to parameter here}} void test0() { using ::foo; @@ -38,7 +39,7 @@ namespace Test0 { test<2> _1 = (foo)(a); class Test0::foo b; - test<2> _2 = (foo)(b); // expected-error {{no viable conversion from 'class Test0::foo' to 'class foo' is possible}} + test<2> _2 = (foo)(b); // expected-error {{no viable conversion from 'class Test0::foo' to 'class ::foo' is possible}} } } } diff --git a/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p4.cpp b/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p4.cpp index 23da98c..a43d9e0 100644 --- a/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p4.cpp +++ b/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p4.cpp @@ -166,7 +166,7 @@ namespace test3 { template <class T> struct C : A<T> { using typename A<T>::type; - using typename A<T>::hiding; // expected-note {{declared at}} \ + using typename A<T>::hiding; // expected-note {{declared here}} \ // expected-error {{'typename' keyword used on a non-type}} using typename A<T>::union_member; // expected-error {{'typename' keyword used on a non-type}} using typename A<T>::enumerator; // expected-error {{'typename' keyword used on a non-type}} diff --git a/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.elab/p3.cpp b/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.elab/p3.cpp index c530311..b04e869 100644 --- a/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.elab/p3.cpp +++ b/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.elab/p3.cpp @@ -13,7 +13,7 @@ class A1 { friend union A; // expected-error {{use of 'A' with tag type that does not match previous declaration}} friend enum A; // expected-error {{ISO C++ forbids forward references to 'enum' types}} \ - // expected-error {{enum types cannot be friends}} + // expected-warning {{cannot be a friend}} }; template <class T> struct B { // expected-note {{previous use is here}} diff --git a/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p16-cxx0x-no-extra-copy.cpp b/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p16-cxx0x-no-extra-copy.cpp new file mode 100644 index 0000000..5a342d4 --- /dev/null +++ b/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p16-cxx0x-no-extra-copy.cpp @@ -0,0 +1,50 @@ +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++0x %s + +// C++03 requires that we check for a copy constructor when binding a +// reference to a reference-compatible rvalue, since we are allowed to +// make a copy. C++0x does not permit the copy, so ensure that we +// don't diagnose cases where the copy constructor is unavailable. + +struct X1 { + X1(); + explicit X1(const X1&); +}; + +struct X2 { + X2(); + +private: + X2(const X2&); +}; + +struct X3 { + X3(); + +private: + X3(X3&); +}; + +template<typename T> +T get_value_badly() { + double *dp = 0; + T *tp = dp; + return T(); +} + +template<typename T> +struct X4 { + X4(); + X4(const X4&, T = get_value_badly<T>()); +}; + +void g1(const X1&); +void g2(const X2&); +void g3(const X3&); +void g4(const X4<int>&); + +void test() { + g1(X1()); + g2(X2()); + g3(X3()); + g4(X4<int>()); +} diff --git a/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-cxx03-extra-copy.cpp b/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-cxx03-extra-copy.cpp new file mode 100644 index 0000000..1639411 --- /dev/null +++ b/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-cxx03-extra-copy.cpp @@ -0,0 +1,61 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +// C++03 requires that we check for a copy constructor when binding a +// reference to a temporary, since we are allowed to make a copy, Even +// though we don't actually make that copy, make sure that we diagnose +// cases where that copy constructor is somehow unavailable. + +struct X1 { + X1(); + explicit X1(const X1&); +}; + +struct X2 { + X2(); + +private: + X2(const X2&); // expected-note{{declared private here}} +}; + +struct X3 { + X3(); + +private: + X3(X3&); // expected-note{{candidate constructor not viable: no known conversion from 'X3' to 'X3 &' for 1st argument}} +}; + +// Check for instantiation of default arguments +template<typename T> +T get_value_badly() { + double *dp = 0; + T *tp = dp; // expected-error{{ cannot initialize a variable of type 'int *' with an lvalue of type 'double *'}} + return T(); +} + +template<typename T> +struct X4 { + X4(); + X4(const X4&, T = get_value_badly<T>()); // expected-note{{in instantiation of}} +}; + +// Check for "dangerous" default arguments that could cause recursion. +struct X5 { + X5(); + X5(const X5&, const X5& = X5()); // expected-error{{no viable constructor copying parameter of type 'X5'}} +}; + +void g1(const X1&); +void g2(const X2&); +void g3(const X3&); +void g4(const X4<int>&); +void g5(const X5&); + +void test() { + g1(X1()); // expected-error{{no viable constructor copying parameter of type 'X1'}} + g2(X2()); // expected-error{{calling a private constructor of class 'X2'}} + g3(X3()); // expected-error{{no viable constructor copying parameter of type 'X3'}} + g4(X4<int>()); + g5(X5()); // expected-error{{no viable constructor copying parameter of type 'X5'}} +} + +// Check for dangerous recursion in default arguments. diff --git a/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-examples.cpp b/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-examples.cpp index d757adf..9b39259 100644 --- a/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-examples.cpp +++ b/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-examples.cpp @@ -17,11 +17,11 @@ struct B : A { } b; // CHECK: example1 void example1() { // CHECK: A &ra = - // CHECK: ImplicitCastExpr{{.*}}'struct A' <DerivedToBase> lvalue + // CHECK: ImplicitCastExpr{{.*}}'struct A' <DerivedToBase (A)> lvalue A &ra = b; // CHECK: A const &rca = // CHECK: ImplicitCastExpr{{.*}}'struct A const' <NoOp> - // CHECK: ImplicitCastExpr{{.*}}'struct A' <DerivedToBase> + // CHECK: ImplicitCastExpr{{.*}}'struct A' <DerivedToBase (A)> const A& rca = b; } @@ -35,12 +35,12 @@ struct X { void example2() { // CHECK: A const &rca = // CHECK: ImplicitCastExpr{{.*}}'struct A const' <NoOp> - // CHECK: ImplicitCastExpr{{.*}}'struct A' <DerivedToBase> + // CHECK: ImplicitCastExpr{{.*}}'struct A' <DerivedToBase (A)> // CHECK: CallExpr{{.*}}B const A &rca = f(); // CHECK: A const &r = // CHECK: ImplicitCastExpr{{.*}}'struct A const' <NoOp> - // CHECK: ImplicitCastExpr{{.*}}'struct A' <DerivedToBase> + // CHECK: ImplicitCastExpr{{.*}}'struct A' <DerivedToBase (A)> // CHECK: CXXMemberCallExpr{{.*}}'struct B' const A& r = x; } diff --git a/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5.cpp b/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5.cpp index 4c7ee94..51d61a5 100644 --- a/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5.cpp +++ b/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5.cpp @@ -22,3 +22,19 @@ namespace PR6264 { T bar = S(); } } + +namespace PR6066 { + struct B { }; + struct A : B { + operator B*(); + operator B&(); // expected-warning{{conversion function converting 'PR6066::A' to its base class 'PR6066::B' will never be used}} + }; + + void f(B&); // no rvalues accepted + void f(B*); + + int g() { + f(A()); // calls f(B*) + return 0; + } +} diff --git a/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p5.cpp b/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p5.cpp index 7ee052c..3100e56 100644 --- a/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p5.cpp +++ b/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p5.cpp @@ -2,7 +2,8 @@ float global_f; -void f0(int *ip = &global_f); // expected-error{{cannot initialize}} +void f0(int *ip = &global_f); // expected-error{{cannot initialize}} \ +// expected-note{{passing argument to parameter 'ip' here}} // Example from C++03 standard int a = 1; diff --git a/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p6.cpp b/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p6.cpp index 00234ac..9ab0b48 100644 --- a/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p6.cpp +++ b/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p6.cpp @@ -1,6 +1,7 @@ // RUN: %clang_cc1 -fsyntax-only -verify %s class C { +public: void f(int i = 3); // expected-note{{here}} void g(int i, int j = 99); }; diff --git a/test/CXX/dcl.decl/dcl.meaning/dcl.ref/p5.cpp b/test/CXX/dcl.decl/dcl.meaning/dcl.ref/p5.cpp index 17fd712..aaf7451 100644 --- a/test/CXX/dcl.decl/dcl.meaning/dcl.ref/p5.cpp +++ b/test/CXX/dcl.decl/dcl.meaning/dcl.ref/p5.cpp @@ -9,10 +9,10 @@ typedef int &intref; typedef intref &intrefref; -template <class T> class RefMem { +template <class T> class RefMem { // expected-warning{{class 'RefMem<int &>' does not declare any constructor to initialize its non-modifiable members}} T & - member; + member; // expected-note{{ reference member 'member' will never be initialized}} }; struct RefRef { @@ -34,7 +34,7 @@ struct RefRef { int & > - refref3; // collapses + refref3; // collapses expected-note{{in instantiation of template class 'RefMem<int &>' requested here}} }; diff --git a/test/CXX/except/except.handle/p16.cpp b/test/CXX/except/except.handle/p16.cpp index 87972f5..4950a2f 100644 --- a/test/CXX/except/except.handle/p16.cpp +++ b/test/CXX/except/except.handle/p16.cpp @@ -11,12 +11,12 @@ class X { public: X(const X<T> &) { int *ip = 0; - ptr = ip; // expected-error{{incompatible type assigning 'int *', expected 'float *'}} + ptr = ip; // expected-error{{assigning to 'float *' from incompatible type 'int *'}} } ~X() { float *fp = 0; - ptr = fp; // expected-error{{incompatible type assigning 'float *', expected 'int *'}} + ptr = fp; // expected-error{{assigning to 'int *' from incompatible type 'float *'}} } }; diff --git a/test/CXX/expr/expr.unary/expr.delete/p5.cpp b/test/CXX/expr/expr.unary/expr.delete/p5.cpp index 4b2b5ae..2fa30e5 100644 --- a/test/CXX/expr/expr.unary/expr.delete/p5.cpp +++ b/test/CXX/expr/expr.unary/expr.delete/p5.cpp @@ -11,7 +11,7 @@ class T0 { ~T0(); }; // The trivial case, inside a template instantiation. template<typename T> -class T1_A { T *x; ~T1_A() { delete x; } }; // expected-warning {{deleting pointer to incomplete type}} +struct T1_A { T *x; ~T1_A() { delete x; } }; // expected-warning {{deleting pointer to incomplete type}} class T1_B; // expected-note {{forward declaration}} void f0() { T1_A<T1_B> x; } // expected-note {{in instantiation of member function}} diff --git a/test/CXX/expr/expr.unary/expr.new/p19.cpp b/test/CXX/expr/expr.unary/expr.new/p19.cpp index 6134779..bb69fd5 100644 --- a/test/CXX/expr/expr.unary/expr.new/p19.cpp +++ b/test/CXX/expr/expr.unary/expr.new/p19.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s +// RUN: %clang_cc1 -fsyntax-only -verify -fexceptions %s typedef __SIZE_TYPE__ size_t; // Operator delete template for placement new with global lookup diff --git a/test/CXX/expr/expr.unary/expr.new/p20-0x.cpp b/test/CXX/expr/expr.unary/expr.new/p20-0x.cpp index c188e1e..4c924b1 100644 --- a/test/CXX/expr/expr.unary/expr.new/p20-0x.cpp +++ b/test/CXX/expr/expr.unary/expr.new/p20-0x.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++0x %s +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++0x -fexceptions %s typedef __SIZE_TYPE__ size_t; struct S { diff --git a/test/CXX/expr/expr.unary/expr.new/p20.cpp b/test/CXX/expr/expr.unary/expr.new/p20.cpp index 71e584e..8cbe2b9 100644 --- a/test/CXX/expr/expr.unary/expr.new/p20.cpp +++ b/test/CXX/expr/expr.unary/expr.new/p20.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s +// RUN: %clang_cc1 -fsyntax-only -verify -fexceptions %s typedef __SIZE_TYPE__ size_t; // Overloaded operator delete with two arguments diff --git a/test/CXX/over/over.match/over.match.best/over.best.ics/over.ics.user/p3-0x.cpp b/test/CXX/over/over.match/over.match.best/over.best.ics/over.ics.user/p3-0x.cpp new file mode 100644 index 0000000..d9e0ff8 --- /dev/null +++ b/test/CXX/over/over.match/over.match.best/over.best.ics/over.ics.user/p3-0x.cpp @@ -0,0 +1,14 @@ +// RUN: %clang_cc1 -fsyntax-only -std=c++0x -verify %s + +namespace PR6285 { + template<typename T> struct identity + { typedef T type; }; + + struct D { + template<typename T = short> + operator typename identity<T>::type(); // expected-note{{candidate}} + }; + + int f() { return D(); } // expected-error{{no viable conversion}} +} + diff --git a/test/CXX/stmt.stmt/stmt.select/p3.cpp b/test/CXX/stmt.stmt/stmt.select/p3.cpp index e674f97..31de685 100644 --- a/test/CXX/stmt.stmt/stmt.select/p3.cpp +++ b/test/CXX/stmt.stmt/stmt.select/p3.cpp @@ -9,3 +9,11 @@ void g() { int x; // expected-error{{redefinition of 'x'}} } } + + +void h() { + if (int x = f()) // expected-note 2{{previous definition}} + int x; // expected-error{{redefinition of 'x'}} + else + int x; // expected-error{{redefinition of 'x'}} +}
\ No newline at end of file diff --git a/test/CXX/temp/temp.decls/temp.class.spec/temp.class.order/p2.cpp b/test/CXX/temp/temp.decls/temp.class.spec/temp.class.order/p2.cpp index cfa14f9..97457ea 100644 --- a/test/CXX/temp/temp.decls/temp.class.spec/temp.class.order/p2.cpp +++ b/test/CXX/temp/temp.decls/temp.class.spec/temp.class.order/p2.cpp @@ -1,16 +1,48 @@ // RUN: %clang_cc1 -fsyntax-only -verify %s -template<int I, int J, class T> class X { +template<int I, int J, class T> struct X { static const int value = 0; }; -template<int I, int J> class X<I, J, int> { +template<int I, int J> struct X<I, J, int> { static const int value = 1; }; -template<int I> class X<I, I, int> { +template<int I> struct X<I, I, int> { static const int value = 2; }; int array0[X<0, 0, float>::value == 0? 1 : -1]; int array1[X<0, 1, int>::value == 1? 1 : -1]; int array2[X<0, 0, int>::value == 2? 1 : -1]; + +namespace DependentSubstPartialOrdering { + template<typename T, typename U = void, typename V = void> + struct X { + static const unsigned value = 1; + }; + + template<typename T, typename U> + struct X<T, U, typename T::is_b> { + static const unsigned value = 2; + }; + + template<typename T> + struct X<T, typename T::is_a, typename T::is_b> { + static const unsigned value = 3; + }; + + struct X1 { }; + + struct X2 { + typedef void is_b; + }; + + struct X3 { + typedef void is_a; + typedef void is_b; + }; + + int check_X1[X<X1, void, void>::value == 1? 1 : -1]; + int check_X2[X<X2, void, void>::value == 2? 1 : -1]; + int check_X3[X<X3, void, void>::value == 3? 1 : -1]; +} diff --git a/test/CXX/temp/temp.decls/temp.friend/p1.cpp b/test/CXX/temp/temp.decls/temp.friend/p1.cpp index c9dc546..073b2a1 100644 --- a/test/CXX/temp/temp.decls/temp.friend/p1.cpp +++ b/test/CXX/temp/temp.decls/temp.friend/p1.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -faccess-control -verify -emit-llvm-only %s +// RUN: %clang_cc1 -verify -emit-llvm-only %s namespace test0 { template <typename T> struct Num { @@ -155,7 +155,7 @@ namespace Dependent { } namespace test7 { - template <class T> class A { // expected-note {{previous definition is here}} + template <class T> class A { // expected-note {{declared here}} friend class B; int x; // expected-note {{declared private here}} }; @@ -174,7 +174,7 @@ namespace test7 { // This shouldn't crash. template <class T> class D { - friend class A; // expected-error {{redefinition of 'A' as different kind of symbol}} + friend class A; // expected-error {{elaborated type refers to a template}} }; template class D<int>; } @@ -216,3 +216,80 @@ namespace test9 { template class A<int>; // expected-note {{in instantiation}} } + +namespace test10 { + template <class T> class A; + template <class T> A<T> bar(const T*, const A<T>&); + template <class T> class A { + private: + void foo(); // expected-note {{declared private here}} + friend A bar<>(const T*, const A<T>&); + }; + + template <class T> A<T> bar(const T *l, const A<T> &r) { + A<T> l1; + l1.foo(); + + A<char> l2; + l2.foo(); // expected-error {{'foo' is a private member of 'test10::A<char>'}} + + return l1; + } + + template A<int> bar<int>(const int *, const A<int> &); // expected-note {{in instantiation}} +} + +// PR6752: this shouldn't crash. +namespace test11 { + struct Foo { + template<class A> + struct IteratorImpl { + template<class T> friend class IteratorImpl; + }; + }; + + template struct Foo::IteratorImpl<int>; + template struct Foo::IteratorImpl<long>; +} + +// PR6827 +namespace test12 { + template <typename T> class Foo; + template <typename T> Foo<T> foo(T* t){ return Foo<T>(t, true); } + + template <typename T> class Foo { + public: + Foo(T*); + friend Foo<T> foo<T>(T*); + private: + Foo(T*, bool); // expected-note {{declared private here}} + }; + + // Should work. + int globalInt; + Foo<int> f = foo(&globalInt); + + // Shouldn't work. + long globalLong; + template <> Foo<long> foo(long *t) { + Foo<int> s(&globalInt, false); // expected-error {{calling a private constructor}} + return Foo<long>(t, true); + } +} + +// PR6514 +namespace test13 { + template <int N, template <int> class Temp> + class Role : public Temp<N> { + friend class Temp<N>; + int x; + }; + + template <int N> class Foo { + void foo(Role<N, test13::Foo> &role) { + (void) role.x; + } + }; + + template class Foo<0>; +} diff --git a/test/CXX/temp/temp.decls/temp.friend/p3.cpp b/test/CXX/temp/temp.decls/temp.friend/p3.cpp index 17d8c85..d116e01 100644 --- a/test/CXX/temp/temp.decls/temp.friend/p3.cpp +++ b/test/CXX/temp/temp.decls/temp.friend/p3.cpp @@ -8,6 +8,5 @@ class B { template <class T> friend class A; template <class T> friend class Undeclared; - // FIXME: Diagnostic below could be (and was) better. - template <class T> friend typename A<T>::Member; // expected-error {{classes or functions}} + template <class T> friend typename A<T>::Member; // expected-warning {{non-class type 'typename A<T>::Member' cannot be a friend}} }; diff --git a/test/CXX/temp/temp.decls/temp.mem/p1.cpp b/test/CXX/temp/temp.decls/temp.mem/p1.cpp index b057eed..f5f1205 100644 --- a/test/CXX/temp/temp.decls/temp.mem/p1.cpp +++ b/test/CXX/temp/temp.decls/temp.mem/p1.cpp @@ -19,17 +19,17 @@ namespace PR6376 { template<typename T> struct X { template<typename Y> - struct Y { }; + struct Y1 { }; // }; template<> struct X<float> { template<typename Y> - struct Y { }; + struct Y1 { }; }; template<typename T, typename U> - struct Z : public X<T>::template Y<U> { }; + struct Z : public X<T>::template Y1<U> { }; Z<float, int> z0; } diff --git a/test/CXX/temp/temp.param/p3.cpp b/test/CXX/temp/temp.param/p3.cpp index 8fcc2dc..dc40c4b 100644 --- a/test/CXX/temp/temp.param/p3.cpp +++ b/test/CXX/temp/temp.param/p3.cpp @@ -26,3 +26,15 @@ template<class T, T i> struct X2 { // expected-error{{no viable conversion}} } }; + +namespace PR6831 { + namespace NA { struct S; } + namespace NB { struct S; } + + using namespace NA; + using namespace NB; + + template <typename S> void foo(); + template <int S> void bar(); + template <template<typename> class S> void baz(); +} diff --git a/test/CXX/temp/temp.res/temp.local/p3.cpp b/test/CXX/temp/temp.res/temp.local/p3.cpp new file mode 100644 index 0000000..88f8963 --- /dev/null +++ b/test/CXX/temp/temp.res/temp.local/p3.cpp @@ -0,0 +1,32 @@ +// RUN: %clang_cc1 -verify %s + +template <class T> struct Base { // expected-note 4 {{member found by ambiguous name lookup}} + static void f(); +}; + +struct X0 { }; + +template <class T> struct Derived: Base<int>, Base<char> { + typename Derived::Base b; // expected-error{{member 'Base' found in multiple base classes of different types}} + typename Derived::Base<double> d; // OK + + void g(X0 *t) { + t->Derived::Base<T>::f(); + t->Base<T>::f(); + t->Base::f(); // expected-error{{member 'Base' found in multiple base classes of different types}} \ + // expected-error{{no member named 'f' in 'X0'}} \ + // expected-error{{expected a class or namespace}} + } +}; + +namespace PR6717 { + template <typename T> + class WebVector { + } + + WebVector(const WebVector<T>& other) { } + + template <typename C> + WebVector<T>& operator=(const C& other) { } // expected-error{{unknown type name 'WebVector'}} \ + // expected-error{{unqualified-id}} +} diff --git a/test/CXX/temp/temp.spec/p5.cpp b/test/CXX/temp/temp.spec/p5.cpp index c37817c..ba99dd7 100644 --- a/test/CXX/temp/temp.spec/p5.cpp +++ b/test/CXX/temp/temp.spec/p5.cpp @@ -27,3 +27,20 @@ template union X0<float>::Inner; // expected-error{{duplicate explicit instantia template float X0<float>::value; // expected-note{{previous explicit instantiation}} template float X0<float>::value; // expected-error{{duplicate explicit instantiation}} + +// Make sure that we don't get tricked by redeclarations of nested classes. +namespace NestedClassRedecls { + template<typename T> + struct X { + struct Nested; + friend struct Nested; + + struct Nested { + Nested() {} + } nested; + }; + + X<int> xi; + + template struct X<int>; +} diff --git a/test/CXX/temp/temp.spec/temp.explicit/p3.cpp b/test/CXX/temp/temp.spec/temp.explicit/p3.cpp index e30f046..e9758bc 100644 --- a/test/CXX/temp/temp.spec/temp.explicit/p3.cpp +++ b/test/CXX/temp/temp.spec/temp.explicit/p3.cpp @@ -8,12 +8,11 @@ template void f0(int); // okay // A definition of the class or class template containing a member function // template shall be in scope at the point of the explicit instantiation of // the member function template. -struct X0; // expected-note 3{{forward declaration}} -template<typename> struct X1; // expected-note 8{{declared here}} +struct X0; // expected-note {{forward declaration}} +template<typename> struct X1; // expected-note 5{{declared here}} -// FIXME: Repeated diagnostics here! -template void X0::f0<int>(int); // expected-error 3{{incomplete type}} // expected-error{{invalid token after top level declarator}} -template void X1<int>::f0<int>(int); // expected-error 3{{implicit instantiation of undefined template}} // expected-error{{invalid token after top level declarator}} +template void X0::f0<int>(int); // expected-error {{incomplete type}} +template void X1<int>::f0<int>(int); // expected-error {{implicit instantiation of undefined template}} // A definition of a class template or class member template shall be in scope // at the point of the explicit instantiation of the class template or class @@ -33,11 +32,10 @@ template struct X2<int>::Inner<float>; // expected-error{{explicit instantiation // A definition of a class template shall be in scope at the point of an // explicit instantiation of a member function or a static data member of the // class template. -template void X1<int>::f1(int); // expected-error 2{{undefined template}} \ - // expected-error{{does not refer}} +template void X1<int>::f1(int); // expected-error {{undefined template}} +template void X1<int>::f1<int>(int); // expected-error {{undefined template}} -template int X1<int>::member; // expected-error 2{{undefined template}} \ - // expected-error{{does not refer}} +template int X1<int>::member; // expected-error {{undefined template}} // A definition of a member class of a class template shall be in scope at the // point of an explicit instantiation of the member class. diff --git a/test/CXX/temp/temp.spec/temp.explicit/p4.cpp b/test/CXX/temp/temp.spec/temp.explicit/p4.cpp index 2b85213..d304374 100644 --- a/test/CXX/temp/temp.spec/temp.explicit/p4.cpp +++ b/test/CXX/temp/temp.spec/temp.explicit/p4.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s +// RUN: %clang_cc1 -fsyntax-only -verify -pedantic %s template<typename T> void f0(T); // expected-note{{here}} template void f0(int); // expected-error{{explicit instantiation of undefined function template}} @@ -16,20 +16,20 @@ template void X0<int>::f1(); // expected-error{{explicit instantiation of undefi template int X0<int>::value; // expected-error{{explicit instantiation of undefined static data member}} -template<> void f0(long); -template void f0(long); // okay +template<> void f0(long); // expected-note{{previous template specialization is here}} +template void f0(long); // expected-warning{{explicit instantiation of 'f0<long>' that occurs after an explicit specialization will be ignored}} -template<> void X0<long>::f1(); -template void X0<long>::f1(); +template<> void X0<long>::f1(); // expected-note{{previous template specialization is here}} +template void X0<long>::f1(); // expected-warning{{explicit instantiation of 'f1' that occurs after an explicit specialization will be ignored}} -template<> struct X0<long>::Inner; -template struct X0<long>::Inner; +template<> struct X0<long>::Inner; // expected-note{{previous template specialization is here}} +template struct X0<long>::Inner; // expected-warning{{explicit instantiation of 'Inner' that occurs after an explicit specialization will be ignored}} -template<> long X0<long>::value; -template long X0<long>::value; +template<> long X0<long>::value; // expected-note{{previous template specialization is here}} +template long X0<long>::value; // expected-warning{{explicit instantiation of 'value' that occurs after an explicit specialization will be ignored}} -template<> struct X0<double>; -template struct X0<double>; +template<> struct X0<double>; // expected-note{{previous template specialization is here}} +template struct X0<double>; // expected-warning{{explicit instantiation of 'X0<double>' that occurs after an explicit specialization will be ignored}} // PR 6458 namespace test0 { diff --git a/test/CXX/temp/temp.spec/temp.inst/p11.cpp b/test/CXX/temp/temp.spec/temp.inst/p11.cpp new file mode 100644 index 0000000..8184071 --- /dev/null +++ b/test/CXX/temp/temp.spec/temp.inst/p11.cpp @@ -0,0 +1,15 @@ +// RUN: %clang_cc1 -verify -emit-llvm-only %s + +// rdar://problem/7838962 +namespace test0 { + template<typename T> unsigned f0() { + return T::MaxSize; // expected-error {{'int' cannot be used prior to '::'}} + }; + template<typename T> struct A { + void Allocate(unsigned Alignment + = f0<T>()) // expected-note {{in instantiation}} + {} + }; + void f1(A<int> x) { x.Allocate(); } + +} |