diff options
author | dim <dim@FreeBSD.org> | 2010-09-17 15:54:40 +0000 |
---|---|---|
committer | dim <dim@FreeBSD.org> | 2010-09-17 15:54:40 +0000 |
commit | 36c49e3f258dced101949edabd72e9bc3f1dedc4 (patch) | |
tree | 0bbe07708f7571f8b5291f6d7b96c102b7c99dee /test/CXX | |
parent | fc84956ac8b7cd244ef30e7a4d4d38a58dec5904 (diff) | |
download | FreeBSD-src-36c49e3f258dced101949edabd72e9bc3f1dedc4.zip FreeBSD-src-36c49e3f258dced101949edabd72e9bc3f1dedc4.tar.gz |
Vendor import of clang r114020 (from the release_28 branch):
http://llvm.org/svn/llvm-project/cfe/branches/release_28@114020
Approved by: rpaulo (mentor)
Diffstat (limited to 'test/CXX')
22 files changed, 600 insertions, 24 deletions
diff --git a/test/CXX/class.access/class.protected/p1.cpp b/test/CXX/class.access/class.protected/p1.cpp index 778e16a..8698fb1 100644 --- a/test/CXX/class.access/class.protected/p1.cpp +++ b/test/CXX/class.access/class.protected/p1.cpp @@ -68,7 +68,7 @@ namespace test1 { namespace test2 { class A { - protected: int x; // expected-note 3 {{declared}} + protected: int x; // expected-note 3 {{object type must derive}} static int sx; static void test(A&); }; @@ -103,7 +103,7 @@ namespace test2 { namespace test3 { class B; class A { - protected: int x; // expected-note {{declared}} + protected: int x; // expected-note {{object type must derive}} static int sx; static void test(B&); }; @@ -138,7 +138,7 @@ namespace test3 { namespace test4 { class C; class A { - protected: int x; // expected-note 3 {{declared}} + protected: int x; // expected-note {{declared}} expected-note 2 {{object type must derive}} static int sx; // expected-note 3{{member is declared here}} static void test(C&); }; @@ -215,7 +215,7 @@ namespace test6 { class Static {}; class A { protected: - void foo(int); // expected-note 3 {{declared}} + void foo(int); // expected-note 3 {{object type must derive}} void foo(long); static void foo(Static); @@ -253,7 +253,7 @@ namespace test7 { class Static {}; class A { protected: - void foo(int); // expected-note 3 {{declared}} + void foo(int); // expected-note 3 {{object type must derive}} void foo(long); static void foo(Static); @@ -291,7 +291,7 @@ namespace test8 { class Static {}; class A { protected: - void foo(int); // expected-note 3 {{declared}} + void foo(int); // expected-note 3 {{object type must derive}} void foo(long); static void foo(Static); @@ -329,8 +329,7 @@ namespace test8 { namespace test9 { class A { // expected-note {{member is declared here}} - protected: int foo(); // expected-note 8 {{declared}} \ - // expected-note {{member is declared here}} + protected: int foo(); // expected-note 4 {{declared}} expected-note 2 {{object type must derive}} expected-note {{object type 'test9::A' must derive}} }; class B : public A { // expected-note {{member is declared here}} @@ -338,7 +337,7 @@ namespace test9 { }; class C : protected B { // expected-note {{declared}} \ - // expected-note 6 {{constrained}} + // expected-note 9 {{constrained}} }; class D : public A { @@ -351,7 +350,7 @@ namespace test9 { static void test(B &b) { b.foo(); - b.A::foo(); // expected-error {{'foo' is a protected member}} + b.A::foo(); b.B::foo(); b.C::foo(); // expected-error {{'foo' is a protected member}} } @@ -359,8 +358,7 @@ namespace test9 { 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}} \ + c.A::foo(); // 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}} @@ -388,3 +386,50 @@ namespace test10 { template class A<int>; } + +// rdar://problem/8360285: class.protected friendship +namespace test11 { + class A { + protected: + int foo(); + }; + + class B : public A { + friend class C; + }; + + class C { + void test() { + B b; + b.A::foo(); + } + }; +} + +// This friendship is considered because a public member of A would be +// a private member of C. +namespace test12 { + class A { protected: int foo(); }; + class B : public virtual A {}; + class C : private B { friend void test(); }; + class D : private C, public virtual A {}; + + void test() { + D d; + d.A::foo(); + } +} + +// This friendship is not considered because a public member of A is +// inaccessible in C. +namespace test13 { + 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 {}; + + void test() { + D d; + d.A::foo(); // expected-error {{protected member}} + } +} diff --git a/test/CXX/class.access/p4.cpp b/test/CXX/class.access/p4.cpp index 90a1449..115a22a 100644 --- a/test/CXX/class.access/p4.cpp +++ b/test/CXX/class.access/p4.cpp @@ -372,7 +372,7 @@ namespace test15 { 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}} + int protected_foo; // expected-note 3 {{declared protected here}} // expected-note {{object type must derive from context type 'test15::B<int>'}} static int protected_sfoo; // expected-note 3 {{declared protected here}} int test1(A<int> &a) { @@ -427,3 +427,26 @@ namespace test16 { void b() { throw A(); } // expected-error{{temporary of type 'test16::A' has private destructor}} \ // expected-error{{exception object of type 'test16::A' has private destructor}} } + +// rdar://problem/8146294 +namespace test17 { + class A { + template <typename T> class Inner { }; // expected-note {{declared private here}} + }; + + A::Inner<int> s; // expected-error {{'Inner' is a private member of 'test17::A'}} +} + +namespace test18 { + template <class T> class A {}; + class B : A<int> { + A<int> member; + }; + + // FIXME: this access to A should be forbidden (because C++ is dumb), + // but LookupResult can't express the necessary information to do + // the check, so we aggressively suppress access control. + class C : B { + A<int> member; + }; +} diff --git a/test/CXX/class.access/p6.cpp b/test/CXX/class.access/p6.cpp index 734a4d8..8795708 100644 --- a/test/CXX/class.access/p6.cpp +++ b/test/CXX/class.access/p6.cpp @@ -119,3 +119,23 @@ namespace test4 { foo(a, 0); } } + +// PR7644 +namespace test5 { + class A { + enum Enum { E0, E1, E2 }; // expected-note 4 {{declared private here}} + template <Enum> void foo(); + template <Enum> class bar; + }; + + template <A::Enum en> void A::foo() {} + template <A::Enum en> class A::bar {}; + + template <A::Enum en> void foo() {} // expected-error {{'Enum' is a private member of 'test5::A'}} + template <A::Enum en> class bar {}; // expected-error {{'Enum' is a private member of 'test5::A'}} + + class B { + template <A::Enum en> void foo() {} // expected-error {{'Enum' is a private member of 'test5::A'}} + template <A::Enum en> class bar {}; // expected-error {{'Enum' is a private member of 'test5::A'}} + }; +} diff --git a/test/CXX/class/class.mem/p1.cpp b/test/CXX/class/class.mem/p1.cpp new file mode 100644 index 0000000..55507d4 --- /dev/null +++ b/test/CXX/class/class.mem/p1.cpp @@ -0,0 +1,64 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +struct S +{ + static int v1; // expected-note{{previous declaration is here}} + int v1; //expected-error{{duplicate member 'v1'}} + int v; //expected-note 2{{previous definition is here}} \ + // expected-note{{previous declaration is here}} + static int v; //expected-error{{redefinition of 'v' as different kind of symbol}} + int v; //expected-error{{duplicate member 'v'}} + static int v; //expected-error{{redefinition of 'v' as different kind of symbol}} + enum EnumT { E = 10 }; + friend struct M; + struct X; //expected-note{{forward declaration of 'S::X'}} + friend struct X; +}; + +S::EnumT Evar = S::E; // ok +S::EnumT Evar2 = EnumT(); //expected-error{{use of undeclared identifier 'EnumT'}} +S::M m; //expected-error{{no type named 'M' in 'S'}} +S::X x; //expected-error{{variable has incomplete type 'S::X'}} + + +struct S2 +{ + static int v2; // expected-note{{previous declaration is here}} + static int v2; //expected-error{{duplicate member 'v2'}} +}; + +struct S3 +{ + static int v3; + struct S4 + { + static int v3; + }; +}; + +struct S4 +{ + static int v4; +}; + +int S4::v4; //expected-note{{previous definition is here}} +int S4::v4; //expected-error{{redefinition of 'v4'}} + +struct S5 +{ + static int v5; //expected-note{{previous definition is here}} + void v5() { } //expected-error{{redefinition of 'v5' as different kind of symbol}} + + void v6() { } //expected-note{{previous definition is here}} + static int v6; //expected-error{{redefinition of 'v6' as different kind of symbol}} + + void v7() { } + void v7(int) { } //expected-note{{previous definition is here}} + static int v7; //expected-error{{redefinition of 'v7' as different kind of symbol}} + + void v8(); + int v8(int); //expected-note{{previous declaration is here}} + int v8; //expected-error{{duplicate member 'v8'}} + + +}; diff --git a/test/CXX/class/class.static/class.static.data/p4.cpp b/test/CXX/class/class.static/class.static.data/p4.cpp new file mode 100644 index 0000000..2b1eca7 --- /dev/null +++ b/test/CXX/class/class.static/class.static.data/p4.cpp @@ -0,0 +1,25 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s +struct InClassInitializerOnly { + static const int i = 0; +}; +int const InClassInitializerOnly::i; + +struct OutOfClassInitializerOnly { + static const int i; +}; +int const OutOfClassInitializerOnly::i = 0; + +struct InClassInitializerAndOutOfClassCopyInitializer { + static const int i = 0; // expected-note{{previous definition is here}} +}; +int const InClassInitializerAndOutOfClassCopyInitializer::i = 0; // expected-error{{redefinition of 'i'}} + +struct InClassInitializerAndOutOfClassDirectInitializer { + static const int i = 0; // expected-note{{previous definition is here}} +}; +int const InClassInitializerAndOutOfClassDirectInitializer::i(0); // expected-error{{redefinition of 'i'}} + + + +int main() { } + diff --git a/test/CXX/conv/conv.ptr/p2.cpp b/test/CXX/conv/conv.ptr/p2.cpp new file mode 100644 index 0000000..8808d20 --- /dev/null +++ b/test/CXX/conv/conv.ptr/p2.cpp @@ -0,0 +1,6 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +namespace pr7801 { + extern void* x[]; + void* dummy[] = { &x }; +} diff --git a/test/CXX/dcl.dcl/basic.namespace/namespace.def/p1.cpp b/test/CXX/dcl.dcl/basic.namespace/namespace.def/p1.cpp new file mode 100644 index 0000000..6ffa873 --- /dev/null +++ b/test/CXX/dcl.dcl/basic.namespace/namespace.def/p1.cpp @@ -0,0 +1,9 @@ +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 -pedantic %s + +// Intentionally compiled as C++03 to test the extension warning. + +namespace a {} // original +namespace a {} // ext +inline namespace b {} // inline original expected-warning {{inline namespaces are}} +inline namespace b {} // inline ext expected-warning {{inline namespaces are}} +inline namespace {} // inline unnamed expected-warning {{inline namespaces are}} diff --git a/test/CXX/dcl.dcl/basic.namespace/namespace.def/p7.cpp b/test/CXX/dcl.dcl/basic.namespace/namespace.def/p7.cpp new file mode 100644 index 0000000..198b013 --- /dev/null +++ b/test/CXX/dcl.dcl/basic.namespace/namespace.def/p7.cpp @@ -0,0 +1,13 @@ +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++0x %s + +namespace NIL {} // expected-note {{previous definition}} +inline namespace NIL {} // expected-error {{cannot be reopened as inline}} +inline namespace IL {} // expected-note {{previous definition}} +namespace IL {} // expected-error {{cannot be reopened as non-inline}} + +namespace {} // expected-note {{previous definition}} +inline namespace {} // expected-error {{cannot be reopened as inline}} +namespace X { + inline namespace {} // expected-note {{previous definition}} + namespace {} // expected-error {{cannot be reopened as non-inline}} +} diff --git a/test/CXX/dcl.dcl/basic.namespace/namespace.def/p8.cpp b/test/CXX/dcl.dcl/basic.namespace/namespace.def/p8.cpp new file mode 100644 index 0000000..b9ad6e1 --- /dev/null +++ b/test/CXX/dcl.dcl/basic.namespace/namespace.def/p8.cpp @@ -0,0 +1,97 @@ +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++0x %s + +// Fun things you can do with inline namespaces: + +inline namespace X { + void f1(); + + inline namespace Y { + void f2(); + + template <typename T> class C {}; + } + + // Specialize and partially specialize somewhere else. + template <> class C<int> {}; + template <typename T> class C<T*> {}; +} + +// Qualified and unqualified lookup as if member of enclosing NS. +void foo1() { + f1(); + ::f1(); + X::f1(); + Y::f1(); // expected-error {{no member named 'f1' in namespace 'X::Y'}} + + f2(); + ::f2(); + X::f2(); + Y::f2(); +} + +template <> class C<float> {}; +template <typename T> class C<T&> {}; + +template class C<double>; + + +// As well as all the fun with ADL. + +namespace ADL { + struct Outer {}; + + inline namespace IL { + struct Inner {}; + + void fo(Outer); + } + + void fi(Inner); + + inline namespace IL2 { + void fi2(Inner); + } +} + +void foo2() { + ADL::Outer o; + ADL::Inner i; + fo(o); + fi(i); + fi2(i); +} + +// Let's not forget overload sets. +struct Distinct {}; +inline namespace Over { + void over(Distinct); +} +void over(int); + +void foo3() { + Distinct d; + ::over(d); +} + +// Don't forget to do correct lookup for redeclarations. +namespace redecl { inline namespace n1 { + + template <class Tp> class allocator; + + template <> + class allocator<void> + { + public: + typedef const void* const_pointer; + }; + + template <class Tp> + class allocator + { + public: + typedef Tp& reference; + + void allocate(allocator<void>::const_pointer = 0); + }; + +} } diff --git a/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p10.cpp b/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p10.cpp index 27b41a7..546c4a4 100644 --- a/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p10.cpp +++ b/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p10.cpp @@ -31,3 +31,4 @@ namespace test1 { using test1::foo; } } + diff --git a/test/CXX/dcl.dcl/basic.namespace/namespace.udir/p6.cpp b/test/CXX/dcl.dcl/basic.namespace/namespace.udir/p6.cpp new file mode 100644 index 0000000..4cb91cd --- /dev/null +++ b/test/CXX/dcl.dcl/basic.namespace/namespace.udir/p6.cpp @@ -0,0 +1,15 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +// <rdar://problem/8296180> +typedef int pid_t; +namespace ns { + typedef int pid_t; +} +using namespace ns; +pid_t x; + +struct A { }; +namespace ns { + typedef ::A A; +} +A a; diff --git a/test/CXX/dcl.dcl/dcl.spec/dcl.fct.spec/p3.cpp b/test/CXX/dcl.dcl/dcl.spec/dcl.fct.spec/p3.cpp index 99a4f7a..d7b9eff 100644 --- a/test/CXX/dcl.dcl/dcl.spec/dcl.fct.spec/p3.cpp +++ b/test/CXX/dcl.dcl/dcl.spec/dcl.fct.spec/p3.cpp @@ -1,11 +1,13 @@ // RUN: %clang_cc1 -verify %s -// XFAIL: * -void f0(void) { - inline void f1(); // expected-error {{'inline' is not allowed on block scope function declaration}} +void f0a(void) { + inline void f1(); // expected-error {{inline declaration of 'f1' not allowed in block scope}} +} + +void f0b(void) { + void f1(); } // FIXME: Add test for "If the inline specifier is used in a friend declaration, // that declaration shall be a definition or the function shall have previously // been declared inline. - diff --git a/test/CXX/dcl.dcl/dcl.spec/dcl.stc/p9.cpp b/test/CXX/dcl.dcl/dcl.spec/dcl.stc/p9.cpp index f507eec..491ab17 100644 --- a/test/CXX/dcl.dcl/dcl.spec/dcl.stc/p9.cpp +++ b/test/CXX/dcl.dcl/dcl.spec/dcl.stc/p9.cpp @@ -1,12 +1,11 @@ // RUN: %clang_cc1 -verify %s -struct S; // expected-note {{forward declaration of 'S'}} +struct S; // expected-note 2{{forward declaration of 'S'}} extern S a; extern S f(); // expected-note {{'f' declared here}} -extern void g(S a); // expected-note {{candidate function}} +extern void g(S a); void h() { - // FIXME: This diagnostic could be better. - g(a); // expected-error {{no matching function for call to 'g'}} + g(a); // expected-error {{argument type 'S' is incomplete}} f(); // expected-error {{calling 'f' with incomplete return type 'S'}} } diff --git a/test/CXX/dcl.decl/dcl.init/p5.cpp b/test/CXX/dcl.decl/dcl.init/p5.cpp new file mode 100644 index 0000000..b50e8d7 --- /dev/null +++ b/test/CXX/dcl.decl/dcl.init/p5.cpp @@ -0,0 +1,20 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +// FIXME: Very incomplete! + +// A program that calls for default-initialization or value-initialization of +// an entity of reference type is illformed. If T is a cv-qualified type, the +// cv-unqualified version of T is used for these definitions of +// zero-initialization, default-initialization, and value-initialization. +// +// FIXME: The diagnostics for these errors are terrible because they fall out +// of the AST representation rather than being explicitly issued during the +// respective initialization forms. +struct S { // expected-error {{implicit default constructor for 'S' must explicitly initialize the reference member}} \ + // expected-note {{candidate constructor (the implicit copy constructor) not viable}} + int& x; // expected-note {{declared here}} +}; +S s; // expected-note {{implicit default constructor for 'S' first required here}} +S f() { + return S(); // expected-error {{no matching constructor for initialization of 'S'}} +} diff --git a/test/CXX/expr/expr.unary/expr.unary.op/p4.cpp b/test/CXX/expr/expr.unary/expr.unary.op/p4.cpp new file mode 100644 index 0000000..170c734 --- /dev/null +++ b/test/CXX/expr/expr.unary/expr.unary.op/p4.cpp @@ -0,0 +1,45 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +// rdar://problem/8347416 +namespace test0 { + struct A { + void foo(void (A::*)(int)); // expected-note {{passing argument to parameter here}} + template<typename T> void g(T); + + void test() { + // FIXME: this diagnostic is terrible + foo(&g<int>); // expected-error {{cannot initialize a parameter of type 'void (test0::A::*)(int)' with an rvalue of type '<overloaded function type>'}} + } + }; +} + +// This should succeed. +namespace test1 { + struct A { + static void f(void (A::*)()); + static void f(void (*)(int)); + void g(); + static void g(int); + + void test() { + f(&g); + } + }; +} + +// Also rdar://problem/8347416 +namespace test2 { + struct A { + static int foo(short); + static int foo(float); + int foo(int); + int foo(double); + + void test(); + }; + + void A::test() { + // FIXME: This diagnostic is terrible. + int (A::*ptr)(int) = &(A::foo); // expected-error {{cannot initialize a variable of type 'int (test2::A::*)(int)' with an rvalue of type '<overloaded function type>'}} + } +} diff --git a/test/CXX/special/class.dtor/p9.cpp b/test/CXX/special/class.dtor/p9.cpp new file mode 100644 index 0000000..8b76a15 --- /dev/null +++ b/test/CXX/special/class.dtor/p9.cpp @@ -0,0 +1,85 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +typedef typeof(sizeof(int)) size_t; + +// PR7803 +namespace test0 { + class A { + public: + static void operator delete(void *p) {}; + virtual ~A(); + }; + + class B : protected A { + public: + ~B(); + }; + + class C : protected B { + public: + using B::operator delete; + ~C(); + }; + + // Shouldn't have an error. + C::~C() {} +} + +namespace test1 { + class A { + public: + static void operator delete(void *p) {}; // expected-note {{member 'operator delete' declared here}} + virtual ~A(); + }; + + class B : protected A { + public: + static void operator delete(void *, size_t) {}; // expected-note {{member 'operator delete' declared here}} + ~B(); + }; + + class C : protected B { + public: + using A::operator delete; + using B::operator delete; + + ~C(); + }; + + C::~C() {} // expected-error {{multiple suitable 'operator delete' functions in 'C'}} +} + +// ...at the point of definition of a virtual destructor... +namespace test2 { + struct A { + virtual ~A(); + static void operator delete(void*, const int &); + }; + + struct B { + virtual ~B(); + static void operator delete(void*, const int &); // expected-note {{declared here}} + }; + B::~B() {} // expected-error {{no suitable member 'operator delete' in 'B'}} + + struct CBase { virtual ~CBase(); }; + struct C : CBase { // expected-error {{no suitable member 'operator delete' in 'C'}} + static void operator delete(void*, const int &); // expected-note {{declared here}} + }; + void test() { + C c; // expected-note {{first required here}} + } +} + +// PR7346 +namespace test3 { + struct A { + virtual ~A(); + static void operator delete(void*, const int &); + }; + + struct B : A { + virtual ~B() {} + static void operator delete(void*); + }; +} diff --git a/test/CXX/temp/temp.arg/temp.arg.type/p2-cxx0x.cpp b/test/CXX/temp/temp.arg/temp.arg.type/p2-cxx0x.cpp new file mode 100644 index 0000000..6f6286f --- /dev/null +++ b/test/CXX/temp/temp.arg/temp.arg.type/p2-cxx0x.cpp @@ -0,0 +1,20 @@ +// RUN: %clang_cc1 -fsyntax-only -std=c++0x -verify %s + +// C++03 imposed restrictions in this paragraph that were lifted with 0x, so we +// just test that the example given now parses cleanly. + +template <class T> class X { }; +template <class T> void f(T t) { } +struct { } unnamed_obj; +void f() { + struct A { }; + enum { e1 }; + typedef struct { } B; + B b; + X<A> x1; + X<A*> x2; + X<B> x3; + f(e1); + f(unnamed_obj); + f(b); +} diff --git a/test/CXX/temp/temp.decls/temp.friend/p4.cpp b/test/CXX/temp/temp.decls/temp.friend/p4.cpp index 226ac0f..e036cef 100644 --- a/test/CXX/temp/temp.decls/temp.friend/p4.cpp +++ b/test/CXX/temp/temp.decls/temp.friend/p4.cpp @@ -8,3 +8,21 @@ struct X1 { X1<int> x1a; X1<float> x1b; // expected-note {{in instantiation of}} + +template<typename T> +struct X2 { + operator int(); + + friend void f(int x) { } // expected-error{{redefinition}} \ + // expected-note{{previous definition}} +}; + +int array0[sizeof(X2<int>)]; +int array1[sizeof(X2<float>)]; // expected-note{{instantiation of}} + +void g() { + X2<int> xi; + f(xi); + X2<float> xf; + f(xf); +} diff --git a/test/CXX/temp/temp.fct.spec/temp.deduct/sfinae-1.cpp b/test/CXX/temp/temp.fct.spec/temp.deduct/sfinae-1.cpp index f6121b3..6481485 100644 --- a/test/CXX/temp/temp.fct.spec/temp.deduct/sfinae-1.cpp +++ b/test/CXX/temp/temp.fct.spec/temp.deduct/sfinae-1.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 %s +// RUN: %clang_cc1 -verify %s typedef char one_byte; struct two_bytes { char data[2]; }; @@ -15,3 +15,28 @@ struct X { }; int array0[is_class<X>::value? 1 : -1]; int array1[is_class<int>::value? -1 : 1]; int array2[is_class<char[3]>::value? -1 : 1]; + +namespace instantiation_order1 { + template<typename T> + struct it_is_a_trap { + typedef typename T::trap type; + }; + + template<bool, typename T = void> + struct enable_if { + typedef T type; + }; + + template<typename T> + struct enable_if<false, T> { }; + + template<typename T> + typename enable_if<sizeof(T) == 17>::type + f(const T&, typename it_is_a_trap<T>::type* = 0); + + void f(...); + + void test_f() { + f('a'); + } +} diff --git a/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/p6.cpp b/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/p6.cpp index 1b240cc..16b5cd2 100644 --- a/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/p6.cpp +++ b/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/p6.cpp @@ -93,3 +93,21 @@ namespace test1 { invoke(&temp2<int, int>); // expected-error {{no matching function for call to 'invoke'}} } } + +namespace rdar8360106 { + template<typename R, typename T> void f0(R (*)(T), T); + template<typename R, typename T> void f1(R (&)(T) , T); // expected-note{{candidate template ignored: couldn't infer template argument 'R'}} + template<typename R, typename T> void f2(R (* const&)(T), T); // expected-note{{candidate template ignored: couldn't infer template argument 'R'}} + + int g(int); + int g(int, int); + + void h() { + f0(g, 1); + f0(&g, 1); + f1(g, 1); + f1(&g, 1); // expected-error{{no matching function for call to 'f1'}} + f2(g, 1); // expected-error{{no matching function for call to 'f2'}} + f2(&g, 1); + } +} diff --git a/test/CXX/temp/temp.param/p4.cpp b/test/CXX/temp/temp.param/p4.cpp index 5ec402a..809fb20 100644 --- a/test/CXX/temp/temp.param/p4.cpp +++ b/test/CXX/temp/temp.param/p4.cpp @@ -17,4 +17,5 @@ template<typename T, T x> struct A10; template<float f> struct A11; // expected-error{{a non-type template parameter cannot have type 'float'}} -template<void *Ptr> struct A12; // expected-error{{a non-type template parameter cannot have type 'void *'}} +template<void *Ptr> struct A12; +template<int (*IncompleteArrayPtr)[]> struct A13; diff --git a/test/CXX/temp/temp.spec/temp.explicit/p3.cpp b/test/CXX/temp/temp.spec/temp.explicit/p3.cpp index e9758bc..48c42c3 100644 --- a/test/CXX/temp/temp.spec/temp.explicit/p3.cpp +++ b/test/CXX/temp/temp.spec/temp.explicit/p3.cpp @@ -2,8 +2,9 @@ // A declaration of a function template shall be in scope at the point of the // explicit instantiation of the function template. -template<typename T> void f0(T) { } +template<typename T> void f0(T); template void f0(int); // okay +template<typename T> void f0(T) { } // 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 @@ -47,3 +48,27 @@ template X2<int>::X2(); // expected-error{{not an instantiation}} template X2<int>::X2(const X2&); // expected-error{{not an instantiation}} template X2<int>::~X2(); // expected-error{{not an instantiation}} template X2<int> &X2<int>::operator=(const X2<int>&); // expected-error{{not an instantiation}} + + +// A definition of a class template is sufficient to explicitly +// instantiate a member of the class template which itself is not yet defined. +namespace PR7979 { + template <typename T> struct S { + void f(); + static void g(); + static int i; + struct S2 { + void h(); + }; + }; + + template void S<int>::f(); + template void S<int>::g(); + template int S<int>::i; + template void S<int>::S2::h(); + + template <typename T> void S<T>::f() {} + template <typename T> void S<T>::g() {} + template <typename T> int S<T>::i; + template <typename T> void S<T>::S2::h() {} +} |