summaryrefslogtreecommitdiff
path: root/clang/test/CXX/temp/temp.decls/temp.class/temp.mem.func
diff options
context:
space:
mode:
Diffstat (limited to 'clang/test/CXX/temp/temp.decls/temp.class/temp.mem.func')
-rw-r--r--clang/test/CXX/temp/temp.decls/temp.class/temp.mem.func/p1-retmem.cpp28
-rw-r--r--clang/test/CXX/temp/temp.decls/temp.class/temp.mem.func/p1.cpp100
-rw-r--r--clang/test/CXX/temp/temp.decls/temp.class/temp.mem.func/p1inst.cpp17
-rw-r--r--clang/test/CXX/temp/temp.decls/temp.class/temp.mem.func/pr5056.cpp17
4 files changed, 162 insertions, 0 deletions
diff --git a/clang/test/CXX/temp/temp.decls/temp.class/temp.mem.func/p1-retmem.cpp b/clang/test/CXX/temp/temp.decls/temp.class/temp.mem.func/p1-retmem.cpp
new file mode 100644
index 0000000..4c05c62
--- /dev/null
+++ b/clang/test/CXX/temp/temp.decls/temp.class/temp.mem.func/p1-retmem.cpp
@@ -0,0 +1,28 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+template<typename T> struct X1 { };
+
+template<typename T>
+struct X0 {
+ typedef int size_type;
+ typedef T value_type;
+
+ size_type f0() const;
+ value_type *f1();
+ X1<value_type*> f2();
+};
+
+template<typename T>
+typename X0<T>::size_type X0<T>::f0() const {
+ return 0;
+}
+
+template<typename U>
+typename X0<U>::value_type *X0<U>::f1() {
+ return 0;
+};
+
+template<typename U>
+X1<typename X0<U>::value_type*> X0<U>::f2() {
+ return 0;
+};
diff --git a/clang/test/CXX/temp/temp.decls/temp.class/temp.mem.func/p1.cpp b/clang/test/CXX/temp/temp.decls/temp.class/temp.mem.func/p1.cpp
new file mode 100644
index 0000000..1764563
--- /dev/null
+++ b/clang/test/CXX/temp/temp.decls/temp.class/temp.mem.func/p1.cpp
@@ -0,0 +1,100 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+template<typename T, typename U> // expected-note{{previous template}}
+class X0 {
+public:
+ typedef int size_type;
+
+ X0(int);
+ ~X0();
+
+ void f0(const T&, const U&);
+
+ T& operator[](int i) const;
+
+ void f1(size_type) const;
+ void f2(size_type) const;
+ void f3(size_type) const;
+ void f4() ;
+
+ operator T*() const;
+
+ T value;
+};
+
+template<typename T, typename U>
+void X0<T, U>::f0(const T&, const U&) { // expected-note{{previous definition}}
+}
+
+template<class X, class Y>
+X& X0<X, Y>::operator[](int i) const {
+ (void)i;
+ return value;
+}
+
+template<class X, class Y>
+void X0<X, Y>::f1(int) const { }
+
+template<class X, class Y>
+void X0<X, Y>::f2(size_type) const { }
+
+template<class X, class Y, class Z> // expected-error{{too many template parameters}}
+void X0<X, Y>::f3(size_type) const {
+}
+
+template<class X, class Y>
+void X0<Y, X>::f4() { } // expected-error{{does not refer}}
+
+// FIXME: error message should probably say, "redefinition of 'X0<T, U>::f0'"
+// rather than just "redefinition of 'f0'"
+template<typename T, typename U>
+void X0<T, U>::f0(const T&, const U&) { // expected-error{{redefinition}}
+}
+
+// Test out-of-line constructors, destructors
+template<typename T, typename U>
+X0<T, U>::X0(int x) : value(x) { }
+
+template<typename T, typename U>
+X0<T, U>::~X0() { }
+
+// Test out-of-line conversion functions.
+template<typename T, typename U>
+X0<T, U>::operator T*() const {
+ return &value;
+}
+
+namespace N { template <class X> class A {void a();}; }
+namespace N { template <class X> void A<X>::a() {} }
+
+// PR5566
+template<typename T>
+struct X1 {
+ template<typename U>
+ struct B { void f(); };
+};
+
+template<typename T>
+template<typename U>
+void X1<T>::template B<U>::f() { }
+
+// PR5527
+template <template <class> class T>
+class X2 {
+ template <class F>
+ class Bar {
+ void Func();
+ };
+};
+
+template <template <class> class T>
+template <class F>
+void X2<T>::Bar<F>::Func() {}
+
+// PR5528
+template <template <class> class T>
+class X3 {
+ void F();
+};
+
+template <template <class> class T>
+void X3<T>::F() {}
diff --git a/clang/test/CXX/temp/temp.decls/temp.class/temp.mem.func/p1inst.cpp b/clang/test/CXX/temp/temp.decls/temp.class/temp.mem.func/p1inst.cpp
new file mode 100644
index 0000000..f09faa9
--- /dev/null
+++ b/clang/test/CXX/temp/temp.decls/temp.class/temp.mem.func/p1inst.cpp
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// Test instantiation of member functions of class templates defined out-of-line
+template<typename T, typename U>
+struct X0 {
+ void f(T *t, const U &u);
+ void f(T *);
+};
+
+template<typename T, typename U>
+void X0<T, U>::f(T *t, const U &u) {
+ *t = u; // expected-error{{not assignable}}
+}
+
+void test_f(X0<float, int> xfi, X0<void, int> xvi, float *fp, void *vp, int i) {
+ xfi.f(fp, i);
+ xvi.f(vp, i); // expected-note{{instantiation}}
+}
diff --git a/clang/test/CXX/temp/temp.decls/temp.class/temp.mem.func/pr5056.cpp b/clang/test/CXX/temp/temp.decls/temp.class/temp.mem.func/pr5056.cpp
new file mode 100644
index 0000000..70c9c70
--- /dev/null
+++ b/clang/test/CXX/temp/temp.decls/temp.class/temp.mem.func/pr5056.cpp
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+extern "C" void * malloc(int);
+
+template <typename T> struct A {
+ void *malloc(int);
+};
+
+template <typename T>
+inline void *A<T>::malloc(int)
+{
+ return 0;
+}
+
+void f() {
+ malloc(10);
+}