This is an archive of the discontinued LLVM Phabricator instance.

Handle tests for noexcept that expect a false value
ClosedPublic

Authored by rogfer01 on Dec 1 2016, 10:21 AM.

Details

Summary

Under libcpp-no-exceptions, noexcept is trivially true. Some tests expect in the usual setting to return false. Wrap these tests in a convenience macro.

Diff Detail

Repository
rL LLVM

Event Timeline

rogfer01 updated this revision to Diff 79944.Dec 1 2016, 10:21 AM
rogfer01 retitled this revision from to Handle tests for noexcept that expect a false value.
rogfer01 updated this object.
rogfer01 added reviewers: EricWF, mclow.lists, rmaprath.
rogfer01 added a subscriber: cfe-commits.
EricWF accepted this revision.Dec 2 2016, 11:19 PM
EricWF edited edge metadata.

Have you tested this against GCC which has different noexcept semantics?

If so this LGTM minus possibly addressing the inline comments.

test/libcxx/strings/iterators.exceptions.pass.cpp
55 ↗(On Diff #79944)

I would prefer something like this if possible:

#ifndef TEST_HAS_NO_EXCEPTIONS
static const bool expect = false;
#else
static const bool expect = true;
#endif
static_assert(std::__libcpp_string_gets_noexcept_iterator<...>::value == expect);

(Also the double negation of TEST_FOR_FALSE(!foo) is weird)

This revision is now accepted and ready to land.Dec 2 2016, 11:19 PM
rogfer01 updated this revision to Diff 80235.Dec 5 2016, 1:31 AM
rogfer01 edited edge metadata.
  • Rewrite the adjusted tests in the way suggested by @EricWF
  • Also check that this test works in a GCC-built libcxx
EricWF added a comment.Dec 5 2016, 1:34 AM

Please address the inline comments before committing.

test/libcxx/strings/iterators.exceptions.pass.cpp
29 ↗(On Diff #80235)

We can't use constexpr because these tests run in C++03. However const bool expected = ... should give you a value you can use in constant expressions.

rogfer01 added inline comments.Dec 5 2016, 1:36 AM
test/libcxx/strings/iterators.exceptions.pass.cpp
29 ↗(On Diff #80235)

Ah, I was confused by the usage of C++11 headers in this file but I will use a static const bool instead. Thanks.

EricWF added inline comments.Dec 5 2016, 1:43 AM
test/libcxx/strings/iterators.exceptions.pass.cpp
29 ↗(On Diff #80235)

No worries. It is super confusing, especially since we can use static_assert but not constexpr. Libc++ goes out of its way to provide as much C++11 in C++03 as possible, but there are weird limitations.

rogfer01 updated this revision to Diff 80238.Dec 5 2016, 2:00 AM

Do not use constexpr.

This revision was automatically updated to reflect the committed changes.