1 //===----------------------------------------------------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // UNSUPPORTED: libcpp-no-exceptions
13 // template <class charT, class traits = regex_traits<charT>> class basic_regex;
15 // template <class ST, class SA>
16 // basic_regex(const basic_string<charT, ST, SA>& s);
20 #include "test_macros.h"
22 static bool error_badbackref_thrown(const char *pat)
27 } catch (const std::regex_error &ex) {
28 result = (ex.code() == std::regex_constants::error_backref);
35 assert(error_badbackref_thrown("\\1abc")); // no references
36 assert(error_badbackref_thrown("ab(c)\\2def")); // only one reference
38 // this should NOT throw, because we only should look at the '1'
39 // See https://llvm.org/bugs/show_bug.cgi?id=31387
41 const char *pat1 = "a(b)c\\1234";
42 std::regex re(pat1, pat1 + 7); // extra chars after the end.