This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
PATCH: Fix PR 715
- To: gcc-patches at gcc dot gnu dot org
- Subject: PATCH: Fix PR 715
- From: Mark Mitchell <mark at codesourcery dot com>
- Date: Tue, 20 Feb 2001 10:32:19 -0800
- Organization: CodeSourcery, LLC
This patch fixes PR 715, a regression since GCC 2.95.2. In this case,
we crashed when calling expand_return with the error_mark_node as a
value.
In the long run, I'm not really sure it makes sense to make our
expansion routines robust in the face of this kind of thing; it may
instead make sense to refuse to expand functions that contain errors.
Certainly, nobody is going to use the RTL, so the only benefit of
performing the expansion is to get things like used-before-set
messages -- and those may well not be valid anyhow, in the face of
errors that existed in the source program. But, that debate is for
another day....
Bootstrapped and tested on i686-pc-linux-gnu, applied on the mainline
and the branch.
--
Mark Mitchell mark@codesourcery.com
CodeSourcery, LLC http://www.codesourcery.com
2001-02-20 Mark Mitchell <mark@codesourcery.com>
* stmt.c (expand_return): If an attempt is made to return the
error_mar_node, treat the return like a return without a value.
Index: stmt.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/stmt.c,v
retrieving revision 1.184
diff -c -p -r1.184 stmt.c
*** stmt.c 2001/01/29 02:46:23 1.184
--- stmt.c 2001/02/20 18:13:58
*************** expand_return (retval)
*** 2946,2952 ****
#endif
if (retval == error_mark_node)
! retval_rhs = NULL_TREE;
else if (TREE_CODE (retval) == RESULT_DECL)
retval_rhs = retval;
else if ((TREE_CODE (retval) == MODIFY_EXPR || TREE_CODE (retval) == INIT_EXPR)
--- 2946,2957 ----
#endif
if (retval == error_mark_node)
! {
! /* Treat this like a return of no value from a function that
! returns a value. */
! expand_null_return ();
! return;
! }
else if (TREE_CODE (retval) == RESULT_DECL)
retval_rhs = retval;
else if ((TREE_CODE (retval) == MODIFY_EXPR || TREE_CODE (retval) == INIT_EXPR)
Index: testsuite/g++.old-deja/g++.other/return1.C
===================================================================
RCS file: return1.C
diff -N return1.C
*** /dev/null Tue May 5 13:32:27 1998
--- return1.C Tue Feb 20 10:14:06 2001
***************
*** 0 ****
--- 1,17 ----
+ // Build don't link:
+ // Special g++ Option:
+
+ struct C {
+ int f() {return 0;}
+ };
+
+ struct D {
+ C a[1];
+ C* g();
+ };
+
+ C* D::g() {
+ int i = 0;
+ while (i < 1 && a[i].f() != 1) {}
+ return undefined_variable; // ERROR -
+ }