Thu, 03 Feb 2011 09:36:28 +0000
5017953: spurious cascaded diagnostics when name not found
Summary: when an operator is applied to one or more erroneous operands, spurious diagnostics are generated
Reviewed-by: jjg
duke@1 | 1 | /** |
duke@1 | 2 | * @test /nodynamiccopyright/ |
duke@1 | 3 | * @bug 4986256 |
jjg@611 | 4 | * @compile/ref=FallThrough.noLint.out -XDrawDiagnostics FallThrough.java |
jjg@611 | 5 | * @compile/ref=FallThrough.lintAll.out -Xlint:all,-path -XDrawDiagnostics FallThrough.java |
jjg@611 | 6 | * @compile/ref=FallThrough.lintFallThrough.out -Xlint:fallthrough -XDrawDiagnostics FallThrough.java |
duke@1 | 7 | */ |
duke@1 | 8 | |
duke@1 | 9 | // control: this class should generate a warning |
duke@1 | 10 | class FallThrough |
duke@1 | 11 | { |
duke@1 | 12 | int m1(int i) { |
duke@1 | 13 | switch (i) { |
duke@1 | 14 | case 1: i++; case 2: i++; |
duke@1 | 15 | } |
duke@1 | 16 | return i; |
duke@1 | 17 | } |
duke@1 | 18 | } |
duke@1 | 19 | |
duke@1 | 20 | // tests: the warnings that would otherwise be generated should all be suppressed |
duke@1 | 21 | @SuppressWarnings("fallthrough") |
duke@1 | 22 | class FallThrough1 |
duke@1 | 23 | { |
duke@1 | 24 | int m1(int i) { |
duke@1 | 25 | switch (i) { |
duke@1 | 26 | case 1: i++; case 2: i++; |
duke@1 | 27 | } |
duke@1 | 28 | return i; |
duke@1 | 29 | } |
duke@1 | 30 | } |
duke@1 | 31 | |
duke@1 | 32 | class FallThrough2 |
duke@1 | 33 | { |
duke@1 | 34 | @SuppressWarnings("fallthrough") |
duke@1 | 35 | class Bar { |
duke@1 | 36 | int m1(int i) { |
duke@1 | 37 | switch (i) { |
duke@1 | 38 | case 1: i++; case 2: i++; |
duke@1 | 39 | } |
duke@1 | 40 | return i; |
duke@1 | 41 | } |
duke@1 | 42 | } |
duke@1 | 43 | |
duke@1 | 44 | @SuppressWarnings("fallthrough") |
duke@1 | 45 | void m2(int i) { |
duke@1 | 46 | switch (i) { |
duke@1 | 47 | case 1: i++; case 2: i++; |
duke@1 | 48 | } |
duke@1 | 49 | } |
duke@1 | 50 | |
duke@1 | 51 | |
duke@1 | 52 | @SuppressWarnings("fallthrough") |
duke@1 | 53 | static int x = new FallThrough2() { |
duke@1 | 54 | int m1(int i) { |
duke@1 | 55 | switch (i) { |
duke@1 | 56 | case 1: i++; case 2: i++; |
duke@1 | 57 | } |
duke@1 | 58 | return i; |
duke@1 | 59 | } |
duke@1 | 60 | }.m1(0); |
duke@1 | 61 | |
duke@1 | 62 | } |