diff options
author | Tim Shen <timshen@google.com> | 2015-01-22 05:07:03 +0000 |
---|---|---|
committer | Tim Shen <timshen@gcc.gnu.org> | 2015-01-22 05:07:03 +0000 |
commit | 770acfc9e3753d7b9d4727293ac6f16811fa751f (patch) | |
tree | b00ed49b942acb7012c647cf30c9f3a9d17cdbba /libstdc++-v3 | |
parent | 77033d2668248d1050d27ea57a8e85a1b3740ac8 (diff) | |
download | gcc-770acfc9e3753d7b9d4727293ac6f16811fa751f.zip gcc-770acfc9e3753d7b9d4727293ac6f16811fa751f.tar.gz gcc-770acfc9e3753d7b9d4727293ac6f16811fa751f.tar.bz2 |
re PR libstdc++/64680 (basic_regex::operator= does not reset flags)
PR libstdc++/64680
* include/bits/regex.h (basic_regex<>::basic_regex,
basic_regex<>::operator=, basic_regex<>::imbue): Conform to the
standard interface.
* testsuite/28_regex/basic_regex/assign/char/cstring.cc: New testcase.
From-SVN: r219987
Diffstat (limited to 'libstdc++-v3')
-rw-r--r-- | libstdc++-v3/ChangeLog | 8 | ||||
-rw-r--r-- | libstdc++-v3/include/bits/regex.h | 22 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/28_regex/basic_regex/assign/char/cstring.cc | 13 |
3 files changed, 36 insertions, 7 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 099ad8b..e4e9f49 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,5 +1,13 @@ 2015-01-22 Tim Shen <timshen@google.com> + PR libstdc++/64680 + * include/bits/regex.h (basic_regex<>::basic_regex, + basic_regex<>::operator=, basic_regex<>::imbue): Conform to the + standard interface. + * testsuite/28_regex/basic_regex/assign/char/cstring.cc: New testcase. + +2015-01-22 Tim Shen <timshen@google.com> + PR libstdc++/64649 * include/bits/regex.tcc (regex_traits<>::lookup_collatename, regex_traits<>::lookup_classname): Correctly narrow input chars. diff --git a/libstdc++-v3/include/bits/regex.h b/libstdc++-v3/include/bits/regex.h index 6de883a..2b09da6 100644 --- a/libstdc++-v3/include/bits/regex.h +++ b/libstdc++-v3/include/bits/regex.h @@ -442,7 +442,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 */ explicit basic_regex(const _Ch_type* __p, flag_type __f = ECMAScript) - : basic_regex(__p, __p + _Rx_traits::length(__p), __f) + : basic_regex(__p, __p + char_traits<_Ch_type>::length(__p), __f) { } /** @@ -553,7 +553,19 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 */ basic_regex& operator=(const _Ch_type* __p) - { return this->assign(__p, flags()); } + { return this->assign(__p); } + + /** + * @brief Replaces a regular expression with a new one constructed from + * an initializer list. + * + * @param __l The initializer list. + * + * @throws regex_error if @p __l is not a valid regular expression. + */ + basic_regex& + operator=(initializer_list<_Ch_type> __l) + { return this->assign(__l.begin(), __l.end()); } /** * @brief Replaces a regular expression with a new one constructed from @@ -564,7 +576,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 template<typename _Ch_traits, typename _Alloc> basic_regex& operator=(const basic_string<_Ch_type, _Ch_traits, _Alloc>& __s) - { return this->assign(__s, flags()); } + { return this->assign(__s); } // [7.8.3] assign /** @@ -644,7 +656,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 flag_type __flags = ECMAScript) { return this->assign(basic_regex(__s.data(), __s.data() + __s.size(), - _M_loc, _M_flags)); + _M_loc, __flags)); } /** @@ -712,7 +724,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 imbue(locale_type __loc) { std::swap(__loc, _M_loc); - _M_automaton = nullptr; + _M_automaton.reset(); return __loc; } diff --git a/libstdc++-v3/testsuite/28_regex/basic_regex/assign/char/cstring.cc b/libstdc++-v3/testsuite/28_regex/basic_regex/assign/char/cstring.cc index 19528b6..445006b 100644 --- a/libstdc++-v3/testsuite/28_regex/basic_regex/assign/char/cstring.cc +++ b/libstdc++-v3/testsuite/28_regex/basic_regex/assign/char/cstring.cc @@ -1,5 +1,4 @@ -// { dg-do compile } -// { dg-options "-std=gnu++11" } +// { dg-options "-std=c++11" } // 2009-06-05 Stephen M. Webb <stephen.webb@bregmasoft.ca> // @@ -36,9 +35,19 @@ void test01() re.assign(cs); } +// basic_regex::operator=() resets flags. libstdc++/64680 +void test02() +{ + bool test __attribute__((unused)) = true; + + std::regex re("[[:alnum:]]", std::regex_constants::basic); + re = "\\w+"; +} + int main() { test01(); + test02(); return 0; } |