public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* Re: [C++/PATCH] Fix PR 30303, ICE with invalid constructor definition
@ 2007-10-14 18:52 Andrew Pinski
  2007-10-14 20:26 ` Paolo Carlini
  0 siblings, 1 reply; 4+ messages in thread
From: Andrew Pinski @ 2007-10-14 18:52 UTC (permalink / raw)
  To: Mark Mitchell, Gcc Patch List

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

Sorry for breaking the threading, I cannot find the original email
anymore (http://gcc.gnu.org/ml/gcc-patches/2007-01/msg00960.html).

Anyways I committed this patch to the trunk after a bootstrap/test on
i386-apple-darwin with no regressions.

The only different between this patch and the older one is a new
testcase, this time for deconstructors.

Thanks,
Andrew Pinski

	* decl.c (grokfndecl): Return NULL after the "definition of
	implicitly-declared" error happened.

	* g++.dg/other/ctor1.C: New test.
	* g++.dg/other/ctor2.C: New test.
       * g++.dg/other/dtor1.C: New test.

[-- Attachment #2: fixpr30303.diff.txt --]
[-- Type: text/plain, Size: 2061 bytes --]

Index: testsuite/g++.dg/other/dtor1.C
===================================================================
--- testsuite/g++.dg/other/dtor1.C	(revision 0)
+++ testsuite/g++.dg/other/dtor1.C	(revision 0)
@@ -0,0 +1,17 @@
+/* { dg-do compile } */
+// PR C++/30303
+// This used to ICE because we did not return NULL
+// in grokfndecl when an error happened.
+
+struct Ifoo
+{
+virtual ~Ifoo(){}
+};
+struct foo : Ifoo
+{
+ foo(){};
+};
+foo::~foo() // { dg-error "definition of implicitly-declared" }
+{
+delete this;
+}
Index: testsuite/g++.dg/other/ctor1.C
===================================================================
--- testsuite/g++.dg/other/ctor1.C	(revision 0)
+++ testsuite/g++.dg/other/ctor1.C	(revision 0)
@@ -0,0 +1,11 @@
+/* { dg-do compile } */
+// PR C++/30303
+// This used to ICE because we did not return NULL
+// in grokfndecl when an error happened.
+
+class A
+{
+  int i;
+};
+
+A::A() { A(); } /* { dg-error "definition of implicitly-declared" } */
Index: testsuite/g++.dg/other/ctor2.C
===================================================================
--- testsuite/g++.dg/other/ctor2.C	(revision 0)
+++ testsuite/g++.dg/other/ctor2.C	(revision 0)
@@ -0,0 +1,17 @@
+/* { dg-do compile } */
+// PR C++/30303
+// This used to ICE because we did not return NULL
+// in grokfndecl when an error happened.
+
+
+class A
+{
+  int i;
+};
+
+void foo()
+{
+  A();
+}
+
+A::A() {} /* { dg-error "definition of implicitly-declared" } */
Index: cp/decl.c
===================================================================
--- cp/decl.c	(revision 129297)
+++ cp/decl.c	(working copy)
@@ -6577,7 +6577,10 @@ grokfndecl (tree ctype,
 	       XXX Isn't this done in start_function, too?  */
 	    revert_static_member_fn (decl);
 	  if (DECL_ARTIFICIAL (old_decl))
-	    error ("definition of implicitly-declared %qD", old_decl);
+	    {
+	      error ("definition of implicitly-declared %qD", old_decl);
+	      return NULL_TREE;
+	    }
 
 	  /* Since we've smashed OLD_DECL to its
 	     DECL_TEMPLATE_RESULT, we must do the same to DECL.  */

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

* Re: [C++/PATCH] Fix PR 30303, ICE with invalid constructor definition
  2007-10-14 18:52 [C++/PATCH] Fix PR 30303, ICE with invalid constructor definition Andrew Pinski
@ 2007-10-14 20:26 ` Paolo Carlini
  0 siblings, 0 replies; 4+ messages in thread
From: Paolo Carlini @ 2007-10-14 20:26 UTC (permalink / raw)
  To: Andrew Pinski; +Cc: Gcc Patch List

Andrew Pinski wrote:
> The only different between this patch and the older one is a new
> testcase, this time for deconstructors.
<destructors>, you mean ;)

Paolo.

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

* Re: [C++/PATCH] Fix PR 30303, ICE with invalid constructor definition
  2007-01-08  4:51 Andrew Pinski
@ 2007-01-11  4:49 ` Mark Mitchell
  0 siblings, 0 replies; 4+ messages in thread
From: Mark Mitchell @ 2007-01-11  4:49 UTC (permalink / raw)
  To: Andrew Pinski; +Cc: gcc-patches

Andrew Pinski wrote:

> 	* decl.c (grokfndecl): Return NULL after the "definition of
> 	implicitly-declared" error happened.
> 
> 	* g++.dg/other/ctor1.C: New test.
> 	* g++.dg/other/ctor2.C: New test.

OK.

-- 
Mark Mitchell
CodeSourcery
mark@codesourcery.com
(650) 331-3385 x713

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

* [C++/PATCH] Fix PR 30303, ICE with invalid constructor definition
@ 2007-01-08  4:51 Andrew Pinski
  2007-01-11  4:49 ` Mark Mitchell
  0 siblings, 1 reply; 4+ messages in thread
From: Andrew Pinski @ 2007-01-08  4:51 UTC (permalink / raw)
  To: gcc-patches

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

The problem here is that grokfndecl errors but does not return NULL for
the case of defining a constructor that was implicitly declared.


OK? Bootstrapped and tested on i686-linux-gnu with no regressions.

Thanks,
Andrew Pinski

	* decl.c (grokfndecl): Return NULL after the "definition of
	implicitly-declared" error happened.

	* g++.dg/other/ctor1.C: New test.
	* g++.dg/other/ctor2.C: New test.



[-- Attachment #2: fixpr30303.diff.txt --]
[-- Type: text/x-patch, Size: 1549 bytes --]

Index: testsuite/g++.dg/other/ctor1.C
===================================================================
--- testsuite/g++.dg/other/ctor1.C	(revision 0)
+++ testsuite/g++.dg/other/ctor1.C	(revision 0)
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+// PR C++/30303
+// This used to ICE because we did not return NULL
+// in grokfndecl when an error happened.
+
+
+
+class A
+{
+  int i;
+};
+
+A::A() { A(); } /* { dg-error "definition of implicitly-declared" } */
Index: testsuite/g++.dg/other/ctor2.C
===================================================================
--- testsuite/g++.dg/other/ctor2.C	(revision 0)
+++ testsuite/g++.dg/other/ctor2.C	(revision 0)
@@ -0,0 +1,18 @@
+/* { dg-do compile } */
+// PR C++/30303
+// This used to ICE because we did not return NULL
+// in grokfndecl when an error happened.
+
+
+
+class A
+{
+  int i;
+};
+
+void foo()
+{
+  A();
+}
+
+A::A() {} /* { dg-error "definition of implicitly-declared" } */
Index: cp/decl.c
===================================================================
--- cp/decl.c	(revision 120543)
+++ cp/decl.c	(working copy)
@@ -6223,7 +6223,10 @@ grokfndecl (tree ctype,
 	       XXX Isn't this done in start_function, too?  */
 	    revert_static_member_fn (decl);
 	  if (DECL_ARTIFICIAL (old_decl))
-	    error ("definition of implicitly-declared %qD", old_decl);
+	    {
+	      error ("definition of implicitly-declared %qD", old_decl);
+	      return NULL_TREE;
+	    }
 
 	  /* Since we've smashed OLD_DECL to its
 	     DECL_TEMPLATE_RESULT, we must do the same to DECL.  */

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

end of thread, other threads:[~2007-10-14 18:16 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-10-14 18:52 [C++/PATCH] Fix PR 30303, ICE with invalid constructor definition Andrew Pinski
2007-10-14 20:26 ` Paolo Carlini
  -- strict thread matches above, loose matches on Subject: below --
2007-01-08  4:51 Andrew Pinski
2007-01-11  4:49 ` Mark Mitchell

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).