aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2009-02-02 12:27:50 +0100
committerJakub Jelinek <jakub@gcc.gnu.org>2009-02-02 12:27:50 +0100
commit43014633b0b9f0e3d2646b6c4ecd75d3830a18b2 (patch)
tree30ad580d32e383e7cccf0f91151153cc29406ac8 /gcc
parentab05897240fb27993741138f137dd096d003058e (diff)
downloadgcc-43014633b0b9f0e3d2646b6c4ecd75d3830a18b2.zip
gcc-43014633b0b9f0e3d2646b6c4ecd75d3830a18b2.tar.gz
gcc-43014633b0b9f0e3d2646b6c4ecd75d3830a18b2.tar.bz2
* lib/target-supports.exp
(check_effective_target_correct_iso_cpp_string_wchar_protos): New. * g++.dg/ext/builtin10.C: New test. * testsuite/21_strings/c_strings/char/3.cc: New test. * testsuite/21_strings/c_strings/wchar_t/3.cc: New test. From-SVN: r143865
Diffstat (limited to 'gcc')
-rw-r--r--gcc/testsuite/ChangeLog6
-rw-r--r--gcc/testsuite/g++.dg/ext/builtin10.C56
-rw-r--r--gcc/testsuite/lib/target-supports.exp19
3 files changed, 80 insertions, 1 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 249f717..c659971a 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,9 @@
+2009-02-02 Jakub Jelinek <jakub@redhat.com>
+
+ * lib/target-supports.exp
+ (check_effective_target_correct_iso_cpp_string_wchar_protos): New.
+ * g++.dg/ext/builtin10.C: New test.
+
2009-02-02 Richard Guenther <rguenther@suse.de>
PR tree-optimization/38937
diff --git a/gcc/testsuite/g++.dg/ext/builtin10.C b/gcc/testsuite/g++.dg/ext/builtin10.C
new file mode 100644
index 0000000..8742223
--- /dev/null
+++ b/gcc/testsuite/g++.dg/ext/builtin10.C
@@ -0,0 +1,56 @@
+// { dg-do compile { target correct_iso_cpp_string_wchar_protos } }
+// { dg-options "-O2 -fdump-tree-optimized" }
+
+#include <cstring>
+
+const void *cv1;
+const char *cc1, *cc2, *cc3, *cc4;
+void *v1;
+char *c1, *c2, *c3, *c4;
+
+void
+f1 (void)
+{
+ cv1 = memchr ("abcba", 'b', 3);
+ cc1 = strchr ("abcba", 'b');
+ cc2 = strrchr ("abcba", 'b');
+ cc3 = strpbrk ("dabc", "abc");
+ cc4 = strstr ("aaabc", "abc");
+}
+
+void
+f2 (void)
+{
+ cv1 = std::memchr ("abcba", 'b', 3);
+ cc1 = std::strchr ("abcba", 'b');
+ cc2 = std::strrchr ("abcba", 'b');
+ cc3 = std::strpbrk ("dabc", "abc");
+ cc4 = std::strstr ("aaabc", "abc");
+}
+
+void
+f3 (void)
+{
+ v1 = memchr ((char *)"abcba", 'b', 3);
+ c1 = strchr ((char *)"abcba", 'b');
+ c2 = strrchr ((char *)"abcba", 'b');
+ c3 = strpbrk ((char *)"dabc", "abc");
+ c4 = strstr ((char *)"aaabc", "abc");
+}
+
+void
+f4 (void)
+{
+ v1 = std::memchr ((char *)"abcba", 'b', 3);
+ c1 = std::strchr ((char *)"abcba", 'b');
+ c2 = std::strrchr ((char *)"abcba", 'b');
+ c3 = std::strpbrk ((char *)"dabc", "abc");
+ c4 = std::strstr ((char *)"aaabc", "abc");
+}
+
+// { dg-final { scan-tree-dump-not "memchr" "optimized" } }
+// { dg-final { scan-tree-dump-not "strchr" "optimized" } }
+// { dg-final { scan-tree-dump-not "strrchr" "optimized" } }
+// { dg-final { scan-tree-dump-not "strpbrk" "optimized" } }
+// { dg-final { scan-tree-dump-not "strstr" "optimized" } }
+// { dg-final { cleanup-tree-dump "optimized" } }
diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp
index aaefa60..12dc685 100644
--- a/gcc/testsuite/lib/target-supports.exp
+++ b/gcc/testsuite/lib/target-supports.exp
@@ -1,4 +1,4 @@
-# Copyright (C) 1999, 2001, 2003, 2004, 2005, 2006, 2007, 2008
+# Copyright (C) 1999, 2001, 2003, 2004, 2005, 2006, 2007, 2008, 2009
# Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
@@ -2815,3 +2815,20 @@ proc check_effective_target_hard_dfp {} {
void foo (void) { z = x + y; }
}]
}
+
+# Return 1 if string.h and wchar.h headers provide C++ requires overloads
+# for strchr etc. functions.
+
+proc check_effective_target_correct_iso_cpp_string_wchar_protos { } {
+ return [check_no_compiler_messages correct_iso_cpp_string_wchar_protos assembly {
+ #include <string.h>
+ #include <wchar.h>
+ #if !defined(__cplusplus) \
+ || !defined(__CORRECT_ISO_CPP_STRING_H_PROTO) \
+ || !defined(__CORRECT_ISO_CPP_WCHAR_H_PROTO)
+ ISO C++ correct string.h and wchar.h protos not supported.
+ #else
+ int i;
+ #endif
+ }]
+}