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]

[patch] Fix PR c++/27447: ICE on invalid ptr-to-member-function


The C++ frontend ICEs since GCC 4.1.0 on the following invalid code snippet:

  void (A::* p)();

bug.cc:1: error: 'A' has not been declared
bug.cc:1: internal compiler error: tree check: expected class 'type',
have 'exceptional' (error_mark) in build_method_type_directly, at tree.c:5172
Please submit a full bug report, [etc.]

The problem is that build_method_type_directly in tree.c doesn't handle
the case where the class is error_mark_node. I could have skipped that
case in build_method_type_directly, but opted to catch this situation
earlier in build_memfn_type in cp/decl2.c.

Bootstrapped and regtested on x86_64-unknown-linux-gnu.
Ok for mainline and 4.1 branch?

Regards,
Volker

:ADDPATCH C++:


2006-05-06  Volker Reichelt  <reichelt@igpm.rwth-aachen.de>

	PR c++/27447
	* decl2.c (build_memfn_type): Skip invalid class types.

===================================================================
--- gcc/gcc/cp/decl2.c	(revision 113549)
+++ gcc/gcc/cp/decl2.c	(working copy)
@@ -114,6 +114,9 @@ build_memfn_type (tree fntype, tree ctype,
   tree raises;
   int type_quals;
 
+  if (ctype == error_mark_node)
+    return error_mark_node;
+
   type_quals = quals & ~TYPE_QUAL_RESTRICT;
   ctype = cp_build_qualified_type (ctype, type_quals);
   fntype = build_method_type_directly (ctype, TREE_TYPE (fntype),
===================================================================

2006-05-06  Volker Reichelt  <reichelt@igpm.rwth-aachen.de>

	PR c++/27447
	* g++.dg/other/ptrmem7.C: New test.

===================================================================
--- gcc/gcc/testsuite/g++.dg/other/ptrmem7.C	2005-08-29 00:25:44 +0200
+++ gcc/gcc/testsuite/g++.dg/other/ptrmem7.C	2006-05-05 18:47:37 +0200
@@ -0,0 +1,4 @@
+// PR c++/27447
+// { dg-do compile }
+
+void (A::* p)();  // { dg-error "declared|token" }
===================================================================



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