1 //===----------------------------------------------------------------------===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is dual licensed under the MIT and the University of Illinois Open 6 // Source Licenses. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 10 // <regex> 11 // UNSUPPORTED: libcpp-no-exceptions 12 // UNSUPPORTED: c++98, c++03 13 14 // the "n" in `a{n}` should be within the numeric limits. 15 16 #include <regex> 17 #include <cassert> 18 #include "test_macros.h" 19 main()20int main() { 21 for (std::regex_constants::syntax_option_type op : 22 {std::regex::basic, std::regex::grep}) { 23 try { 24 TEST_IGNORE_NODISCARD std::regex("a\\{100000000000000000\\}", op); 25 assert(false); 26 } catch (const std::regex_error &e) { 27 assert(e.code() == std::regex_constants::error_badbrace); 28 } 29 } 30 for (std::regex_constants::syntax_option_type op : 31 {std::regex::ECMAScript, std::regex::extended, std::regex::egrep, 32 std::regex::awk}) { 33 try { 34 TEST_IGNORE_NODISCARD std::regex("a{100000000000000000}", op); 35 assert(false); 36 } catch (const std::regex_error &e) { 37 assert(e.code() == std::regex_constants::error_badbrace); 38 } 39 } 40 return 0; 41 } 42