OSDN Git Service

* stmt.c (expand_return): If an attempt is made to return the
authormmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 20 Feb 2001 18:22:32 +0000 (18:22 +0000)
committermmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 20 Feb 2001 18:22:32 +0000 (18:22 +0000)
error_mar_node, treat the return like a return without a value.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@39924 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/cp/ChangeLog
gcc/stmt.c
gcc/testsuite/g++.old-deja/g++.other/return1.C [new file with mode: 0644]

index df1b7fb..70b8d26 100644 (file)
@@ -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
index 45c61d1..5387d68 100644 (file)
@@ -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.
index 8465df7..80be1fa 100644 (file)
@@ -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 (file)
index 0000000..42a7e47
--- /dev/null
@@ -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 - 
+}