public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Fix PR c++/37647: ICE with invalid use of constructor
@ 2008-10-03  4:46 Simon Martin
  2008-10-13  3:24 ` Mark Mitchell
  0 siblings, 1 reply; 3+ messages in thread
From: Simon Martin @ 2008-10-03  4:46 UTC (permalink / raw)
  To: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 770 bytes --]

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++:



[-- Attachment #2: CL_37647 --]
[-- Type: text/plain, Size: 141 bytes --]

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

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



[-- Attachment #3: pr37647.patch --]
[-- Type: text/plain, Size: 545 bytes --]

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;



[-- Attachment #4: CL_37647_testsuite --]
[-- Type: text/plain, Size: 111 bytes --]

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

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



[-- Attachment #5: ctor9.C --]
[-- Type: text/plain, Size: 153 bytes --]

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

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



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2008-10-24 19:31 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-10-03  4:46 [PATCH] Fix PR c++/37647: ICE with invalid use of constructor Simon Martin
2008-10-13  3:24 ` Mark Mitchell
2008-10-24 21:42   ` Simon Martin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).