Page MenuHomePhabricator

Implements CWG 2082 Referring to parameters in unevaluated operands of default arguments
Needs ReviewPublic

Authored by Mordante on Aug 3 2019, 3:43 AM.



This implements the current standard wording for [dcl.fct.default]p9 and [dcl.fct.default]p7. This has been changed by CWG 2082.

Note: I don't have access to the paper therefore I assume it retroactively applies to all C++ standards.

Diff Detail

Event Timeline

Mordante created this revision.Aug 3 2019, 3:43 AM
rsmith added inline comments.Aug 3 2019, 4:55 PM

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
3 ↗(On Diff #213186)

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.

Mordante marked 2 inline comments as done.Aug 4 2019, 10:04 AM
Mordante added inline comments.

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.

3 ↗(On Diff #213186)

Thanks for the info, I'll have a look at it after I fix the ODR used part.

Mordante updated this revision to Diff 215448.Aug 15 2019, 11:32 AM

Updated the unit tests as requested. This required the Sema::ActOnParamDefaultArgument to delay a part of the ODR validation until the default argument has been 'instantiated'.
As discussed on IRC; the up to date cwg_index.html is not public, so I only updated the unit test and removed the changes to cxx_dr_status.html.