OSDN Git Service

2000-12-15 Alexandre Petit-Bianco <apbianco@cygnus.com>
authorapbianco <apbianco@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 15 Dec 2000 08:50:12 +0000 (08:50 +0000)
committerapbianco <apbianco@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 15 Dec 2000 08:50:12 +0000 (08:50 +0000)
* parse.y (end_artificial_method_body): Fixed undefined behavior.
Credits go to rth for finding it.

(http://gcc.gnu.org/ml/gcc/2000-12/msg00495.html)

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

gcc/java/ChangeLog
gcc/java/parse.y

index 4385b49..70065a9 100644 (file)
@@ -1,3 +1,8 @@
+2000-12-15  Alexandre Petit-Bianco  <apbianco@cygnus.com>
+
+       * parse.y (end_artificial_method_body): Fixed undefined behavior.
+       Credits go to rth for finding it.
+
 2000-12-13  Mike Stump  <mrs@wrs.com>
 
        * parse.y (check_static_final_variable_assignment_flag): Fix spelling.
index 00a5544..7a23e72 100644 (file)
@@ -7200,7 +7200,11 @@ static void
 end_artificial_method_body (mdecl)
      tree mdecl;
 {
-  BLOCK_EXPR_BODY (DECL_FUNCTION_BODY (mdecl)) = exit_block ();
+  /* exit_block modifies DECL_FUNCTION_BODY (current_function_decl).
+     It has to be evaluated first. (if mdecl is current_function_decl,
+     we have an undefined behavior if no temporary variable is used.) */
+  tree b = exit_block ();
+  BLOCK_EXPR_BODY (DECL_FUNCTION_BODY (mdecl)) = b;
   exit_block ();
 }