This is an archive of the discontinued LLVM Phabricator instance.

[C++] Delay checking of constexpr-ness for special members.
Needs ReviewPublic

Authored by Rakete1111 on Aug 3 2018, 6:00 PM.

Details

Reviewers
rsmith
Summary

Specific class layouts meant that the constexpr-ness of a special member could only be decided after every special member was seen. However, this was at odds with the implementation, which checked the constexpr-ness for each special member in the order in which they were declared (hence that the bug only occurs when special members are ordered in a specific order).

This patch moves the checking of constexpr-ness after evaluating each special member.
This fixes https://llvm.org/pr38143

Diff Detail

Event Timeline

Rakete1111 created this revision.Aug 3 2018, 6:00 PM
Rakete1111 updated this revision to Diff 159160.Aug 3 2018, 9:33 PM

Add missing test cases. :)

rsmith added inline comments.Aug 6 2018, 6:05 PM
lib/Sema/SemaDeclCXX.cpp
6045

Your new handling should go up here, before we mark the method as finished (rather than marking it as finished twice).

6557–6558

We should only delay this for the first declaration, just as we only delay the corresponding check for exception specifications for the first declaration. (Maybe move the call to CheckExplicitlyDefaultedSpecialMemberConstexpr(MD); from the out-of-class default case to here, inside an if (!First).)

6560–6575

We should really implement the exception specification part and the constexpr part the same way. Either we should have a single list of special members we need to finish, or we should figure them out at the end of the class (like you're doing for constexpr now). But implementing exception specs one way and constexpr a different way invites bugs.

6623

... what rule? (This comment has lost the prior comment that it's commenting on.)