diff options
| author | paolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-02-21 23:15:35 +0000 |
|---|---|---|
| committer | paolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-02-21 23:15:35 +0000 |
| commit | 9d42e8447f95c60e101f4f62e9698d303ddb17c2 (patch) | |
| tree | af3594b665e83e53542a937dca36da67827c4609 | |
| parent | 11ef5c280ff39d33ee2e35661f850af5d5603e3e (diff) | |
| download | ppe42-gcc-9d42e8447f95c60e101f4f62e9698d303ddb17c2.tar.gz ppe42-gcc-9d42e8447f95c60e101f4f62e9698d303ddb17c2.zip | |
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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@95357 138bc75d-0d04-0410-961f-82ee72b054a4
| -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 00000000000..6c9ab1bc2f7 --- /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 00000000000..bcdda5ca69d --- /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 5a9c61c4304..ae20d762902 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 4b7d5f9f572..54e975edab6 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; |

