This is an archive of the discontinued LLVM Phabricator instance.

Disallow narrowing conversions to bool in noexcept specififers.
ClosedPublic

Authored by cor3ntin on Jul 17 2021, 3:55 AM.

Details

Summary

Completes the support for P1401R5

Diff Detail

Event Timeline

cor3ntin requested review of this revision.Jul 17 2021, 3:55 AM
cor3ntin created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptJul 17 2021, 3:55 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
cor3ntin updated this revision to Diff 359677.Jul 18 2021, 11:55 PM

Fix cxx_status

aaron.ballman added inline comments.Jul 22 2021, 6:01 AM
clang/lib/Sema/SemaOverload.cpp
5644

This function is checking converted constant expressions which was not touched by p1401r5, and it looks like this will break anything attempting to to contextual conversion constant expressions of type bool per http://eel.is/c++draft/expr.const#10 because it's removing the attempt to contextually convert to bool here.

5644

Also, I don't think P1401 was applied as a DR (but we should double check!) so I'd expect some checks for the language standard to gate the behavior. If P1401 was applied as a DR, then we should add some tests to clang/test/CXX with the proper DR markings so that our DR status page gets updated.

clang/test/SemaCXX/cxx2a-explicit-bool.cpp
731

Curiously, these tests already have this behavior without this patch applied: https://godbolt.org/z/13PojdWEe

cor3ntin updated this revision to Diff 360840.Jul 22 2021, 8:45 AM

It turns out that explicit was doing the right thing (as outlined in P1401),
but noexcept was not.

I've reworked the handling of noexcept so that noexcept and explicit specifier
use the same code paths, as they have the same expected behavior and wording.
This also make sure their diagnostics are consistent.

cor3ntin added inline comments.Jul 22 2021, 8:49 AM
clang/lib/Sema/SemaOverload.cpp
5644

It's in the air http://lists.isocpp.org/ext/2021/06/16918.php - Bur Richard took the decision to consider it as a DR
However the changes this patch intends to fix pertaining to preexisting wording, and clang was non-conforming.
P1401 merely put this non-conformity to light.

cor3ntin updated this revision to Diff 363534.Aug 2 2021, 11:30 AM

Fix tests

cor3ntin retitled this revision from Disallow narrowing conversions to bool in explicit specififers. to Disallow narrowing conversions to bool in noexcept specififers..Aug 2 2021, 11:31 AM
cor3ntin updated this revision to Diff 364719.Aug 6 2021, 1:32 AM

Remove whitespace only change

aaron.ballman added inline comments.Aug 6 2021, 6:28 AM
clang/lib/Sema/SemaExceptionSpec.cpp
81

You should just get rid of this parameter entirely if it's no longer going to be used.

clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
879

Was there a reason this test needed to change?

clang/www/cxx_status.html
1299

We're on Clang 14 now.

cor3ntin added inline comments.Aug 6 2021, 6:40 AM
clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
879

yup, 2 is not convertible to bool here. I use 0+1 to keep the kind of expression the same

aaron.ballman added inline comments.Aug 6 2021, 6:45 AM
clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
879

I kinda figured that was the case, thanks for confirming!

cor3ntin updated this revision to Diff 364783.Aug 6 2021, 6:47 AM
  • Update the release version to Clang 14 in cxx_status
  • Remove unused parameter
  • Remove WS only changes
This revision is now accepted and ready to land.Aug 6 2021, 6:50 AM
aaron.ballman closed this revision.Aug 6 2021, 7:28 AM

I've committed on your behalf in 3c8e94bc20e5829ab5167d21d242b6b624dd934e, thank you for the fix!