Page MenuHomePhabricator

[libc++] Remove some obsolete _LIBCPP_CXX03_LANG
Changes PlannedPublic

Authored by Quuxplusone on Jun 11 2021, 7:44 PM.

Details

Reviewers
ldionne
EricWF
mclow.lists
Group Reviewers
Restricted Project
Summary

Based on this comment from D103753.

We don't pretend to implement a "C++03 library"; no libc++ user should
ever be relying on the fact that e.g. `emplace_back` does NOT exist.

We support GCC only with `-std=c++11` and later.

We support Clang in `-std=c++03` mode, but Clang supports rvalue references,
defaulted member functions, NSDMIs, and variadic templates all as extensions
to C++03.

Conclusion: Several instances of _LIBCPP_CXX03_LANG are unnecessary.

However, it's still true that in `-std=c++03` mode we're not allowed to use
- `std::initializer_list`
- braces around member-initializers
- the `constexpr` or `noexcept` keywords

And I don't think we want to turn on user-visible move constructors;
e.g. today in `-std=c++03` mode,

    std::vector<T> v(1);
    auto w = std::move(v);

visibly calls T's copy ctor.
I think it would be reckless to change that, at least in this particular patch.

Diff Detail

Event Timeline

Quuxplusone requested review of this revision.Jun 11 2021, 7:44 PM
Quuxplusone created this revision.
Herald added 1 blocking reviewer(s): Restricted Project. · View Herald TranscriptJun 11 2021, 7:44 PM
ldionne accepted this revision.Jun 14 2021, 6:02 AM

Thanks for the cleanup.

This revision is now accepted and ready to land.Jun 14 2021, 6:02 AM

Rebase; ready to land on Monday if nobody shouts "stop!" before then.

ldionne requested changes to this revision.Jun 21 2021, 7:59 AM

Thinking about this some more, I believe we need to figure out what to do with the tests. As it stands, this patch doesn't modify the tests at all, which means that the C++11 functionality that will be enabled in C++03 by this patch will never get tested.

One way to go would be to change some UNSUPPORTED: c++03 to UNSUPPORTED: c++03 && !libc++ to acknowledge that we're supporting this in libc++ as an extension.

This revision now requires changes to proceed.Jun 21 2021, 7:59 AM

@ldionne: My impression is that your testing concern applies:

  • YES to things like vector::emplace_back
  • NO to the changes in <bitset>
  • MAYBE to things like vector::push_back(value_type&&)

I think the precedent here is std/utilities/utility/forward/move.pass.cpp — libc++ supports std::move in C++03 as an extension, so our tests for std::move do not say UNSUPPORTED: c++03. Instead, they say nothing: the test is simply supported in all modes. I can go through the tests for these facilities and remove UNSUPPORTED: c++03 where I see it; for example, in std/containers//sequences/deque/deque.modifiers/emplace_back.pass.cpp.

It doesn't make sense to add UNSUPPORTED: c++03 && !libc++ to new code; this is the libc++ test suite, and we do not run it on any other "C++03" libraries. Any other library tested with this test suite should be C++11-or-later already.

I'll also split out the "implementation" changes, that don't have any effects on libcxx/test/, into a separate commit/PR.

Quuxplusone planned changes to this revision.Jun 22 2021, 10:02 AM

Please make sure we test things like vector::emplace_back and vector::push_back(value_type&&) in the test suite (i.e. we remove any UNSUPPORTED: c++03 annotations).