aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorKaveh R. Ghazi <ghazi@caip.rutgers.edu>2000-11-07 22:13:58 +0000
committerKaveh Ghazi <ghazi@gcc.gnu.org>2000-11-07 22:13:58 +0000
commita7c683a887b9e2eaca0028348e7bb5957aed36e2 (patch)
treefc95b4e700de8b8e7ab66106fc43231243cd8be0 /gcc
parent8735550f7fa5757fab10fc858aa4be534b048ad6 (diff)
downloadgcc-a7c683a887b9e2eaca0028348e7bb5957aed36e2.zip
gcc-a7c683a887b9e2eaca0028348e7bb5957aed36e2.tar.gz
gcc-a7c683a887b9e2eaca0028348e7bb5957aed36e2.tar.bz2
* gcc.c-torture/execute/string-opt-1.c: New test.
From-SVN: r37301
Diffstat (limited to 'gcc')
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/gcc.c-torture/execute/string-opt-1.c38
2 files changed, 42 insertions, 0 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 8b2a8725..540d2b9 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2000-11-07 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
+
+ * gcc.c-torture/execute/string-opt-1.c: New test.
+
2000-11-07 Jeffrey Oldham <oldham@oz.codesourcery.com>
* gcc.c-torture/execute/va-arg-15.x: New file. Fails on
diff --git a/gcc/testsuite/gcc.c-torture/execute/string-opt-1.c b/gcc/testsuite/gcc.c-torture/execute/string-opt-1.c
new file mode 100644
index 0000000..e78f328
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/execute/string-opt-1.c
@@ -0,0 +1,38 @@
+/* Copyright (C) 2000 Free Software Foundation.
+
+ Ensure all expected transformations of builtin strstr occur and
+ perform correctly.
+
+ Written by Kaveh R. Ghazi, 11/6/2000. */
+
+extern void abort(void);
+extern char *strstr (const char *, const char *);
+
+int main()
+{
+ const char *const foo = "hello world";
+
+ if (strstr (foo, "") != foo)
+ abort();
+ if (strstr (foo + 4, "") != foo + 4)
+ abort();
+ if (strstr (foo, "h") != foo)
+ abort();
+ if (strstr (foo, "w") != foo + 6)
+ abort();
+ if (strstr (foo + 6, "o") != foo + 7)
+ abort();
+
+ return 0;
+}
+
+#ifdef __OPTIMIZE__
+/* When optimizing, all the above cases should be transformed into
+ something else. So any remaining calls to the original function
+ should abort. */
+char *
+strstr(const char *s1, const char *s2)
+{
+ abort();
+}
+#endif