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++/37647: ICE with invalid use of constructor


Hi all.

The following invalid snippet triggers an ICE with 4.3 and 4.4

=== cut here ===
struct A
{
    A() { void A(); }
};
=== cut here ===


The problem is that DECL_CONSTRUCTOR is set for "void A();", which implies that we call 'grok_ctor_properties' itself calling 'copy_fn_p', that asserts that the passed declaration "has" DECL_FUNCTION_MEMBER_P, which is obviously not the case here.

This regression has been introduced by my fix for PR c++/29077 that is
not correct since it sets DECL_{CONS,DES}TRUCTOR regardless of 'ctype',
while it should do it only when 'ctype' is not NULL_TREE. The attached
patch fixes this.

I've successfully regtested this on x86_64-apple-darwin-9. Is it
OK for 4.3 and for the mainline?

Thanks in advance,
Simon

:ADDPATCH c++:


2008-10-02  Simon Martin  <simartin@users.sourceforge.net>

	PR c++/37647
	* decl.c (grokfndecl): Don't honour SFK in a non class context.


Index: gcc/cp/decl.c
===================================================================
--- gcc/cp/decl.c	(revision 140838)
+++ gcc/cp/decl.c	(working copy)
@@ -6531,10 +6531,10 @@ grokfndecl (tree ctype,
     {
     case sfk_constructor:
     case sfk_copy_constructor:
-      DECL_CONSTRUCTOR_P (decl) = 1;
+      DECL_CONSTRUCTOR_P (decl) = (ctype != NULL_TREE);
       break;
     case sfk_destructor:
-      DECL_DESTRUCTOR_P (decl) = 1;
+      DECL_DESTRUCTOR_P (decl) =  (ctype != NULL_TREE);
       break;
     default:
       break;


2008-10-02  Simon Martin  <simartin@users.sourceforge.net>

	PR c++/37647
	* g++.dg/parse/ctor9.C: New test.


/* PR c++/37647 */
/* { dg-do "compile" } */

struct A
{
  A() { void A(); } /* { dg-error "return type specification for constructor invalid" } */
};



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