summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.old-deja/g++.brendan/crash7.C
diff options
context:
space:
mode:
authorupstream source tree <ports@midipix.org>2015-03-15 20:14:05 -0400
committerupstream source tree <ports@midipix.org>2015-03-15 20:14:05 -0400
commit554fd8c5195424bdbcabf5de30fdc183aba391bd (patch)
tree976dc5ab7fddf506dadce60ae936f43f58787092 /gcc/testsuite/g++.old-deja/g++.brendan/crash7.C
downloadcbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.bz2
cbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.xz
obtained gcc-4.6.4.tar.bz2 from upstream website;upstream
verified gcc-4.6.4.tar.bz2.sig; imported gcc-4.6.4 source tree from verified upstream tarball. downloading a git-generated archive based on the 'upstream' tag should provide you with a source tree that is binary identical to the one extracted from the above tarball. if you have obtained the source via the command 'git clone', however, do note that line-endings of files in your working directory might differ from line-endings of the respective files in the upstream repository.
Diffstat (limited to 'gcc/testsuite/g++.old-deja/g++.brendan/crash7.C')
-rw-r--r--gcc/testsuite/g++.old-deja/g++.brendan/crash7.C48
1 files changed, 48 insertions, 0 deletions
diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash7.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash7.C
new file mode 100644
index 000000000..44339ea2c
--- /dev/null
+++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash7.C
@@ -0,0 +1,48 @@
+// { dg-do assemble }
+// GROUPS passed templates
+
+template<class T>
+class Vector
+{
+ int sz;
+ T *v;
+public:
+ Vector (int s) : sz (s) { v = new T[sz]; }
+ ~Vector () { delete[] v; }
+ T &operator[] (int i) { return v[i]; }
+ int size () { return sz; }
+};
+
+template<class T>// { dg-error "" } previous definition of T
+struct Comparator
+{
+ typedef T T;// { dg-error "" } use of template type T in typedef to T
+ static int lessthan (T &a, T &b) { return a < b; }
+};
+
+template<class Comp>
+struct Sort
+{
+ static void sort (Vector<Comp::T> &);// { dg-error "" } use of bad T
+};
+
+template<class Comp>
+void Sort<Comp>::sort (Vector<Comp::T> &v)// { dg-error "" } use of bad T
+{
+ int n = v.size ();
+
+ for (int i = 0; i < n - 1; i++)
+ for (int j = n - 1; i < j; j--)
+ if (Comp::lessthan (v[j], v[j - 1]))
+ {
+ typename Comp::T temp = v[j];
+ v[j] = v[j - 1];
+ v[j - 1] = temp;
+ }
+}
+
+void
+f (Vector<int> &vi)
+{
+ Sort<Comparator<int> >::sort (vi); // { dg-error "'sort' is not a member of 'Sort<Comparator<int> >'" }
+}