summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/template
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite/g++.dg/template')
-rw-r--r--gcc/testsuite/g++.dg/template/arg2.C2
-rw-r--r--gcc/testsuite/g++.dg/template/crash56.C4
-rw-r--r--gcc/testsuite/g++.dg/template/error26.C2
-rw-r--r--gcc/testsuite/g++.dg/template/explicit-args2.C38
-rw-r--r--gcc/testsuite/g++.dg/template/explicit-args3.C12
-rw-r--r--gcc/testsuite/g++.dg/template/local4.C2
-rw-r--r--gcc/testsuite/g++.dg/template/nested3.C7
-rw-r--r--gcc/testsuite/g++.dg/template/overload11.C27
-rw-r--r--gcc/testsuite/g++.dg/template/partial6.C31
-rw-r--r--gcc/testsuite/g++.dg/template/scope3.C15
-rw-r--r--gcc/testsuite/g++.dg/template/sfinae15.C23
-rw-r--r--gcc/testsuite/g++.dg/template/sfinae16.C34
-rw-r--r--gcc/testsuite/g++.dg/template/sizeof12.C19
-rw-r--r--gcc/testsuite/g++.dg/template/spec35.C2
14 files changed, 208 insertions, 10 deletions
diff --git a/gcc/testsuite/g++.dg/template/arg2.C b/gcc/testsuite/g++.dg/template/arg2.C
index 1314b258fef..9fb7a68cc78 100644
--- a/gcc/testsuite/g++.dg/template/arg2.C
+++ b/gcc/testsuite/g++.dg/template/arg2.C
@@ -10,5 +10,5 @@ template <typename T> class X {};
void fn ()
{
class L {};
- X<L> f;
+ X<L> f; // { dg-error "uses local type|trying to instantiate|no type|invalid type" "" }
}
diff --git a/gcc/testsuite/g++.dg/template/crash56.C b/gcc/testsuite/g++.dg/template/crash56.C
index 1efa3500d8a..03bddf42a57 100644
--- a/gcc/testsuite/g++.dg/template/crash56.C
+++ b/gcc/testsuite/g++.dg/template/crash56.C
@@ -7,10 +7,10 @@
namespace N
{
- struct A { A (A*); }; // { dg-error "lookup finds" "" }
+ struct A { A (A*); };
}
template<typename T> void g (N::A *p)
{
- (void) A (p); // { dg-error "in call" "" }
+ (void) A (p); // { dg-message "" "" }
}
diff --git a/gcc/testsuite/g++.dg/template/error26.C b/gcc/testsuite/g++.dg/template/error26.C
index 7545762bf34..cd8d46d1e4f 100644
--- a/gcc/testsuite/g++.dg/template/error26.C
+++ b/gcc/testsuite/g++.dg/template/error26.C
@@ -2,4 +2,4 @@
template<typename> struct A;
-template<typename T> void foo (A<&T::template i>); // { dg-error "T::template i|mismatch|& T::i" }
+template<typename T> void foo (A<&T::template i>); // { dg-error "T:: ?template i|mismatch|& T::i" }
diff --git a/gcc/testsuite/g++.dg/template/explicit-args2.C b/gcc/testsuite/g++.dg/template/explicit-args2.C
new file mode 100644
index 00000000000..cd53b456dcc
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/explicit-args2.C
@@ -0,0 +1,38 @@
+// PR c++/37177
+// { dg-options -std=c++0x }
+
+namespace N1
+{
+ template<class T> bool foo();
+}
+
+struct S
+{
+ template <class T>
+ static bool foo();
+
+ template <class T>
+ bool bar();
+};
+
+template<class T> bool foo();
+
+int main()
+{
+ (void)(&S::bar<int>);
+ decltype(&S::bar<int>) a;
+
+ (void*)(&S::foo<int>);
+ (void)(&S::foo<int>);
+ decltype(&S::foo<int>) b;
+
+ (void*)(&N1::foo<int>);
+ (void)(&N1::foo<int>);
+ decltype(&N1::foo<int>) c;
+
+ (void*)(&foo<int>);
+ (void)(&foo<int>);
+ decltype(&foo<int>) d;
+
+ &foo<int> == 0;
+}
diff --git a/gcc/testsuite/g++.dg/template/explicit-args3.C b/gcc/testsuite/g++.dg/template/explicit-args3.C
new file mode 100644
index 00000000000..c095e6688fd
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/explicit-args3.C
@@ -0,0 +1,12 @@
+// PR c++/37177
+
+template <class T>
+struct A { };
+
+template <class T>
+void operator+(T, T); // { dg-error "class or enum" }
+
+int main()
+{
+ operator+<int>; // { dg-error "cannot resolve" }
+}
diff --git a/gcc/testsuite/g++.dg/template/local4.C b/gcc/testsuite/g++.dg/template/local4.C
index 41e2370c395..cfa37364975 100644
--- a/gcc/testsuite/g++.dg/template/local4.C
+++ b/gcc/testsuite/g++.dg/template/local4.C
@@ -4,5 +4,5 @@ template <typename T> void foo() {}
int main () {
struct S {};
- foo<S> ();
+ foo<S> (); // { dg-error "match" }
}
diff --git a/gcc/testsuite/g++.dg/template/nested3.C b/gcc/testsuite/g++.dg/template/nested3.C
index 1ae4bf7647d..5652e178a70 100644
--- a/gcc/testsuite/g++.dg/template/nested3.C
+++ b/gcc/testsuite/g++.dg/template/nested3.C
@@ -5,13 +5,13 @@ class A {
int _k;
};
T1 _t1;
- T2 _t2; // { dg-message "instantiated" }
+ T2 _t2;
};
template <class U>
-class B { // { dg-error "declaration" }
+class B {
class SubB1 {
- B _i; // { dg-error "incomplete type" }
+ B _i;
};
class SubB2 {
@@ -19,7 +19,6 @@ class B { // { dg-error "declaration" }
};
A<U,SubB1>::SubA<SubB2> _a; // { dg-error "not a base type" "not base" }
// { dg-message "note" "note" { target *-*-* } 20 }
- // { dg-message "instantiated" "inst" { target *-*-* } 20 }
// { dg-error "non-template" "non-template" { target *-*-* } 20 }
};
diff --git a/gcc/testsuite/g++.dg/template/overload11.C b/gcc/testsuite/g++.dg/template/overload11.C
new file mode 100644
index 00000000000..d7b0a7c9f1c
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/overload11.C
@@ -0,0 +1,27 @@
+// PR c++/39413
+// We don't need to instantiate Wrapper<int> to check the
+// foo(const Thingy&) overload.
+
+template <class T> struct Incomplete;
+
+template <typename T> class Wrapper
+{
+ Incomplete<T> i;
+};
+
+template <typename T> struct Thingy
+{
+ Thingy();
+ Thingy(const Wrapper<T>& v);
+
+ template <typename X> void foo(const Thingy<X>&);
+ void foo(const Thingy&);
+};
+
+int main()
+{
+ Thingy<int> ap1;
+ Thingy<float> bp1;
+
+ ap1.foo(bp1);
+}
diff --git a/gcc/testsuite/g++.dg/template/partial6.C b/gcc/testsuite/g++.dg/template/partial6.C
new file mode 100644
index 00000000000..80bbfe3c138
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/partial6.C
@@ -0,0 +1,31 @@
+// PR c++/41703
+// The second GetAllSize template is more specialized because even though
+// deduction on each parameter type succeeds, we never get a template
+// argument for its X to make it match the first template.
+
+template <typename T, int (T::*)() const>
+struct TSizeEnabler
+{
+ typedef T TClass;
+};
+
+template <typename X>
+int
+GetAllSize(const X &Var)
+{ return sizeof(Var); }
+
+template <typename X>
+int
+GetAllSize(const typename TSizeEnabler<X, &X::func>::TClass &Var)
+{ return Var.func(); }
+
+struct H
+{
+ int func() const;
+};
+
+int main()
+{
+ H b;
+ return GetAllSize< H >(b);
+}
diff --git a/gcc/testsuite/g++.dg/template/scope3.C b/gcc/testsuite/g++.dg/template/scope3.C
new file mode 100644
index 00000000000..c191c79c5ce
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/scope3.C
@@ -0,0 +1,15 @@
+// PR c++/41038
+
+struct S
+{
+ int size() const;
+};
+
+template<typename T>
+struct Packer
+{
+ int foo() {
+ return Packer::var.size();
+ }
+ const S& var;
+};
diff --git a/gcc/testsuite/g++.dg/template/sfinae15.C b/gcc/testsuite/g++.dg/template/sfinae15.C
new file mode 100644
index 00000000000..27bce255db3
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/sfinae15.C
@@ -0,0 +1,23 @@
+// PR c++/40944
+// { dg-options -std=c++0x }
+// { dg-do run }
+
+template<typename T>
+struct make { static T&& it(); };
+
+void (*pf)(int&) = 0;
+
+template< typename T >
+int bar(T const& x,
+ decltype( pf(make<T const&>::it()) )* = 0 // SFINAE!
+ ) {
+ return 1;
+}
+
+int bar(...) {
+ return 0;
+}
+
+int main() {
+ return bar(42);
+}
diff --git a/gcc/testsuite/g++.dg/template/sfinae16.C b/gcc/testsuite/g++.dg/template/sfinae16.C
new file mode 100644
index 00000000000..5ea564c9f86
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/sfinae16.C
@@ -0,0 +1,34 @@
+// PR c++/41927
+// { dg-options "-std=c++0x -Wall" }
+
+// We were getting a spurious ||/&& warning about the enable_if with the
+// source position of d1.
+
+template<typename Tp>
+ struct is_int
+ { static const bool value = true; };
+
+template<bool, typename Tp = void>
+ struct enable_if
+ { };
+
+template<typename Tp>
+ struct enable_if<true, Tp>
+ { typedef Tp type; };
+
+template<typename Rep>
+ struct duration
+ {
+ duration() { }
+
+ template<typename Rep2, typename = typename
+ enable_if<false || (true && is_int<Rep2>::value)>::type>
+ duration(const duration<Rep2>&) { }
+ };
+
+int main()
+{
+ duration<int> d0;
+ duration<int> d1 = d0;
+}
+
diff --git a/gcc/testsuite/g++.dg/template/sizeof12.C b/gcc/testsuite/g++.dg/template/sizeof12.C
new file mode 100644
index 00000000000..e165d2aab78
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/sizeof12.C
@@ -0,0 +1,19 @@
+// Contributed by Dodji Seketeli <dodji@redhat.com>
+// Origin PR c++/41863
+
+template<int X>
+struct Bar
+{
+};
+
+template<typename T>
+class Foo
+{
+ T m_foo;
+
+ void
+ crash()
+ {
+ Bar<sizeof(m_foo)> bar;
+ }
+};
diff --git a/gcc/testsuite/g++.dg/template/spec35.C b/gcc/testsuite/g++.dg/template/spec35.C
index cae33ed3d1f..709ece5dd90 100644
--- a/gcc/testsuite/g++.dg/template/spec35.C
+++ b/gcc/testsuite/g++.dg/template/spec35.C
@@ -24,6 +24,6 @@ void instantiator ()
// { dg-final { scan-assembler-not ".glob(a|)l\[\t \]*_?_Z2f1IiEvT_" } }
f1(0); // Expected to have static linkage
- // { dg-final { scan-assembler ".weak(_definition)?\[\t \]*_?_Z2f2IiEvT_" } }
+ // { dg-final { scan-assembler ".weak(_definition)?\[\t \]*_?_Z2f2IiEvT_" { target { ! { *-*-mingw* *-*-cygwin } } } } }
f2(0); // Expected to have weak global linkage
}