parse.y (end_artificial_method_body): Fixed undefined behavior.
authorAlexandre Petit-Bianco <apbianco@cygnus.com>
Fri, 15 Dec 2000 08:50:12 +0000 (08:50 +0000)
committerAlexandre Petit-Bianco <apbianco@gcc.gnu.org>
Fri, 15 Dec 2000 08:50:12 +0000 (00:50 -0800)
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.

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

From-SVN: r38278

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

index 4385b49946a1aa826860b448afb7b8f44e6f8d21..70065a93187cdef460be96107d8831eb48e70d2c 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 00a55444575d8c8952e091bd381c0abe6ad40409..7a23e72b96d1b8ecf24f618a159d4d21d47f491c 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 ();
 }