summaryrefslogtreecommitdiffstats
path: root/test/CXX/temp
diff options
context:
space:
mode:
Diffstat (limited to 'test/CXX/temp')
-rw-r--r--test/CXX/temp/temp.arg/temp.arg.type/p2-cxx0x.cpp20
-rw-r--r--test/CXX/temp/temp.decls/temp.friend/p4.cpp18
-rw-r--r--test/CXX/temp/temp.fct.spec/temp.deduct/sfinae-1.cpp27
-rw-r--r--test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/p6.cpp18
-rw-r--r--test/CXX/temp/temp.param/p4.cpp3
-rw-r--r--test/CXX/temp/temp.spec/temp.explicit/p3.cpp27
6 files changed, 110 insertions, 3 deletions
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() {}
+}
OpenPOWER on IntegriCloud