This is an archive of the discontinued LLVM Phabricator instance.

[clang] P2266: apply move elision rules on throw expr nested in function prototypes
ClosedPublic

Authored by mizvekov on Jun 5 2022, 1:04 PM.

Details

Summary

Our rules to determine if the throw expression are within the variable
scope were giving a false negative result in case the throw expression
would appear within a decltype in a nested function declaration.

Per P2266R3, the relevant rule is: [expr.prim.id.unqual]/2

if the id-expression (possibly parenthesized) is the operand of a throw-expression, and names an implicitly movable entity that belongs to a scope that does not contain the compound-statement of the innermost lambda-expression, try-block , or function-try-block (if any) whose compound-statement or ctor-initializer encloses the throw-expression.

This fixes PR54341.

Signed-off-by: Matheus Izvekov <mizvekov@gmail.com>

Diff Detail

Event Timeline

mizvekov created this revision.Jun 5 2022, 1:04 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 5 2022, 1:04 PM
mizvekov requested review of this revision.Jun 5 2022, 1:04 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 5 2022, 1:04 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript
rsmith accepted this revision.Jun 6 2022, 10:17 AM
rsmith added inline comments.
clang/lib/Sema/SemaExprCXX.cpp
849

Many of the remaining scope checks here also seem incorrect per the wording.

This revision is now accepted and ready to land.Jun 6 2022, 10:17 AM
mizvekov marked an inline comment as done.Jun 6 2022, 3:09 PM
mizvekov added inline comments.
clang/lib/Sema/SemaExprCXX.cpp
849

Thanks, I left a FIXME for next time.