Decorate string_view members with nonnull attribute
authorJonathan Wakely <jwakely@redhat.com>
Fri, 15 Jun 2018 16:47:55 +0000 (17:47 +0100)
committerJonathan Wakely <redi@gcc.gnu.org>
Fri, 15 Jun 2018 16:47:55 +0000 (17:47 +0100)
commit36eec25a6fa7c32e36d7f77f85c8acb7ff38a66b
tree5141ae4527a55652b497904a61bf3dc2f23ff62a
parent3438bf7b9f5ce1cfbb7e2419da25e72f109ea480
Decorate string_view members with nonnull attribute

The C++ committee has confirmed that passing a null pointer to the
unary basic_string_view constructor is undefined. This removes the check
from our implementation, and adds the nonnull attribute to warn when the
compiler can detect undefined input.

* include/std/string_view (basic_string_view(const CharT*)): Remove
check for null pointer and add nonnull attribute.
(compare(const CharT*), compare(size_type, size_type, const CharT*))
(find(const CharT*, size_type), rfind(const CharT*, size_type))
(find_first_of(const CharT*, size_type))
(find_last_of(const CharT*, size_type))
(find_first_not_of(const CharT*, size_type))
(find_last_not_of(const CharT*, size_type)): Add nonnull attribute.
* testsuite/21_strings/basic_string_view/cons/char/nonnull.cc: New.
* testsuite/21_strings/basic_string_view/operations/compare/char/
nonnull.cc: New.
* testsuite/21_strings/basic_string_view/operations/find/char/
nonnull.cc: New.
* testsuite/21_strings/basic_string_view/operations/rfind/char/
nonnull.cc: New.

From-SVN: r261638
libstdc++-v3/ChangeLog
libstdc++-v3/include/std/string_view
libstdc++-v3/testsuite/21_strings/basic_string_view/cons/char/nonnull.cc [new file with mode: 0644]
libstdc++-v3/testsuite/21_strings/basic_string_view/cons/wchar_t/nonnull.cc [new file with mode: 0644]
libstdc++-v3/testsuite/21_strings/basic_string_view/operations/compare/char/nonnull.cc [new file with mode: 0644]
libstdc++-v3/testsuite/21_strings/basic_string_view/operations/find/char/nonnull.cc [new file with mode: 0644]
libstdc++-v3/testsuite/21_strings/basic_string_view/operations/rfind/char/nonnull.cc [new file with mode: 0644]