| Summary: | [fp] Codan doesn't pay attention to __attribute__((noreturn)) | ||
|---|---|---|---|
| Product: | [Tools] CDT | Reporter: | Sergey Prigogin <eclipse.sprigogin> |
| Component: | cdt-codan | Assignee: | Elena Laskavaia <elaskavaia.cdt> |
| Status: | RESOLVED FIXED | QA Contact: | Elena Laskavaia <elaskavaia.cdt> |
| Severity: | normal | ||
| Priority: | P3 | CC: | cdtdoug, dcrocker, martin.gerhardy, mckinlay, yevshif, yo35 |
| Version: | 7.0 | ||
| Target Milestone: | 8.1.0 | ||
| Hardware: | PC | ||
| OS: | Linux | ||
| Whiteboard: | |||
| Bug Depends on: | 316230 | ||
| Bug Blocks: | 346557 | ||
I did not know about this attribute. I have a concept. For example exit() hardcoded as "noreturn". -> 7.0.1 how does it represented in AST btw? (In reply to comment #2) > how does it represented in AST btw? Attributes, I'm afraid, are not preserved in the AST. This is something we'll have to change. *** Bug 350478 has been marked as a duplicate of this bug. *** Implementation of IFinction.isNoReturn method uploaded to Gerrit at https://git.eclipse.org/r/#/c/5578/. IFinction.isNoReturn() method is now available. fixed thanks for Sergey implementing annotations support I'm still having problems with this. Simple examples work, but my actual production code doesn't and I can't seem to make a small example. Putting __attribute__((noreturn)) on the function definition as well as the declaration stops the warning, but GCC doesn't allow this. (In reply to comment #8) > I'm still having problems with this. Simple examples work, but my actual > production code doesn't and I can't seem to make a small example. There is little chance to fix this bug unless you can provide an example that triggers the false warning. Another alternative is for you to debug the issue yourself to determine where the existing logic fails. Fair enough. I tried and failed to isolate it (in the time I had). Just thought you might want to know. Should the attribute be accepted in a place where GCC does not allow it? (In reply to comment #10) > Should the attribute be accepted in a place where GCC does not allow it? CDT parser is pretty lax when accepting __attribute__ in various places. The problem is that GCC doesn't provide a formal definition of the grammar for __attribute__. I also encounter this bug, even in simple situations. For instance:
void do_throw() __attribute__((noreturn));
int fun(int x) { // <- Warning
if(x==0) return 42;
else do_throw();
}
This code raise the warning "No return, in function returnin non-void". However,
with a simplier 'fun' function, the warning disappear:
void do_throw() __attribute__((noreturn));
int fun(int x) { // <- No warning
do_throw();
}
Finally, whatever the function 'fun' is, I obtain an exception if the definition of 'do_throw' is included:
void do_throw() __attribute__((noreturn));
void do_throw() {
throw "Stop it";
}
int fun(int x) { // <- Warning
do_throw();
}
And also:
void __attribute__((noreturn)) do_throw() {
throw std::exception();
}
int fun(int x) { // <- Warning
do_throw();
}
PS: I use CDT v8.1.1 and Juno. *** cdt git genie on behalf of Alena Laskavaia ***
Bug 316076 - fixed f.p. when using gcc annotation about no return
[*] http://git.eclipse.org/c/cdt/org.eclipse.cdt.git/commit/?id=77a06573a9ac854ef0e75b021f39625a7a6dc3ff
|
The following code triggers a warning "No return, in function returning non-void", but gcc is happy with it. void f() __attribute__((noreturn)); bool test() { f(); }