[PATCH] D85613: [clang] Look through bindings when checking whether a default argument references a local entity.
Richard Smith - zygoloid via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sun Aug 9 23:09:49 PDT 2020
rsmith added inline comments.
================
Comment at: clang/lib/Sema/SemaDeclCXX.cpp:101-105
+ if (const VarDecl *HoldingVar = Binding->getHoldingVar()) {
+ // C++20 [dcl.struct.bind]p4:
+ // Each vi is the name [...] that refers to the object bound to ri [...]
+ Decl = HoldingVar;
+ } else {
----------------
Is there a reason to separate these two cases? (Could we just use the decomposed decl unconditionally?) Generally treating tuple-like decompositions differently from other kinds seems error-prone.
================
Comment at: clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p7.cpp:51
+ extern void h8a(int = sizeof(z)); // ok
+ extern void h8b(int = w); // expected-error {{default argument references local variable 'w'}}
----------------
The diagnostic in this case is inconsistent with the non-tuple-like cases. I think this diagnostic is better; we should use the original `Decl` when producing the diagnostic, not the decomposed variable.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D85613/new/
https://reviews.llvm.org/D85613
More information about the cfe-commits
mailing list