From c9407e4c671efb42c76dbb80a13ecf0c5dc09f05 Mon Sep 17 00:00:00 2001
From: Mark Mitchell <mmitchel@gcc.gnu.org>
Date: Tue, 20 Feb 2001 18:22:32 +0000
Subject: [PATCH] stmt.c (expand_return): If an attempt is made to return the
 error_mar_node...

	* stmt.c (expand_return): If an attempt is made to return the
	error_mar_node, treat the return like a return without a value.

From-SVN: r39924
---
 gcc/ChangeLog                                  |  5 +++++
 gcc/cp/ChangeLog                               |  3 +--
 gcc/stmt.c                                     |  7 ++++++-
 gcc/testsuite/g++.old-deja/g++.other/return1.C | 18 ++++++++++++++++++
 4 files changed, 30 insertions(+), 3 deletions(-)
 create mode 100644 gcc/testsuite/g++.old-deja/g++.other/return1.C

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index df1b7fb943c..70b8d265321 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,8 @@
+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.
+
 2001-02-19  Zack Weinberg  <zackw@stanford.edu>
 
 	* sibcall.c (skip_copy_to_return_value): Call
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 45c61d1e269..5387d68d437 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1075,8 +1075,7 @@ Sun Feb  4 15:52:44 2001  Richard Kenner  <kenner@vlsi1.ultra.nyu.edu>
 
 	* class.c (check_field_decls): Don't special case anonymous
 	fields in error messages.
-	(note_name_declared_inpwdpwd
-	_class): Use %D on diagnostic.
+	(note_name_declared_in_class): Use %D on diagnostic.
 
 	* tree.c (pod_type_p): Use strip_array_types.
 	(cp_valid_lang_attribute): Likewise.
diff --git a/gcc/stmt.c b/gcc/stmt.c
index 8465df7221c..80be1faf737 100644
--- a/gcc/stmt.c
+++ b/gcc/stmt.c
@@ -2946,7 +2946,12 @@ expand_return (retval)
 #endif
 
   if (retval == error_mark_node)
-    retval_rhs = NULL_TREE;
+    {
+      /* 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)
diff --git a/gcc/testsuite/g++.old-deja/g++.other/return1.C b/gcc/testsuite/g++.old-deja/g++.other/return1.C
new file mode 100644
index 00000000000..42a7e47a2c4
--- /dev/null
+++ b/gcc/testsuite/g++.old-deja/g++.other/return1.C
@@ -0,0 +1,18 @@
+// Build don't link:
+// Special g++ Option: 
+// Origin: holmen@mail.nu
+
+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 - 
+}
-- 
2.30.2