aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/ext/instantiate1.C
blob: 90a4af0ec67e035275d027a9ea29918be21c06ba (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// Test that 'extern template' suppresses instantiations.
// { dg-do link }
// { dg-options "" }

template <class T> void f (T) { }
extern template void f (int);

template <class T> struct A {
  void f ();
};
template <class T> void A<T>::f () { }
extern template struct A<int>;

// { dg-error "void f<int>\\(int\\)" "suppressing f<int>" { target *-*-* } "0" }
void test_f_int () { f(42); } 

// { dg-error "A<int>::f\\(\\)" "suppressing A<int>" { target *-*-* } "0" }
void test_A_int_f () { A<int> a; a.f (); }

// { dg-bogus "void f<double>\\(double\\)" "f<double>" { target *-*-* } "0" }
void test_f_double () { f (2.0); }

// { dg-bogus "A<double>::f\\(\\)" "A<double>" { target *-*-* } "0" }
void test_A_double_f () { A<double> b; b.f (); }

int main ()
{
  test_f_int ();
  test_A_int_f ();
  test_f_double ();
  test_A_double_f ();
}