diff options
Diffstat (limited to 'gcc/testsuite/g++.dg/other/ptrmem10.C')
-rw-r--r-- | gcc/testsuite/g++.dg/other/ptrmem10.C | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/gcc/testsuite/g++.dg/other/ptrmem10.C b/gcc/testsuite/g++.dg/other/ptrmem10.C new file mode 100644 index 000000000..bc386ed56 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/ptrmem10.C @@ -0,0 +1,30 @@ +// Contributed by Dodji Seketeli <dodji@redhat.com> +// Origin PR c++/37093 + +template <class C, void (C::*M) ()> +static +void foo(void *obj) // { dg-message "note" } +{ + C *p = static_cast<C*>(obj); + (p->*M)(); +} + +template <class C> +static void +bar(C *c, void (C::*m) ()) +{ + foo<C,m>((void *)c);// { dg-error "(not a valid template arg|pointer-to-member|no matching fun)" } + // { dg-message "candidate" "candidate note" { target *-*-* } 16 } +} + +struct S +{ + void baz () {} +}; + +int +main () +{ + S a; + bar(&a, &S::baz); +} |