[libcxx] r260527 - Add some tests to ensure that the __regex_word does not conflict with any of ctype_base's values.
Marshall Clow via cfe-commits
cfe-commits at lists.llvm.org
Thu Feb 11 07:23:05 PST 2016
Author: marshall
Date: Thu Feb 11 09:23:04 2016
New Revision: 260527
URL: http://llvm.org/viewvc/llvm-project?rev=260527&view=rev
Log:
Add some tests to ensure that the __regex_word does not conflict with any of ctype_base's values.
Hopefully this will catch cases like https://llvm.org/bugs/show_bug.cgi?id=26476 in the future.
Modified:
libcxx/trunk/test/std/re/re.traits/lookup_classname.pass.cpp
Modified: libcxx/trunk/test/std/re/re.traits/lookup_classname.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/re/re.traits/lookup_classname.pass.cpp?rev=260527&r1=260526&r2=260527&view=diff
==============================================================================
--- libcxx/trunk/test/std/re/re.traits/lookup_classname.pass.cpp (original)
+++ libcxx/trunk/test/std/re/re.traits/lookup_classname.pass.cpp Thu Feb 11 09:23:04 2016
@@ -33,6 +33,19 @@ test(const char_type* A,
int main()
{
+// if __regex_word is not distinct from all the classes, bad things happen
+// See https://llvm.org/bugs/show_bug.cgi?id=26476 for an example.
+ assert((std::ctype_base::space & std::regex_traits<char>::__regex_word) == 0);
+ assert((std::ctype_base::print & std::regex_traits<char>::__regex_word) == 0);
+ assert((std::ctype_base::cntrl & std::regex_traits<char>::__regex_word) == 0);
+ assert((std::ctype_base::upper & std::regex_traits<char>::__regex_word) == 0);
+ assert((std::ctype_base::lower & std::regex_traits<char>::__regex_word) == 0);
+ assert((std::ctype_base::alpha & std::regex_traits<char>::__regex_word) == 0);
+ assert((std::ctype_base::digit & std::regex_traits<char>::__regex_word) == 0);
+ assert((std::ctype_base::punct & std::regex_traits<char>::__regex_word) == 0);
+ assert((std::ctype_base::xdigit & std::regex_traits<char>::__regex_word) == 0);
+ assert((std::ctype_base::blank & std::regex_traits<char>::__regex_word) == 0);
+
test("d", std::ctype_base::digit);
test("D", std::ctype_base::digit);
test("d", std::ctype_base::digit, true);
More information about the cfe-commits
mailing list