diff options
author | Douglas Gregor <dgregor@cs.indiana.edu> | 2005-02-21 23:15:35 +0000 |
---|---|---|
committer | Paolo Carlini <paolo@gcc.gnu.org> | 2005-02-21 23:15:35 +0000 |
commit | 84bafc8d191e31d205d9c33cd0dc91cf9910cab3 (patch) | |
tree | af3594b665e83e53542a937dca36da67827c4609 /gcc/testsuite | |
parent | 9804209d324be049840389053e370d5a1ce51550 (diff) | |
download | gcc-84bafc8d191e31d205d9c33cd0dc91cf9910cab3.zip gcc-84bafc8d191e31d205d9c33cd0dc91cf9910cab3.tar.gz gcc-84bafc8d191e31d205d9c33cd0dc91cf9910cab3.tar.bz2 |
cv_func.C: New test.
2005-02-21 Douglas Gregor <dgregor@cs.indiana.edu>
* g++.dg/other/cv_func.C: New test.
* g++.dg/template/mem_func_ptr.C: New test.
* g++.dg/template/qualttp20.C: We now get the xfail'd warning
when we are being pedantic; we expect this test to pass now.
* g++.old-deja/g++.pt/ptrmem5.C: We no longer receive a bogus
error here.
From-SVN: r95357
Diffstat (limited to 'gcc/testsuite')
-rw-r--r-- | gcc/testsuite/g++.dg/other/cv_func.C | 32 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/template/mem_func_ptr.C | 57 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/template/qualttp20.C | 3 | ||||
-rw-r--r-- | gcc/testsuite/g++.old-deja/g++.pt/ptrmem5.C | 2 |
4 files changed, 92 insertions, 2 deletions
diff --git a/gcc/testsuite/g++.dg/other/cv_func.C b/gcc/testsuite/g++.dg/other/cv_func.C new file mode 100644 index 0000000..6c9ab1b --- /dev/null +++ b/gcc/testsuite/g++.dg/other/cv_func.C @@ -0,0 +1,32 @@ +// { dg-do compile } +// { dg-options "-pedantic -pedantic-errors" } +typedef int FIC(int) const; +typedef int FI(int); + +FIC f; // { dg-error "qualified" } +// { dg-error "ignoring" "" { target *-*-* } 6 } +struct S { + FIC f; // OK + + const FI g; // { dg-error "qualifier" } + + int h(int) const; + +}; +FIC S::*pm = &S::f; +const FI S::*pm2 = &S::f; // { dg-error "qualifier" } +// { dg-error "cannot convert" "" { target *-*-* } 17 } +const FIC S::*pm3 = &S::f; // { dg-error "qualifier" } + +int S::f(int) const +{ + return 17; +} + + +int foo(float) const // { dg-error "qualifier" } +{ + return 0; +} + +int bar(float) volatile; // { dg-error "qualifier" } diff --git a/gcc/testsuite/g++.dg/template/mem_func_ptr.C b/gcc/testsuite/g++.dg/template/mem_func_ptr.C new file mode 100644 index 0000000..bcdda5c --- /dev/null +++ b/gcc/testsuite/g++.dg/template/mem_func_ptr.C @@ -0,0 +1,57 @@ +// { dg-do compile } +template<typename T> struct takes_member_ptr; +template<typename T, typename Class> struct takes_member_ptr<T Class::*> {}; + +template<typename T, typename Class> +void fun_takes_member_ptr(T Class::*) {} + + +template<typename T> struct order_member_ptrs; +template<typename T, typename Class> struct order_member_ptrs<T Class::*> {}; +template<typename R, typename T1, typename Class> + struct order_member_ptrs<R (Class::*)(T1)> + { + typedef int type; + }; + +template<typename R, typename T1, typename Class> + struct order_member_ptrs<R (Class::*)(T1) const> + { + typedef int c_type; + }; + +template<typename R, typename T1, typename Class> + struct order_member_ptrs<R (Class::*)(T1) volatile> + { + typedef int v_type; + }; + +template<typename R, typename T1, typename Class> + struct order_member_ptrs<R (Class::*)(T1) const volatile> + { + typedef int cv_type; + }; + + +struct X { + void bar(float) {} + void bar_c(float) const {} + void bar_v(float) volatile {} + void bar_cv(float) const volatile {} +}; + +void foo() +{ + sizeof(takes_member_ptr<void (X::*)(float)>); + sizeof(takes_member_ptr<void (X::*)(float) const>); + sizeof(takes_member_ptr<void (X::*)(float) volatile>); + sizeof(takes_member_ptr<void (X::*)(float) const volatile>); + sizeof(order_member_ptrs<void (X::*)(float)>::type); + sizeof(order_member_ptrs<void (X::*)(float) const>::c_type); + sizeof(order_member_ptrs<void (X::*)(float) volatile>::v_type); + sizeof(order_member_ptrs<void (X::*)(float) const volatile>::cv_type); + fun_takes_member_ptr(&X::bar); + fun_takes_member_ptr(&X::bar_c); + fun_takes_member_ptr(&X::bar_v); + fun_takes_member_ptr(&X::bar_cv); +} diff --git a/gcc/testsuite/g++.dg/template/qualttp20.C b/gcc/testsuite/g++.dg/template/qualttp20.C index 5a9c61c..ae20d762 100644 --- a/gcc/testsuite/g++.dg/template/qualttp20.C +++ b/gcc/testsuite/g++.dg/template/qualttp20.C @@ -1,4 +1,5 @@ // { dg-do compile } +// { dg-options "-pedantic -pedantic-errors" } // Copyright (C) 2001 Free Software Foundation, Inc. // Contributed by Nathan Sidwell 15 Dec 2001 <nathan@codesourcery.com> @@ -16,7 +17,7 @@ struct AS template <typename T> struct B1 : T { typedef typename T::L __restrict__ r;// { dg-error "'__restrict__' qualifiers cannot" "" } - typedef typename T::myT __restrict__ p;// { dg-warning "ignoring '__restrict__'" "" { xfail *-*-* } } + typedef typename T::myT __restrict__ p;// { dg-error "ignoring '__restrict__'" } // The following are DR 295 dependent typedef typename T::myT volatile *myvolatile; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/ptrmem5.C b/gcc/testsuite/g++.old-deja/g++.pt/ptrmem5.C index 4b7d5f9..54e975e 100644 --- a/gcc/testsuite/g++.old-deja/g++.pt/ptrmem5.C +++ b/gcc/testsuite/g++.old-deja/g++.pt/ptrmem5.C @@ -14,4 +14,4 @@ struct Null { int *pd = NULL; int (*pf)() = NULL; int Null::*pmd = NULL; -int (Null::*pmf)() = NULL; // { dg-bogus "" "" { xfail *-*-* } } - cannot convert - +int (Null::*pmf)() = NULL; |