Repository navigation
Conversation
…tor or destructor is called [GH edgcpp#218]
| } // expected-warning {{non-void function does not return a value}} | ||
| ^ | ||
|
|
||
| "Test_name.c", line 162: warning: missing return statement at end of non-void function "testTernaryUnconditionalNoreturn" |
There was a problem hiding this comment.
This warning suppression is kinda interesting, I assume I compose with something that transforms cond ? E : E into just E, but haven't explored what specifically
int testTernaryUnconditionalNoreturn() {
true ? NoReturn() : NoReturn();
}noreturn warning on noreturn cdtors [GH #218]noreturn warning on when calling noreturn cdtors [GH #218]
|
@daveedvdv is something like this what you had in mind? I ask because there are quite a few similar statements to the issue at hand, // S is a class that throws on ctor or dtor
[[noreturn]] void a() { S{}; } // expression statement, PR affects it, erroneous warning removed
[[noreturn]] void b() { S s; } // init statement, PR affects expression statements only, erroneous warning persists
void c(const S&);
[[noreturn]] void d() { c(S{}); } // PR does not peer into sub-expressions, erroneous warning persistsIs this limited scope what you intended? Also, this is not me pinging you for a review, I am not in any rush, |
| } else if (node_is(node, enk_temp_init)) { | ||
| a_dynamic_init_ptr dip = node->variant.init.dynamic_init; | ||
| a_boolean does_not_return = FALSE; | ||
| if (!dip) return; |
There was a problem hiding this comment.
We have a strict policy against "early returns".
There was a problem hiding this comment.
Refactored a bit, joined up the suppression warnings from both blocks, killed the early return.
| } else if (is_call_node(node)) { | ||
| a_boolean call_does_not_return = FALSE; | ||
| a_type_ptr routine_type; | ||
| node = node->variant.operation.operands; |
There was a problem hiding this comment.
Best to use routine_from_function_expr to handle all the cases.
There was a problem hiding this comment.
This implementation notices noreturn on function pointers as well,
I think switching to it would be a slight regression.
// imported/clang/c/Sema/attr-noreturn.sft.c
__attribute__((noreturn)) void f(__attribute__((noreturn)) void (*x)(void)) {
x();
}
That would be awesome, but beware of traversal costs. Maybe start with just this, for now? |
…d temporaries go through same code (`a_boolean does_not_return`)
Suppress
noreturn_function_does_returnwarning if noreturn constructor or destructor is called [GH #218]Previously we were testing for throw expressions and
noreturncall expressions only,extending to
noreturnconstructors and destructors as well.Noting though, this warning suppression does not consider subexpressions,
it only operates on top-level expressions of expression statements.
This could be significantly improved by recursing over the sub-expressions,
while being careful around short-circuiting.
Moreover, init statements could use similar warning suppressions.
Half of
src/statements.cdiff is just whitespace, slightly cleanerdiff -w: