This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

C++ PATCH to cxx-pretty-print.c for c++/43868 (ice with -g)


For some reason the code for printing a PMF was in pp_cxx_decl_specifier_seq which meant that code trying to just print a type didn't hit it. Fixed thus.

Tested x86_64-pc-linux-gnu, applied to trunk.

commit 8c1b20bd9279d60e4e3e4a17c2a1dd09f506ef71
Author: Jason Merrill <jason@redhat.com>
Date:   Fri Apr 30 15:29:47 2010 -0400

    	PR c++/43868
    	* cxx-pretty-print.c (pp_cxx_decl_specifier_seq): Move pmf handling...
    	(pp_cxx_type_specifier_seq): ...here.

diff --git a/gcc/cp/cxx-pretty-print.c b/gcc/cp/cxx-pretty-print.c
index 5ef84fe..7b92272 100644
--- a/gcc/cp/cxx-pretty-print.c
+++ b/gcc/cp/cxx-pretty-print.c
@@ -1170,16 +1170,6 @@ pp_cxx_decl_specifier_seq (cxx_pretty_printer *pp, tree t)
       pp_cxx_decl_specifier_seq (pp, TREE_TYPE (t));
       break;
 
-    case RECORD_TYPE:
-      if (TYPE_PTRMEMFUNC_P (t))
-	{
-	  tree pfm = TYPE_PTRMEMFUNC_FN_TYPE (t);
-	  pp_cxx_decl_specifier_seq (pp, TREE_TYPE (TREE_TYPE (pfm)));
-	  pp_cxx_whitespace (pp);
-	  pp_cxx_ptr_operator (pp, t);
-	}
-      break;
-
     case FUNCTION_DECL:
       /* Constructors don't have return types.  And conversion functions
 	 do not have a type-specifier in their return types.  */
@@ -1275,6 +1265,17 @@ pp_cxx_type_specifier_seq (cxx_pretty_printer *pp, tree t)
       pp_cxx_right_paren (pp);
       break;
 
+    case RECORD_TYPE:
+      if (TYPE_PTRMEMFUNC_P (t))
+	{
+	  tree pfm = TYPE_PTRMEMFUNC_FN_TYPE (t);
+	  pp_cxx_decl_specifier_seq (pp, TREE_TYPE (TREE_TYPE (pfm)));
+	  pp_cxx_whitespace (pp);
+	  pp_cxx_ptr_operator (pp, t);
+	  break;
+	}
+      /* else fall through */
+
     default:
       if (!(TREE_CODE (t) == FUNCTION_DECL && DECL_CONSTRUCTOR_P (t)))
 	pp_c_specifier_qualifier_list (pp_c_base (pp), t);
diff --git a/gcc/testsuite/g++.dg/template/ptrmem21.C b/gcc/testsuite/g++.dg/template/ptrmem21.C
new file mode 100644
index 0000000..c30fa38
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/ptrmem21.C
@@ -0,0 +1,37 @@
+// PR c++/43868
+// { dg-options "-g" }
+
+struct Foo
+{
+    virtual void do_something() = 0;
+};
+
+template <typename T>
+struct Foo_impl;
+
+template <typename R, typename O>
+struct Foo_impl<R (O::*)() const> : public Foo
+{
+    struct Helper
+    {
+        typedef int Some_type;
+        operator Some_type () const { return 0; }
+        Helper( R (O::*)() const) {}
+    };
+
+    void do_something() {  Helper( 0); };
+};
+
+void register_foo_internal( Foo*) {};
+
+template <typename TT>
+void register_foo( TT) { register_foo_internal( new Foo_impl<TT>()); }
+
+struct Bar
+{
+};
+
+void setup()
+{
+    register_foo( (int (Bar::*) () const) 0);
+}

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]