1 // { dg-do assemble  }
2 
3 // Copyright (C) 1999 Free Software Foundation, Inc.
4 // Contributed by Nathan Sidwell 21 May 1999 <nathan@acm.org>
5 
6 // Template deduction and type unification should not issue diagnostics when
7 // they're trying to see if it's possible.  Here deduction fails in some cases
8 // because you cant cv qualify a function type.
9 
fn()10 template<class T> void fn(){} // A
11 
fn(T const *)12 template<class T> void fn(T const *){} // B
13 
14 // these next two specializations need to know if they're specializing A or B.
15 // They specialize A, because they can't instantiate B.
16 
17 template<> void fn<int &>() {} // ok, specialize A
18 
19 template<> void fn<void ()>() {} // ok, specialize A
20 
21 // now make sure we moan when we really should
foo(T const *)22 template<class T> void foo(T const *){} // { dg-error "pointer to reference" }
23 
f()24 void f()
25 {
26   foo<int &>(); // { dg-error "" } attempt to build int & const *
27   // { dg-message "candidate" "candidate note" { target *-*-* } 26 }
28   foo<void ()>(); // { dg-error "" } attempt to build void (const *)()
29   // { dg-message "candidate" "candidate note" { target *-*-* } 28 }
30 }
31 
32 typedef void (*Fptr)();
33 
34 template<class T> void PV(Fptr const &, T const * const &);
35 template<class T1, class T2> void PV(T1 const * const &, T2 const * const &);
36 
baz()37 void baz()
38 {
39   void *t;
40   PV(&baz, t);
41 }
42