OSDN Git Service

Add NIOS2 support. Code from SourceyG++.
[pf3gnuchains/gcc-fork.git] / libjava / testsuite / libjava.lang / err3.java
1 /*--------------------------------------------------------------------------*/
2 /* File name  : err3.java                                              */
3 /*            :                                                             */
4 /* Cause      : Evaluation sequence of the formula which used               */
5 /*            : the substitution operator is not performed correctly.       */
6 /*            :                                                             */
7 /* Message    : NG1:[27]-->[9]                                              */
8 /*            : NG2:[27]-->[9]                                              */
9 /*            :                                                             */
10 /* Note       : JLS 15.6 Evaluation Order (p305)                            */
11 /*                 S15.6.1 Evaluate Left-Hand Operand First                 */
12 /*            : A formula should be evaluated to 9*3 instead of 3*3.        */
13 /*--------------------------------------------------------------------------*/
14
15 public class err3 {
16   public static void main(String[] args) {
17     int x = 9;
18     x *= (x = 3);
19     if ( x == 27 ) {
20       System.out.println("OK1");
21     } else {
22       System.out.println("NG1:[27]-->["+x+"]");
23     }
24
25     int y = 9;
26     y = y * (y = 3);
27     if ( y == 27 ) {
28       System.out.println("OK2");
29     } else {
30       System.out.println("NG2:[27]-->["+y+"]");
31     }
32   }
33 }
34