Summary: | [compiler] warning on fall through | ||||||||
---|---|---|---|---|---|---|---|---|---|
Product: | [Eclipse Project] JDT | Reporter: | Adam Kiezun <akiezun> | ||||||
Component: | Core | Assignee: | Maxime Daniel <maxime_daniel> | ||||||
Status: | VERIFIED FIXED | QA Contact: | |||||||
Severity: | enhancement | ||||||||
Priority: | P3 | CC: | joerg, maxime_daniel | ||||||
Version: | 3.0 | ||||||||
Target Milestone: | 3.2 M5 | ||||||||
Hardware: | PC | ||||||||
OS: | Windows 2000 | ||||||||
Whiteboard: | |||||||||
Attachments: |
|
Description
Adam Kiezun
2004-06-18 11:58:41 EDT
post 3.0 e.g. public class X { void foo(int i) { switch(i) { case 0 : case 1 : return; case 2 : System.out.println(i); <<<<<<<<<<<<<<<< case 3 : System.out.println(i); // fall-through default : return; } } } The line denoted by <<<<<<<<<<<< should be complained against, since it is an undocumented fall-through situation. To make it simple, any comment on a line would make the fall-through case treated as documented. The comment would need to span over the entire line (i.e. cannot just be a trailing comment to a statement). API proposal: - a new warning name for the batch compiler, fallThrough; - a new warning token for use with SuppressWarnings, fall-through; - a new problem IProblem#PossibleFallThroughCase; - a new problem reporting method ProblemReporter#possibleFallThroughCase; - a new compiler option CompilerOptions#ReportPossibleFallThroughCase, default reporting level is Ignore, option name for pref file is org.eclipse.jdt.core.compiler.problem.possibleFallThroughCase. Created attachment 34583 [details]
Suggested API + support
See FlowAnalysisTest, tests #6 to 18, and BatchCompilerTest, tests #49 to 51 for examples.
Retarget to 3.2 M5. Created attachment 34671 [details]
Reviewed API - testing under progress
Fixed in HEAD. Verifier please be aware that bug 127730 has been opened to track progress on the ability to 'comment out' the fall-through warning (default case label in the initial post). This is not supported yet. Verified for 3.2 M5 using build I20060215-0800 |