OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libjava/] [testsuite/] [libjava.lang/] [err3.java] - Blame information for rev 861

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 765 jeremybenn
/*--------------------------------------------------------------------------*/
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
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.