[cfe-commits] r76740 - in /cfe/trunk/test: CXX/temp/temp.decls/temp.class/temp.mem.func/p1inst.cpp SemaTemplate/example-dynarray.cpp
Douglas Gregor
dgregor at apple.com
Wed Jul 22 08:45:43 PDT 2009
Author: dgregor
Date: Wed Jul 22 10:45:39 2009
New Revision: 76740
URL: http://llvm.org/viewvc/llvm-project?rev=76740&view=rev
Log:
Test template instantiation for member functions of class templates defined
out of line.
Added:
cfe/trunk/test/CXX/temp/temp.decls/temp.class/temp.mem.func/p1inst.cpp
Modified:
cfe/trunk/test/SemaTemplate/example-dynarray.cpp
Added: cfe/trunk/test/CXX/temp/temp.decls/temp.class/temp.mem.func/p1inst.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/temp/temp.decls/temp.class/temp.mem.func/p1inst.cpp?rev=76740&view=auto
==============================================================================
--- cfe/trunk/test/CXX/temp/temp.decls/temp.class/temp.mem.func/p1inst.cpp (added)
+++ cfe/trunk/test/CXX/temp/temp.decls/temp.class/temp.mem.func/p1inst.cpp Wed Jul 22 10:45:39 2009
@@ -0,0 +1,17 @@
+// RUN: clang-cc -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}}
+}
\ No newline at end of file
Modified: cfe/trunk/test/SemaTemplate/example-dynarray.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/example-dynarray.cpp?rev=76740&r1=76739&r2=76740&view=diff
==============================================================================
--- cfe/trunk/test/SemaTemplate/example-dynarray.cpp (original)
+++ cfe/trunk/test/SemaTemplate/example-dynarray.cpp Wed Jul 22 10:45:39 2009
@@ -43,30 +43,8 @@
unsigned size() const { return Last - Start; }
unsigned capacity() const { return End - Start; }
- void push_back(const T& value) {
- if (Last == End) {
- unsigned NewCapacity = capacity() * 2;
- if (NewCapacity == 0)
- NewCapacity = 4;
-
- T* NewStart = (T*)malloc(sizeof(T) * NewCapacity);
-
- unsigned Size = size();
- for (unsigned I = 0; I != Size; ++I)
- new (NewStart + I) T(Start[I]);
-
- // FIXME: destruct old values
- free(Start);
-
- Start = NewStart;
- Last = Start + Size;
- End = Start + NewCapacity;
- }
-
- new (Last) T(value);
- ++Last;
- }
-
+ void push_back(const T& value);
+
void pop_back() {
// FIXME: destruct old value
--Last;
@@ -108,6 +86,31 @@
T* Start, *Last, *End;
};
+template<typename T>
+void dynarray<T>::push_back(const T& value) {
+ if (Last == End) {
+ unsigned NewCapacity = capacity() * 2;
+ if (NewCapacity == 0)
+ NewCapacity = 4;
+
+ T* NewStart = (T*)malloc(sizeof(T) * NewCapacity);
+
+ unsigned Size = size();
+ for (unsigned I = 0; I != Size; ++I)
+ new (NewStart + I) T(Start[I]);
+
+ // FIXME: destruct old values
+ free(Start);
+
+ Start = NewStart;
+ Last = Start + Size;
+ End = Start + NewCapacity;
+ }
+
+ new (Last) T(value);
+ ++Last;
+}
+
struct Point {
Point() { x = y = z = 0.0; }
Point(const Point& other) : x(other.x), y(other.y), z(other.z) { }
More information about the cfe-commits
mailing list