mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 15:24:43 +02:00
8187443: Forest Consolidation: Move files to unified layout
Reviewed-by: darcy, ihse
This commit is contained in:
parent
270fe13182
commit
3789983e89
56923 changed files with 3 additions and 15727 deletions
25
test/langtools/tools/javac/ParseConditional.java
Normal file
25
test/langtools/tools/javac/ParseConditional.java
Normal file
|
@ -0,0 +1,25 @@
|
|||
/*
|
||||
* @test /nodynamiccopyright/
|
||||
* @bug 4092958
|
||||
* @summary The compiler was too permissive in its parsing of conditional
|
||||
* expressions.
|
||||
* @author turnidge
|
||||
*
|
||||
* @compile/fail/ref=ParseConditional.out -XDrawDiagnostics ParseConditional.java
|
||||
*/
|
||||
|
||||
public class ParseConditional {
|
||||
public static void main(String[] args) {
|
||||
boolean condition = true;
|
||||
int a = 1;
|
||||
int b = 2;
|
||||
int c = 3;
|
||||
int d = 4;
|
||||
// The following line should give an error because the conditional ?: operator
|
||||
// is higher priority than the final assignment operator, between c and d.
|
||||
// As such, the correct parsing is:
|
||||
// a = (condition ? b = c : c) = d;
|
||||
// and it is illegal to try and assign to the value of the conditional expression.
|
||||
a = condition ? b = c : c = d;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue