| Summary: | "No break at the end of case" warning for a case statement produced by macro expansion | ||
|---|---|---|---|
| Product: | [Tools] CDT | Reporter: | Sergey Prigogin <eclipse.sprigogin> |
| Component: | cdt-codan | Assignee: | Sergey Prigogin <eclipse.sprigogin> |
| Status: | RESOLVED FIXED | QA Contact: | Elena Laskavaia <elaskavaia.cdt> |
| Severity: | normal | ||
| Priority: | P3 | CC: | cdtdoug, zeratul976 |
| Version: | 8.0 | ||
| Target Milestone: | 8.0.1 | ||
| Hardware: | All | ||
| OS: | All | ||
| Whiteboard: | |||
Fixed in master and cdt_8_0 > 20110828. *** cdt git genie on behalf of Sergey Prigogin ***
Bug 356037 - "No break at the end of case" warning for a case statement
produced by macro expansion.
[*] http://git.eclipse.org/c/cdt/org.eclipse.cdt.git/commit/?id=c0b9f79b300f27293e507c7c050afe4befa86928
*** cdt git genie on behalf of Sergey Prigogin ***
Bug 356037 - "No break at the end of case" warning for a case statement
produced by macro expansion.
[*] http://git.eclipse.org/c/cdt/org.eclipse.cdt.git/commit/?id=dce3efe73399ecb1c1c2bd810800aa7e9c5f453a
Sergey, what is the rationale for this special treatment of macros? (In reply to Nathan Ridge from comment #4) > Sergey, what is the rationale for this special treatment of macros? Showing warnings in the code that is a result of macro expansion is confusing to the user since the user doesn't see the suspicious code. It may also lead to a large number of warnings for the same macro if that macro is used in many places. (In reply to Sergey Prigogin from comment #5) > (In reply to Nathan Ridge from comment #4) > > Sergey, what is the rationale for this special treatment of macros? > > Showing warnings in the code that is a result of macro expansion is > confusing to the user since the user doesn't see the suspicious code. It may > also lead to a large number of warnings for the same macro if that macro is > used in many places. Isn't there the chance of catching a real bug, though, if you use the macro multiple times in the same switch, and you forgot the 'break' in the macro definition? (In reply to Nathan Ridge from comment #6) > Isn't there the chance of catching a real bug, though, if you use the macro > multiple times in the same switch, and you forgot the 'break' in the macro > definition? It's better to miss a real bug than to produce false positives. |
There should be no "No break at the end of case" warning if the case statement is a result of macro expansion: #define MY_MACRO(i) \ case i: { \ } void f() { int x; switch (x) { MY_MACRO(1) // There should be no warning here. } }