-
Couldn't load subscription status.
- Fork 15k
[clang] Check captured variables for noreturn attribute #155213
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -225,3 +225,16 @@ extern void abc_02(func_type *); | |
| abc_02(&func_ptr); | ||
| func_ptr(); | ||
| } // expected-warning {{function declared 'noreturn' should not return}} | ||
|
|
||
| [[noreturn]] void test_lambda() { | ||
| func_type func_ptr = noret; | ||
| [&func_ptr]() { func_ptr = ordinary; } (); | ||
| func_ptr(); | ||
| } // expected-warning {{function declared 'noreturn' should not return}} | ||
|
|
||
| [[noreturn]] void test_lambda_var(int x) { | ||
| func_type func_ptr = noret; | ||
| auto LF = [&](){func_ptr = ordinary;}; | ||
|
||
| LF(); | ||
| func_ptr(); | ||
| } // expected-warning {{function declared 'noreturn' should not return}} | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't seem right at all. the 'this' argument in a
CXXConstructExprdoes NOT get placed in the 0 arg (in fact, they are not present), so you can't assume 0 exists here. AND it isn't really clear why the 0 arg is important here, but others arent?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is more about the way LambdaExpr can be reached from variable initializer. For example, the code:
produces AST like:
These 'Visit*' methods are introduced to support this kind of lambda usage.