OSDN Git Service

2005-02-21 Douglas Gregor <dgregor@cs.indiana.edu>
authorpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 21 Feb 2005 23:15:35 +0000 (23:15 +0000)
committerpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 21 Feb 2005 23:15:35 +0000 (23:15 +0000)
        * 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

gcc/testsuite/g++.dg/other/cv_func.C [new file with mode: 0644]
gcc/testsuite/g++.dg/template/mem_func_ptr.C [new file with mode: 0644]
gcc/testsuite/g++.dg/template/qualttp20.C
gcc/testsuite/g++.old-deja/g++.pt/ptrmem5.C

diff --git a/gcc/testsuite/g++.dg/other/cv_func.C b/gcc/testsuite/g++.dg/other/cv_func.C
new file mode 100644 (file)
index 0000000..6c9ab1b
--- /dev/null
@@ -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 (file)
index 0000000..bcdda5c
--- /dev/null
@@ -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);
+}
index 5a9c61c..ae20d76 100644 (file)
@@ -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;
index 4b7d5f9..54e975e 100644 (file)
@@ -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;