diff options
author | timshen <timshen@138bc75d-0d04-0410-961f-82ee72b054a4> | 2015-12-15 05:59:01 +0000 |
---|---|---|
committer | timshen <timshen@138bc75d-0d04-0410-961f-82ee72b054a4> | 2015-12-15 05:59:01 +0000 |
commit | 6e9076b9aa8105f4fcc7a00c9c186e5d5a469db2 (patch) | |
tree | f9aea3082ea5ebf65212d12078d3180f90bb8bac /libstdc++-v3 | |
parent | 10698a7cf6497e832681083865817fe4cea5a02d (diff) | |
download | gcc-6e9076b9aa8105f4fcc7a00c9c186e5d5a469db2.tar.gz |
Backport from mainline
2015-12-15 Tim Shen <timshen@google.com>
PR libstdc++/68863
* include/bits/regex_executor.tcc (_Executor::_M_lookahead):
Copy the captured content for lookahead, so that the backreferences
inside can refer to them.
* testsuite/28_regex/algorithms/regex_match/ecma/char/68863.cc:
New testcase.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_9-branch@231643 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3')
-rw-r--r-- | libstdc++-v3/ChangeLog | 12 | ||||
-rw-r--r-- | libstdc++-v3/include/bits/regex_executor.tcc | 5 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/28_regex/algorithms/regex_match/ecma/char/68863.cc | 43 |
3 files changed, 59 insertions, 1 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 70774cce9ab..ddae62f66b2 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,15 @@ +2015-12-15 Tim Shen <timshen@google.com> + + Backport from mainline + 2015-12-15 Tim Shen <timshen@google.com> + + PR libstdc++/68863 + * include/bits/regex_executor.tcc (_Executor::_M_lookahead): + Copy the captured content for lookahead, so that the backreferences + inside can refer to them. + * testsuite/28_regex/algorithms/regex_match/ecma/char/68863.cc: + New testcase. + 2015-10-02 Jonathan Wakely <jwakely@redhat.com> PR libstdc++/65142 diff --git a/libstdc++-v3/include/bits/regex_executor.tcc b/libstdc++-v3/include/bits/regex_executor.tcc index 1dc65435f11..3ef1789febf 100644 --- a/libstdc++-v3/include/bits/regex_executor.tcc +++ b/libstdc++-v3/include/bits/regex_executor.tcc @@ -144,7 +144,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION bool _Executor<_BiIter, _Alloc, _TraitsT, __dfs_mode>:: _M_lookahead(_State<_TraitsT> __state) { - _ResultsVec __what(_M_cur_results.size()); + // Backreferences may refer to captured content. + // We may want to make this faster by not copying, + // but let's not be clever prematurely. + _ResultsVec __what(_M_cur_results); auto __sub = std::unique_ptr<_Executor>(new _Executor(_M_current, _M_end, __what, diff --git a/libstdc++-v3/testsuite/28_regex/algorithms/regex_match/ecma/char/68863.cc b/libstdc++-v3/testsuite/28_regex/algorithms/regex_match/ecma/char/68863.cc new file mode 100644 index 00000000000..9e7a9a73614 --- /dev/null +++ b/libstdc++-v3/testsuite/28_regex/algorithms/regex_match/ecma/char/68863.cc @@ -0,0 +1,43 @@ +// { dg-options "-std=gnu++11" } + +// Copyright (C) 2015 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// 28.11.2 regex_match + +#include <regex> +#include <testsuite_hooks.h> +#include <testsuite_regex.h> + +using namespace __gnu_test; +using namespace std; + +// libstdc++/68863 +void +test01() +{ + bool test __attribute__((unused)) = true; + + VERIFY(!std::regex_match("aa", std::regex("(.)(?!\\1)."))); +} + +int +main() +{ + test01(); + return 0; +} |