summaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.linespec/cpls.cc
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/testsuite/gdb.linespec/cpls.cc')
-rw-r--r--gdb/testsuite/gdb.linespec/cpls.cc110
1 files changed, 109 insertions, 1 deletions
diff --git a/gdb/testsuite/gdb.linespec/cpls.cc b/gdb/testsuite/gdb.linespec/cpls.cc
index 332a8b5254c..fd396515ed7 100644
--- a/gdb/testsuite/gdb.linespec/cpls.cc
+++ b/gdb/testsuite/gdb.linespec/cpls.cc
@@ -146,7 +146,7 @@ namespace ns_overload3_test
}
}
-/* Code for the template-overload tests. */
+/* Code for the template-function_foo (template parameter completion) tests. */
template <typename T>
struct template_struct
@@ -163,6 +163,113 @@ T template_struct<T>::template_overload_fn (T t)
template_struct<int> template_struct_int;
template_struct<long> template_struct_long;
+/* Code for the template-parameter-overload test. */
+
+template <typename T>
+void foo (T c) {}
+
+template <typename T1, typename T2>
+void foo (T1 a, T2 b) {}
+
+template <typename T>
+struct a
+{
+ void method () {}
+};
+
+template <typename T>
+struct b
+{
+ void method () {}
+};
+
+template <typename T>
+struct c
+{
+ void method () {}
+};
+
+template <typename T>
+struct d
+{
+ void method () {};
+};
+
+template <typename T1, typename T2>
+struct A
+{
+ void method () {}
+};
+
+template <typename T1, typename T2>
+struct B
+{
+ void method () {}
+};
+
+namespace n
+{
+ struct na {};
+ struct nb {};
+
+ template <typename T1, typename T2>
+ struct NA {};
+
+ template <typename T1, typename T2>
+ struct NB {};
+};
+
+static void
+template_function_foo ()
+{
+ a<a<int>> aa;
+ aa.method ();
+ a<b<int>> ab;
+ ab.method ();
+ c<c<int>> cc;
+ cc.method ();
+ c<d<int>> cd;
+ cd.method ();
+ foo (aa);
+ foo (ab);
+ foo (cc);
+ foo (cd);
+ foo (aa, ab);
+ foo (aa, cc);
+ foo (aa, cd);
+
+ A<a<b<int>>, c<d<int>>> Aabcd;
+ Aabcd.method ();
+ foo (Aabcd);
+
+ A<a<b<int>>, a<a<int>>> Aabaa;
+ Aabaa.method ();
+ foo (Aabaa);
+
+ A<a<b<int>>, a<b<int>>> Aabab;
+ Aabab.method ();
+ foo (Aabab);
+
+ B<a<b<int>>, c<d<int>>> Babcd;
+ Babcd.method ();
+ foo (Babcd);
+
+ foo (Aabcd, Babcd);
+ foo (Aabcd, Aabaa);
+ foo (Aabcd, Aabab);
+
+ n::na na;
+ n::nb nb;
+ foo (na, nb);
+ a<n::na> ana;
+ b<n::nb> bnb;
+ foo (ana, bnb);
+
+ n::NA<n::na, n::nb> NAnanb;
+ n::NB<n::na, n::nb> Nbnanb;
+ foo (NAnanb, Nbnanb);
+}
+
/* Code for the template2-ret-type tests. */
template <typename T>
@@ -381,6 +488,7 @@ main ()
template2_struct_inst.template2_fn<int, int> ();
template_struct_int.template_overload_fn(0);
template_struct_long.template_overload_fn(0);
+ template_function_foo ();
return 0;
}