[PATCH] D65696: Implements CWG 2082 Referring to parameters in unevaluated operands of default arguments

Mark de Wever via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sun Aug 4 10:05:31 PDT 2019

Mordante marked 2 inline comments as done.
Mordante added inline comments.

Comment at: clang/lib/Sema/SemaDeclCXX.cpp:103-105
+      //   A local variable cannot be odr-used (6.2) in a default argument.
+      if (DRE->isNonOdrUse() != NOUR_None)
+        return false;
rsmith wrote:
> Please add tests for the distinction between "potentially-evaluated" and "odr-used" here, for example:
> ```
> void f() {
>   const int n = 123;
>   void g(int k = n); // ok, not an odr-use
> }
> ```
I added the test but unfortunately clang disagrees with you and considers `n` ODR used. 
I'll have look how to teach clang `n` is not ODR used.

Comment at: clang/www/cxx_dr_status.html:3
 <!-- This file is auto-generated by make_cxx_dr_status. Do not modify. -->
rsmith wrote:
> Note that this is an auto-generated file. To update it, you need to add a test to the relevant file (`test/CXX/drs/dr20xx.cpp`) with a suitable comment (`// dr2082: 10` to mark this implemented in Clang 10), grab a recent `cwg_index.html` file, and run the `make_cxx_dr_status` script.
Thanks for the info, I'll have a look at it after I fix the ODR used part.

  rG LLVM Github Monorepo



More information about the cfe-commits mailing list