Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 333813

Summary: "No break at the end of this case" checker needs to be smarter
Product: [Tools] CDT Reporter: Sergey Prigogin <eclipse.sprigogin>
Component: cdt-codanAssignee: Elena Laskavaia <elaskavaia.cdt>
Status: RESOLVED FIXED QA Contact: Elena Laskavaia <elaskavaia.cdt>
Severity: normal    
Priority: P3 CC: cdtdoug, malaperle
Version: 8.0   
Target Milestone: 8.0   
Hardware: PC   
OS: All   
Whiteboard:

Description Sergey Prigogin CLA 2011-01-09 14:39:23 EST
An empty case at the end of the switch should be treated differently from an empty case preceding another case. It makes sense to show no warnings in the following code by default:

switch (i) {
case 1:
case 2:
  // do something
  break;
}

but show a warning in:

switch (i) {
case 1:
  // do something
  break;
case 2:
}
Comment 1 Andrew Gvozdev CLA 2011-01-09 22:25:19 EST
It is smart enough so you can do it in "Customize" dialog for both but I agree that defaults should be as you pointed out. I had to modify our internal CDT installation to do that just the other day.
Comment 2 Andrew Gvozdev CLA 2011-01-09 22:41:03 EST
BTW the description for this problem in preferences ends with triple word "statement".
Comment 3 Sergey Prigogin CLA 2011-01-09 23:12:09 EST
(In reply to comment #1)
To clarify:
The empty case preference should not apply to the last case, which should be governed exclusively by the last case preference.
Comment 4 Elena Laskavaia CLA 2011-01-17 21:57:41 EST
3 bugs in one. 
So I fixed:
- description text
- property empty statement does not apply to last statement
- default turn off empty stmt customization property

added corresponding test cases