summaryrefslogtreecommitdiffstats
path: root/libcxx/test/std/re/re.regex/re.regex.construct
diff options
context:
space:
mode:
authorJF Bastien <jfbastien@apple.com>2019-02-04 20:31:13 +0000
committerJF Bastien <jfbastien@apple.com>2019-02-04 20:31:13 +0000
commit2df59c50688c122bbcae7467d3eaf862c3ea3088 (patch)
tree29c9a3e1c54fe76a506ffecc0cc4d8fbaba5cb04 /libcxx/test/std/re/re.regex/re.regex.construct
parent6fd4e7fe0258ff71fe759535236883ea9060587c (diff)
downloadbcm5719-llvm-2df59c50688c122bbcae7467d3eaf862c3ea3088.tar.gz
bcm5719-llvm-2df59c50688c122bbcae7467d3eaf862c3ea3088.zip
Support tests in freestanding
Summary: Freestanding is *weird*. The standard allows it to differ in a bunch of odd manners from regular C++, and the committee would like to improve that situation. I'd like to make libc++ behave better with what freestanding should be, so that it can be a tool we use in improving the standard. To do that we need to try stuff out, both with "freestanding the language mode" and "freestanding the library subset". Let's start with the super basic: run the libc++ tests in freestanding, using clang as the compiler, and see what works. The easiest hack to do this: In utils/libcxx/test/config.py add: self.cxx.compile_flags += ['-ffreestanding'] Run the tests and they all fail. Why? Because in freestanding `main` isn't special. This "not special" property has two effects: main doesn't get mangled, and main isn't allowed to omit its `return` statement. The first means main gets mangled and the linker can't create a valid executable for us to test. The second means we spew out warnings (ew) and the compiler doesn't insert the `return` we omitted, and main just falls of the end and does whatever undefined behavior (if you're luck, ud2 leading to non-zero return code). Let's start my work with the basics. This patch changes all libc++ tests to declare `main` as `int main(int, char**` so it mangles consistently (enabling us to declare another `extern "C"` main for freestanding which calls the mangled one), and adds `return 0;` to all places where it was missing. This touches 6124 files, and I apologize. The former was done with The Magic Of Sed. The later was done with a (not quite correct but decent) clang tool: https://gist.github.com/jfbastien/793819ff360baa845483dde81170feed This works for most tests, though I did have to adjust a few places when e.g. the test runs with `-x c`, macros are used for main (such as for the filesystem tests), etc. Once this is in we can create a freestanding bot which will prevent further regressions. After that, we can start the real work of supporting C++ freestanding fairly well in libc++. <rdar://problem/47754795> Reviewers: ldionne, mclow.lists, EricWF Subscribers: christof, jkorous, dexonsmith, arphaman, miyuki, libcxx-commits Differential Revision: https://reviews.llvm.org/D57624 llvm-svn: 353086
Diffstat (limited to 'libcxx/test/std/re/re.regex/re.regex.construct')
-rw-r--r--libcxx/test/std/re/re.regex/re.regex.construct/awk_oct.pass.cpp4
-rw-r--r--libcxx/test/std/re/re.regex/re.regex.construct/bad_backref.pass.cpp4
-rw-r--r--libcxx/test/std/re/re.regex/re.regex.construct/bad_ctype.pass.cpp4
-rw-r--r--libcxx/test/std/re/re.regex/re.regex.construct/bad_escape.pass.cpp4
-rw-r--r--libcxx/test/std/re/re.regex/re.regex.construct/bad_repeat.pass.cpp4
-rw-r--r--libcxx/test/std/re/re.regex/re.regex.construct/copy.pass.cpp4
-rw-r--r--libcxx/test/std/re/re.regex/re.regex.construct/deduct.fail.cpp4
-rw-r--r--libcxx/test/std/re/re.regex/re.regex.construct/deduct.pass.cpp4
-rw-r--r--libcxx/test/std/re/re.regex/re.regex.construct/default.pass.cpp4
-rw-r--r--libcxx/test/std/re/re.regex/re.regex.construct/il_flg.pass.cpp4
-rw-r--r--libcxx/test/std/re/re.regex/re.regex.construct/iter_iter.pass.cpp4
-rw-r--r--libcxx/test/std/re/re.regex/re.regex.construct/iter_iter_flg.pass.cpp4
-rw-r--r--libcxx/test/std/re/re.regex/re.regex.construct/ptr.pass.cpp4
-rw-r--r--libcxx/test/std/re/re.regex/re.regex.construct/ptr_flg.pass.cpp4
-rw-r--r--libcxx/test/std/re/re.regex/re.regex.construct/ptr_size.pass.cpp4
-rw-r--r--libcxx/test/std/re/re.regex/re.regex.construct/ptr_size_flg.pass.cpp4
-rw-r--r--libcxx/test/std/re/re.regex/re.regex.construct/string.pass.cpp4
-rw-r--r--libcxx/test/std/re/re.regex/re.regex.construct/string_flg.pass.cpp4
18 files changed, 54 insertions, 18 deletions
diff --git a/libcxx/test/std/re/re.regex/re.regex.construct/awk_oct.pass.cpp b/libcxx/test/std/re/re.regex/re.regex.construct/awk_oct.pass.cpp
index eabf8eab9f2..2e7eed350c0 100644
--- a/libcxx/test/std/re/re.regex/re.regex.construct/awk_oct.pass.cpp
+++ b/libcxx/test/std/re/re.regex/re.regex.construct/awk_oct.pass.cpp
@@ -17,7 +17,7 @@
#include <cassert>
#include "test_macros.h"
-int main()
+int main(int, char**)
{
using std::regex_constants::awk;
@@ -25,4 +25,6 @@ int main()
assert(std::regex_match("\41", std::regex("\\41", awk)));
assert(std::regex_match("\141", std::regex("\\141", awk)));
assert(std::regex_match("\141" "1", std::regex("\\1411", awk)));
+
+ return 0;
}
diff --git a/libcxx/test/std/re/re.regex/re.regex.construct/bad_backref.pass.cpp b/libcxx/test/std/re/re.regex/re.regex.construct/bad_backref.pass.cpp
index cc1b081c7df..0a15b6453c8 100644
--- a/libcxx/test/std/re/re.regex/re.regex.construct/bad_backref.pass.cpp
+++ b/libcxx/test/std/re/re.regex/re.regex.construct/bad_backref.pass.cpp
@@ -29,7 +29,7 @@ static bool error_badbackref_thrown(const char *pat)
return result;
}
-int main()
+int main(int, char**)
{
assert(error_badbackref_thrown("\\1abc")); // no references
assert(error_badbackref_thrown("ab(c)\\2def")); // only one reference
@@ -41,4 +41,6 @@ int main()
const char *pat1 = "a(b)c\\1234";
std::regex re(pat1, pat1 + 7); // extra chars after the end.
}
+
+ return 0;
}
diff --git a/libcxx/test/std/re/re.regex/re.regex.construct/bad_ctype.pass.cpp b/libcxx/test/std/re/re.regex/re.regex.construct/bad_ctype.pass.cpp
index dc24531cb48..5752d5cd681 100644
--- a/libcxx/test/std/re/re.regex/re.regex.construct/bad_ctype.pass.cpp
+++ b/libcxx/test/std/re/re.regex/re.regex.construct/bad_ctype.pass.cpp
@@ -29,8 +29,10 @@ static bool error_ctype_thrown(const char *pat)
return result;
}
-int main()
+int main(int, char**)
{
assert(error_ctype_thrown("[[::]]"));
assert(error_ctype_thrown("[[:error:]]"));
+
+ return 0;
}
diff --git a/libcxx/test/std/re/re.regex/re.regex.construct/bad_escape.pass.cpp b/libcxx/test/std/re/re.regex/re.regex.construct/bad_escape.pass.cpp
index f9e589ce7c7..041d55bdf88 100644
--- a/libcxx/test/std/re/re.regex/re.regex.construct/bad_escape.pass.cpp
+++ b/libcxx/test/std/re/re.regex/re.regex.construct/bad_escape.pass.cpp
@@ -29,7 +29,7 @@ static bool error_escape_thrown(const char *pat)
return result;
}
-int main()
+int main(int, char**)
{
assert(error_escape_thrown("[\\a]"));
assert(error_escape_thrown("\\a"));
@@ -44,4 +44,6 @@ int main()
assert(!error_escape_thrown("[\\cA]"));
assert(!error_escape_thrown("\\cA"));
+
+ return 0;
}
diff --git a/libcxx/test/std/re/re.regex/re.regex.construct/bad_repeat.pass.cpp b/libcxx/test/std/re/re.regex/re.regex.construct/bad_repeat.pass.cpp
index 2d07e1e8cf3..1af8b5ba651 100644
--- a/libcxx/test/std/re/re.regex/re.regex.construct/bad_repeat.pass.cpp
+++ b/libcxx/test/std/re/re.regex/re.regex.construct/bad_repeat.pass.cpp
@@ -29,7 +29,7 @@ static bool error_badrepeat_thrown(const char *pat)
return result;
}
-int main()
+int main(int, char**)
{
assert(error_badrepeat_thrown("?a"));
assert(error_badrepeat_thrown("*a"));
@@ -40,4 +40,6 @@ int main()
assert(error_badrepeat_thrown("*(a+)"));
assert(error_badrepeat_thrown("+(a+)"));
assert(error_badrepeat_thrown("{(a+)"));
+
+ return 0;
}
diff --git a/libcxx/test/std/re/re.regex/re.regex.construct/copy.pass.cpp b/libcxx/test/std/re/re.regex/re.regex.construct/copy.pass.cpp
index 588f673bf4f..f3db8fe0611 100644
--- a/libcxx/test/std/re/re.regex/re.regex.construct/copy.pass.cpp
+++ b/libcxx/test/std/re/re.regex/re.regex.construct/copy.pass.cpp
@@ -16,10 +16,12 @@
#include <cassert>
#include "test_macros.h"
-int main()
+int main(int, char**)
{
std::regex r1("(a([bc]))");
std::regex r2 = r1;
assert(r2.flags() == std::regex::ECMAScript);
assert(r2.mark_count() == 2);
+
+ return 0;
}
diff --git a/libcxx/test/std/re/re.regex/re.regex.construct/deduct.fail.cpp b/libcxx/test/std/re/re.regex/re.regex.construct/deduct.fail.cpp
index 5ece59ad263..30ec49c833b 100644
--- a/libcxx/test/std/re/re.regex/re.regex.construct/deduct.fail.cpp
+++ b/libcxx/test/std/re/re.regex/re.regex.construct/deduct.fail.cpp
@@ -24,7 +24,7 @@
#include <cstddef>
-int main()
+int main(int, char**)
{
// Test the explicit deduction guides
{
@@ -41,4 +41,6 @@ int main()
// Test the implicit deduction guides
+
+ return 0;
}
diff --git a/libcxx/test/std/re/re.regex/re.regex.construct/deduct.pass.cpp b/libcxx/test/std/re/re.regex/re.regex.construct/deduct.pass.cpp
index 5d7493ae640..47e5a1dba7f 100644
--- a/libcxx/test/std/re/re.regex/re.regex.construct/deduct.pass.cpp
+++ b/libcxx/test/std/re/re.regex/re.regex.construct/deduct.pass.cpp
@@ -31,7 +31,7 @@ using namespace std::literals;
struct A {};
-int main()
+int main(int, char**)
{
// Test the explicit deduction guides
@@ -133,4 +133,6 @@ int main()
assert(re.flags() == std::regex_constants::grep);
assert(re.mark_count() == 0);
}
+
+ return 0;
}
diff --git a/libcxx/test/std/re/re.regex/re.regex.construct/default.pass.cpp b/libcxx/test/std/re/re.regex/re.regex.construct/default.pass.cpp
index b5c1521fce5..f706229e683 100644
--- a/libcxx/test/std/re/re.regex/re.regex.construct/default.pass.cpp
+++ b/libcxx/test/std/re/re.regex/re.regex.construct/default.pass.cpp
@@ -25,8 +25,10 @@ test()
assert(r.mark_count() == 0);
}
-int main()
+int main(int, char**)
{
test<char>();
test<wchar_t>();
+
+ return 0;
}
diff --git a/libcxx/test/std/re/re.regex/re.regex.construct/il_flg.pass.cpp b/libcxx/test/std/re/re.regex/re.regex.construct/il_flg.pass.cpp
index aac13147e81..aaf5bc25a7c 100644
--- a/libcxx/test/std/re/re.regex/re.regex.construct/il_flg.pass.cpp
+++ b/libcxx/test/std/re/re.regex/re.regex.construct/il_flg.pass.cpp
@@ -29,7 +29,7 @@ test(std::initializer_list<char> il, std::regex_constants::syntax_option_type f,
}
-int main()
+int main(int, char**)
{
std::string s1("\\(a\\)");
std::string s2("\\(a[bc]\\)");
@@ -65,4 +65,6 @@ int main()
test({'\\', '(', 'a', '[', 'b', 'c', ']', '\\', ')'}, std::regex_constants::egrep, 0);
test({'\\', '(', 'a', '\\', '(', '[', 'b', 'c', ']', '\\', ')', '\\', ')'}, std::regex_constants::egrep, 0);
test({'(', 'a', '(', '[', 'b', 'c', ']', ')', ')'}, std::regex_constants::egrep, 2);
+
+ return 0;
}
diff --git a/libcxx/test/std/re/re.regex/re.regex.construct/iter_iter.pass.cpp b/libcxx/test/std/re/re.regex/re.regex.construct/iter_iter.pass.cpp
index 0b5d0c50413..3dcf29fa009 100644
--- a/libcxx/test/std/re/re.regex/re.regex.construct/iter_iter.pass.cpp
+++ b/libcxx/test/std/re/re.regex/re.regex.construct/iter_iter.pass.cpp
@@ -28,7 +28,7 @@ test(Iter first, Iter last, unsigned mc)
assert(r.mark_count() == mc);
}
-int main()
+int main(int, char**)
{
typedef forward_iterator<std::string::const_iterator> F;
std::string s1("\\(a\\)");
@@ -40,4 +40,6 @@ int main()
test(F(s2.begin()), F(s2.end()), 0);
test(F(s3.begin()), F(s3.end()), 0);
test(F(s4.begin()), F(s4.end()), 2);
+
+ return 0;
}
diff --git a/libcxx/test/std/re/re.regex/re.regex.construct/iter_iter_flg.pass.cpp b/libcxx/test/std/re/re.regex/re.regex.construct/iter_iter_flg.pass.cpp
index 37878347f95..22423c09282 100644
--- a/libcxx/test/std/re/re.regex/re.regex.construct/iter_iter_flg.pass.cpp
+++ b/libcxx/test/std/re/re.regex/re.regex.construct/iter_iter_flg.pass.cpp
@@ -29,7 +29,7 @@ test(Iter first, Iter last, std::regex_constants::syntax_option_type f, unsigned
assert(r.mark_count() == mc);
}
-int main()
+int main(int, char**)
{
typedef forward_iterator<std::string::const_iterator> F;
std::string s1("\\(a\\)");
@@ -66,4 +66,6 @@ int main()
test(F(s2.begin()), F(s2.end()), std::regex_constants::egrep, 0);
test(F(s3.begin()), F(s3.end()), std::regex_constants::egrep, 0);
test(F(s4.begin()), F(s4.end()), std::regex_constants::egrep, 2);
+
+ return 0;
}
diff --git a/libcxx/test/std/re/re.regex/re.regex.construct/ptr.pass.cpp b/libcxx/test/std/re/re.regex/re.regex.construct/ptr.pass.cpp
index 877b9a4c6ee..b71d9eb7f49 100644
--- a/libcxx/test/std/re/re.regex/re.regex.construct/ptr.pass.cpp
+++ b/libcxx/test/std/re/re.regex/re.regex.construct/ptr.pass.cpp
@@ -25,10 +25,12 @@ test(const CharT* p, unsigned mc)
assert(r.mark_count() == mc);
}
-int main()
+int main(int, char**)
{
test("\\(a\\)", 0);
test("\\(a[bc]\\)", 0);
test("\\(a\\([bc]\\)\\)", 0);
test("(a([bc]))", 2);
+
+ return 0;
}
diff --git a/libcxx/test/std/re/re.regex/re.regex.construct/ptr_flg.pass.cpp b/libcxx/test/std/re/re.regex/re.regex.construct/ptr_flg.pass.cpp
index 998f28db892..e918b03116b 100644
--- a/libcxx/test/std/re/re.regex/re.regex.construct/ptr_flg.pass.cpp
+++ b/libcxx/test/std/re/re.regex/re.regex.construct/ptr_flg.pass.cpp
@@ -25,7 +25,7 @@ test(const CharT* p, std::regex_constants::syntax_option_type f, unsigned mc)
assert(r.mark_count() == mc);
}
-int main()
+int main(int, char**)
{
test("\\(a\\)", std::regex_constants::basic, 1);
test("\\(a[bc]\\)", std::regex_constants::basic, 1);
@@ -56,4 +56,6 @@ int main()
test("\\(a[bc]\\)", std::regex_constants::egrep, 0);
test("\\(a\\([bc]\\)\\)", std::regex_constants::egrep, 0);
test("(a([bc]))", std::regex_constants::egrep, 2);
+
+ return 0;
}
diff --git a/libcxx/test/std/re/re.regex/re.regex.construct/ptr_size.pass.cpp b/libcxx/test/std/re/re.regex/re.regex.construct/ptr_size.pass.cpp
index 03a53b76979..29fa3ca57ac 100644
--- a/libcxx/test/std/re/re.regex/re.regex.construct/ptr_size.pass.cpp
+++ b/libcxx/test/std/re/re.regex/re.regex.construct/ptr_size.pass.cpp
@@ -24,7 +24,7 @@ test(const CharT* p, std::size_t len, unsigned mc)
assert(r.mark_count() == mc);
}
-int main()
+int main(int, char**)
{
test("\\(a\\)", 5, 0);
test("\\(a[bc]\\)", 9, 0);
@@ -35,4 +35,6 @@ int main()
test("(\0)(b)(c)(d)", 9, 3);
test("(\0)(b)(c)(d)", 3, 1);
test("(\0)(b)(c)(d)", 0, 0);
+
+ return 0;
}
diff --git a/libcxx/test/std/re/re.regex/re.regex.construct/ptr_size_flg.pass.cpp b/libcxx/test/std/re/re.regex/re.regex.construct/ptr_size_flg.pass.cpp
index 8546c167355..07f3947318e 100644
--- a/libcxx/test/std/re/re.regex/re.regex.construct/ptr_size_flg.pass.cpp
+++ b/libcxx/test/std/re/re.regex/re.regex.construct/ptr_size_flg.pass.cpp
@@ -26,7 +26,7 @@ test(const CharT* p, std::size_t len, std::regex_constants::syntax_option_type f
assert(r.mark_count() == mc);
}
-int main()
+int main(int, char**)
{
test("\\(a\\)", 5, std::regex_constants::basic, 1);
test("\\(a[bc]\\)", 9, std::regex_constants::basic, 1);
@@ -57,4 +57,6 @@ int main()
test("\\(a[bc]\\)", 9, std::regex_constants::egrep, 0);
test("\\(a\\([bc]\\)\\)", 13, std::regex_constants::egrep, 0);
test("(a([bc]))", 9, std::regex_constants::egrep, 2);
+
+ return 0;
}
diff --git a/libcxx/test/std/re/re.regex/re.regex.construct/string.pass.cpp b/libcxx/test/std/re/re.regex/re.regex.construct/string.pass.cpp
index 58f607183e9..ecd0451d82b 100644
--- a/libcxx/test/std/re/re.regex/re.regex.construct/string.pass.cpp
+++ b/libcxx/test/std/re/re.regex/re.regex.construct/string.pass.cpp
@@ -26,10 +26,12 @@ test(const String& p, unsigned mc)
assert(r.mark_count() == mc);
}
-int main()
+int main(int, char**)
{
test(std::string("\\(a\\)"), 0);
test(std::string("\\(a[bc]\\)"), 0);
test(std::string("\\(a\\([bc]\\)\\)"), 0);
test(std::string("(a([bc]))"), 2);
+
+ return 0;
}
diff --git a/libcxx/test/std/re/re.regex/re.regex.construct/string_flg.pass.cpp b/libcxx/test/std/re/re.regex/re.regex.construct/string_flg.pass.cpp
index 6d504db3334..b6bd8c53c5a 100644
--- a/libcxx/test/std/re/re.regex/re.regex.construct/string_flg.pass.cpp
+++ b/libcxx/test/std/re/re.regex/re.regex.construct/string_flg.pass.cpp
@@ -27,7 +27,7 @@ test(const String& p, std::regex_constants::syntax_option_type f, unsigned mc)
assert(r.mark_count() == mc);
}
-int main()
+int main(int, char**)
{
test(std::string("\\(a\\)"), std::regex_constants::basic, 1);
test(std::string("\\(a[bc]\\)"), std::regex_constants::basic, 1);
@@ -58,4 +58,6 @@ int main()
test(std::string("\\(a[bc]\\)"), std::regex_constants::egrep, 0);
test(std::string("\\(a\\([bc]\\)\\)"), std::regex_constants::egrep, 0);
test(std::string("(a([bc]))"), std::regex_constants::egrep, 2);
+
+ return 0;
}
OpenPOWER on IntegriCloud