[PATCH] D139400: [clang] Show error when a local variables is passed as default template parameter
Shafik Yaghmour via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Dec 8 12:29:20 PST 2022
shafik added inline comments.
================
Comment at: clang/lib/Sema/SemaTemplate.cpp:1594
+ if (VarDecl *VD = dyn_cast<VarDecl>(DRE->getDecl())) {
+ if (VD->isLocalVarDecl()) {
+ Diag(DRE->getLocation(),
----------------
So if we look at `CheckDefaultArgumentVisitor::VistDeclRefExpr` it has a comment about having to check ODR use due to [cwg 2346](https://cplusplus.github.io/CWG/issues/2346.html) and I believe you should be using that as well.
Which would make your example below pass since the variable is `const` see: https://godbolt.org/z/78Tojh6q5
It looks like neither gcc nor MSVC implement this DR.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D139400/new/
https://reviews.llvm.org/D139400
More information about the cfe-commits
mailing list