mdt@YAHI.STANFORD.EDU (Michael Tiemann) (03/17/89)
yahi% diff -c2 cplus-decl.c~ cplus-decl.c *** cplus-decl.c~ Wed Mar 15 09:26:48 1989 --- cplus-decl.c Thu Mar 16 22:23:57 1989 *************** *** 2999,3003 **** If not, it will get done when the type is completed. */ ! if (TREE_CODE (decl) == VAR_DECL || TREE_CODE (decl) == FUNCTION_DECL) { int toplev = current_binding_level == global_binding_level; --- 2999,3004 ---- If not, it will get done when the type is completed. */ ! if (TREE_CODE (decl) == VAR_DECL || TREE_CODE (decl) == FUNCTION_DECL ! || TREE_CODE (decl) == RESULT_DECL) { int toplev = current_binding_level == global_binding_level; *************** *** 6776,6781 **** /* If we have a named return value, put that in our scope as well. */ if (DECL_NAME (DECL_RESULT (current_function_decl)) != value_identifier) ! finish_decl (DECL_RESULT (current_function_decl), ! DECL_INITIAL (DECL_RESULT (current_function_decl)), 0); } --- 6777,6785 ---- /* If we have a named return value, put that in our scope as well. */ if (DECL_NAME (DECL_RESULT (current_function_decl)) != value_identifier) ! { ! pushdecl (DECL_RESULT (current_function_decl)); ! finish_decl (DECL_RESULT (current_function_decl), ! DECL_INITIAL (DECL_RESULT (current_function_decl)), 0); ! } } yahi% ================================================================ Here is the test program which now compiles: struct A { int i; A(int x) { printf("A(%d)\n", x); i = x; }; A(A& x) { printf("A(A& x), x.i == %d\n", x.i); i = x.i; }; ~A(void) { printf("~A(%d)\n", i); }; void operator += (A& x) { printf("+=(%d, %d)\n", i, x.i); i += x.i; }; }; A foo (void) return tmp = 4; { printf("foo(void), tmp.i == %d\n", tmp.i); return tmp; } main() { A bar = 5; bar += foo(); printf("main(), bar.i == %d\n", bar.i); } ================================================================ And here are the results: yahi% a.out A(5) A(4) foo(void), tmp.i == 4 A(A& x), x.i == 4 +=(5, 4) ~A(4) main(), bar.i == 9 ~A(9) yahi% ================================================================ Michael