Bug 333813 - "No break at the end of this case" checker needs to be smarter
Summary: "No break at the end of this case" checker needs to be smarter
Status: RESOLVED FIXED
Alias: None
Product: CDT
Classification: Tools
Component: cdt-codan (show other bugs)
Version: 8.0   Edit
Hardware: PC All
: P3 normal (vote)
Target Milestone: 8.0   Edit
Assignee: Elena Laskavaia CLA
QA Contact: Elena Laskavaia CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-01-09 14:39 EST by Sergey Prigogin CLA
Modified: 2011-01-17 22:23 EST (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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