Bug 21912 - Compiler probleme: continue statement with label identifier
Summary: Compiler probleme: continue statement with label identifier
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 2.0   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: 2.1 M1   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-07-25 12:36 EDT by Luc Bourlier CLA
Modified: 2002-09-19 07:30 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Luc Bourlier CLA 2002-07-25 12:36:14 EDT
In the case of multiple label before a loop statement (for, do, while), if there
is a continue statement with a label identifier which not represent the label
just before the loop statement, the compiler should generate a compilation error.

Example:
public class Test {
  public static void main(String[] args) {
    a : b : for (int i= 0; i < 10; i++) {
      if (i % 2  == 0)
        continue b;
      if (i % 2  == 1)
        continue a;
    }
  }
}


see the Java Language Spec, §14.15
"A continue statement with label Identifier attempts to transfer control to the
enclosing labeled statement (§14.7) that has the same Identifier as its label;
that statement, which is called the continue target, then immediately ends the
current iteration and begins a new one. The continue target must be a while, do,
or for statement or a compile-time error occurs. (...)"

javac generate the correct error:
> javac Test.java
Test.java:7: not a loop label: a
        continue a;
        ^
1 error
Comment 1 Philipe Mulet CLA 2002-07-26 06:22:53 EDT
Good find.
Comment 2 Philipe Mulet CLA 2002-07-26 06:26:37 EDT
Note that javac 1.3.1 did allow such code.
Comment 3 Philipe Mulet CLA 2002-07-26 12:45:15 EDT
Fixed (LabelStatement#concreteStatement()).
Comment 4 David Audel CLA 2002-09-19 07:30:27 EDT
Verified.