C++ PATCH: PR 10218
Mark Mitchell
mark@codesourcery.com
Fri Mar 28 21:26:00 GMT 2003
PR 10218 is a crash after a valid error message; here's a fix to
improve the error recovery.
Even though this is a regression, I'm not going to put this on the
release branch; it just might cause other problems, and the
confused-by-earlier-errors backup will save us.
Tested on i686-pc-linux-gnu, applied on the mainline.
--
Mark Mitchell
CodeSourcery, LLC
mark@codesourcery.com
2003-03-28 Mark Mitchell <mark@codesourcery.com>
PR c++/10218
* decl.c (grokfndecl): Return NULL_TREE for bogus out-of-class
definitions.
Index: decl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/decl.c,v
retrieving revision 1.1026
diff -c -5 -p -r1.1026 decl.c
*** decl.c 22 Mar 2003 15:34:39 -0000 1.1026
--- decl.c 28 Mar 2003 21:14:52 -0000
*************** grokfndecl (tree ctype,
*** 9130,9151 ****
if (old_decl && DECL_ARTIFICIAL (old_decl))
error ("definition of implicitly-declared `%D'", old_decl);
if (old_decl)
{
/* Since we've smashed OLD_DECL to its
DECL_TEMPLATE_RESULT, we must do the same to DECL. */
if (TREE_CODE (decl) == TEMPLATE_DECL)
decl = DECL_TEMPLATE_RESULT (decl);
/* Attempt to merge the declarations. This can fail, in
the case of some invalid specialization declarations. */
push_scope (ctype);
! if (!duplicate_decls (decl, old_decl))
! error ("no `%#D' member function declared in class `%T'",
! decl, ctype);
pop_scope (ctype);
return old_decl;
}
}
if (DECL_CONSTRUCTOR_P (decl) && !grok_ctor_properties (ctype, decl))
--- 9130,9157 ----
if (old_decl && DECL_ARTIFICIAL (old_decl))
error ("definition of implicitly-declared `%D'", old_decl);
if (old_decl)
{
+ bool ok;
+
/* Since we've smashed OLD_DECL to its
DECL_TEMPLATE_RESULT, we must do the same to DECL. */
if (TREE_CODE (decl) == TEMPLATE_DECL)
decl = DECL_TEMPLATE_RESULT (decl);
/* Attempt to merge the declarations. This can fail, in
the case of some invalid specialization declarations. */
push_scope (ctype);
! ok = duplicate_decls (decl, old_decl);
pop_scope (ctype);
+ if (!ok)
+ {
+ error ("no `%#D' member function declared in class `%T'",
+ decl, ctype);
+ return NULL_TREE;
+ }
return old_decl;
}
}
if (DECL_CONSTRUCTOR_P (decl) && !grok_ctor_properties (ctype, decl))
More information about the Gcc-patches
mailing list