aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorKaveh R. Ghazi <ghazi@caip.rutgers.edu>2000-12-27 15:29:52 +0000
committerKaveh Ghazi <ghazi@gcc.gnu.org>2000-12-27 15:29:52 +0000
commitce94d12f67d02e9772add99f21c1d1abebd82085 (patch)
tree6648e6add43c6bbb62a70d9b05dc47a582d77a25 /gcc
parent0a1bb917fc6358da39f7b7fa9a56e20b64c80f20 (diff)
downloadgcc-ce94d12f67d02e9772add99f21c1d1abebd82085.zip
gcc-ce94d12f67d02e9772add99f21c1d1abebd82085.tar.gz
gcc-ce94d12f67d02e9772add99f21c1d1abebd82085.tar.bz2
stdio-opt-1.c: Test __builtin_ style too.
* gcc.c-torture/execute/stdio-opt-1.c: Test __builtin_ style too. * gcc.c-torture/execute/stdio-opt-2.c: Likewise. * gcc.c-torture/execute/string-opt-1.c: Likewise. * gcc.c-torture/execute/string-opt-2.c: Likewise. * gcc.c-torture/execute/string-opt-3.c: Likewise. * gcc.c-torture/execute/string-opt-4.c: Likewise. * gcc.c-torture/execute/string-opt-6.c: Likewise. * gcc.c-torture/execute/string-opt-7.c: Likewise. * gcc.c-torture/execute/string-opt-8.c: Likewise. * gcc.c-torture/execute/string-opt-9.c: Likewise. * gcc.c-torture/execute/string-opt-10.c: Likewise. * gcc.c-torture/execute/string-opt-11.c: Likewise. * gcc.c-torture/execute/string-opt-12.c: Likewise. * gcc.c-torture/execute/string-opt-3.c: Test rindex. * gcc.c-torture/execute/string-opt-4.c: Test index. From-SVN: r38497
Diffstat (limited to 'gcc')
-rw-r--r--gcc/testsuite/ChangeLog19
-rw-r--r--gcc/testsuite/gcc.c-torture/execute/stdio-opt-1.c5
-rw-r--r--gcc/testsuite/gcc.c-torture/execute/stdio-opt-2.c4
-rw-r--r--gcc/testsuite/gcc.c-torture/execute/string-opt-1.c5
-rw-r--r--gcc/testsuite/gcc.c-torture/execute/string-opt-10.c6
-rw-r--r--gcc/testsuite/gcc.c-torture/execute/string-opt-11.c5
-rw-r--r--gcc/testsuite/gcc.c-torture/execute/string-opt-12.c5
-rw-r--r--gcc/testsuite/gcc.c-torture/execute/string-opt-2.c6
-rw-r--r--gcc/testsuite/gcc.c-torture/execute/string-opt-3.c27
-rw-r--r--gcc/testsuite/gcc.c-torture/execute/string-opt-4.c23
-rw-r--r--gcc/testsuite/gcc.c-torture/execute/string-opt-6.c7
-rw-r--r--gcc/testsuite/gcc.c-torture/execute/string-opt-7.c6
-rw-r--r--gcc/testsuite/gcc.c-torture/execute/string-opt-8.c5
-rw-r--r--gcc/testsuite/gcc.c-torture/execute/string-opt-9.c6
14 files changed, 119 insertions, 10 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index af37582..524b5b1 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,22 @@
+2000-12-27 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
+
+ * gcc.c-torture/execute/stdio-opt-1.c: Test __builtin_ style too.
+ * gcc.c-torture/execute/stdio-opt-2.c: Likewise.
+ * gcc.c-torture/execute/string-opt-1.c: Likewise.
+ * gcc.c-torture/execute/string-opt-2.c: Likewise.
+ * gcc.c-torture/execute/string-opt-3.c: Likewise.
+ * gcc.c-torture/execute/string-opt-4.c: Likewise.
+ * gcc.c-torture/execute/string-opt-6.c: Likewise.
+ * gcc.c-torture/execute/string-opt-7.c: Likewise.
+ * gcc.c-torture/execute/string-opt-8.c: Likewise.
+ * gcc.c-torture/execute/string-opt-9.c: Likewise.
+ * gcc.c-torture/execute/string-opt-10.c: Likewise.
+ * gcc.c-torture/execute/string-opt-11.c: Likewise.
+ * gcc.c-torture/execute/string-opt-12.c: Likewise.
+
+ * gcc.c-torture/execute/string-opt-3.c: Test rindex.
+ * gcc.c-torture/execute/string-opt-4.c: Test index.
+
2000-12-26 Geoffrey Keating <geoffk@redhat.com>
* gcc.c-torture/compile/20001226-1.c: New test.
diff --git a/gcc/testsuite/gcc.c-torture/execute/stdio-opt-1.c b/gcc/testsuite/gcc.c-torture/execute/stdio-opt-1.c
index 6200786..061946f 100644
--- a/gcc/testsuite/gcc.c-torture/execute/stdio-opt-1.c
+++ b/gcc/testsuite/gcc.c-torture/execute/stdio-opt-1.c
@@ -42,6 +42,11 @@ int main()
if (s_ptr != s_array+1 || *s_ptr != 0)
abort();
+ /* Test at least one instance of the __builtin_ style. We do this
+ to ensure that it works and that the prototype is correct. */
+ s_ptr = s_array;
+ __builtin_fputs ("", *s_ptr);
+
return 0;
}
diff --git a/gcc/testsuite/gcc.c-torture/execute/stdio-opt-2.c b/gcc/testsuite/gcc.c-torture/execute/stdio-opt-2.c
index b7bfd33..1e30336 100644
--- a/gcc/testsuite/gcc.c-torture/execute/stdio-opt-2.c
+++ b/gcc/testsuite/gcc.c-torture/execute/stdio-opt-2.c
@@ -30,6 +30,10 @@ int main()
printf ("\n");
printf ("hello world\n");
+ /* Test at least one instance of the __builtin_ style. We do this
+ to ensure that it works and that the prototype is correct. */
+ __builtin_printf ("%s\n", "hello");
+
return 0;
}
diff --git a/gcc/testsuite/gcc.c-torture/execute/string-opt-1.c b/gcc/testsuite/gcc.c-torture/execute/string-opt-1.c
index 058d594..2210a04 100644
--- a/gcc/testsuite/gcc.c-torture/execute/string-opt-1.c
+++ b/gcc/testsuite/gcc.c-torture/execute/string-opt-1.c
@@ -25,6 +25,11 @@ int main()
if (strstr (foo + 1, "world") != foo + 6)
abort();
+ /* Test at least one instance of the __builtin_ style. We do this
+ to ensure that it works and that the prototype is correct. */
+ if (__builtin_strstr (foo + 1, "world") != foo + 6)
+ abort();
+
return 0;
}
diff --git a/gcc/testsuite/gcc.c-torture/execute/string-opt-10.c b/gcc/testsuite/gcc.c-torture/execute/string-opt-10.c
index 3949bb8..e1a271d 100644
--- a/gcc/testsuite/gcc.c-torture/execute/string-opt-10.c
+++ b/gcc/testsuite/gcc.c-torture/execute/string-opt-10.c
@@ -63,6 +63,12 @@ int main ()
|| strcmp (dst, "hello world world"))
abort();
+ /* Test at least one instance of the __builtin_ style. We do this
+ to ensure that it works and that the prototype is correct. */
+ strcpy (dst, s1);
+ if (__builtin_strncat (dst, "", 100) != dst || strcmp (dst, s1))
+ abort();
+
return 0;
}
diff --git a/gcc/testsuite/gcc.c-torture/execute/string-opt-11.c b/gcc/testsuite/gcc.c-torture/execute/string-opt-11.c
index b17e4c1..cad19c9 100644
--- a/gcc/testsuite/gcc.c-torture/execute/string-opt-11.c
+++ b/gcc/testsuite/gcc.c-torture/execute/string-opt-11.c
@@ -46,6 +46,11 @@ int main ()
if (strspn ("", ++d2+5) != 0 || d2 != dst+1)
abort();
+ /* Test at least one instance of the __builtin_ style. We do this
+ to ensure that it works and that the prototype is correct. */
+ if (__builtin_strspn (s1, "hello") != 5)
+ abort();
+
return 0;
}
diff --git a/gcc/testsuite/gcc.c-torture/execute/string-opt-12.c b/gcc/testsuite/gcc.c-torture/execute/string-opt-12.c
index ebe47e5..b9df9c2 100644
--- a/gcc/testsuite/gcc.c-torture/execute/string-opt-12.c
+++ b/gcc/testsuite/gcc.c-torture/execute/string-opt-12.c
@@ -46,6 +46,11 @@ int main ()
if (strcspn ("", ++d2+5) != 0 || d2 != dst+1)
abort();
+ /* Test at least one instance of the __builtin_ style. We do this
+ to ensure that it works and that the prototype is correct. */
+ if (__builtin_strcspn (s1, "z") != 11)
+ abort();
+
return 0;
}
diff --git a/gcc/testsuite/gcc.c-torture/execute/string-opt-2.c b/gcc/testsuite/gcc.c-torture/execute/string-opt-2.c
index 29e9af0..7b9bcbf 100644
--- a/gcc/testsuite/gcc.c-torture/execute/string-opt-2.c
+++ b/gcc/testsuite/gcc.c-torture/execute/string-opt-2.c
@@ -7,6 +7,7 @@
extern void abort(void);
extern char *strpbrk (const char *, const char *);
+extern int strcmp (const char *, const char *);
void fn (const char *foo, const char *const *bar)
{
@@ -26,6 +27,11 @@ void fn (const char *foo, const char *const *bar)
abort();
if (strpbrk (foo + 6, "o") != foo + 7)
abort();
+
+ /* Test at least one instance of the __builtin_ style. We do this
+ to ensure that it works and that the prototype is correct. */
+ if (__builtin_strpbrk (foo + 6, "o") != foo + 7)
+ abort();
}
int main()
diff --git a/gcc/testsuite/gcc.c-torture/execute/string-opt-3.c b/gcc/testsuite/gcc.c-torture/execute/string-opt-3.c
index 5f27399..61718f2 100644
--- a/gcc/testsuite/gcc.c-torture/execute/string-opt-3.c
+++ b/gcc/testsuite/gcc.c-torture/execute/string-opt-3.c
@@ -9,6 +9,7 @@ extern void abort (void);
extern __SIZE_TYPE__ strlen (const char *);
extern int strcmp (const char *, const char *);
extern char *strrchr (const char *, int);
+extern char *rindex (const char *, int);
int x = 6;
char *bar = "hi world";
@@ -67,11 +68,20 @@ int main()
abort ();
if (x != 8)
abort ();
- /* For systems which don't have rindex, we test the __builtin_
- version to avoid spurious link failures at -O0. We only need to
- test one case since everything is handled in the same code path
- as builtin strrchr. */
- if (__builtin_rindex ("hello", 'z') != 0)
+ /* Test only one instance of rindex since the code path is the same
+ as that of strrchr. */
+ if (rindex ("hello", 'z') != 0)
+ abort ();
+
+ /* Test at least one instance of the __builtin_ style. We do this
+ to ensure that it works and that the prototype is correct. */
+ if (__builtin_rindex (foo, 'o') != foo + 7)
+ abort ();
+ if (__builtin_strrchr (foo, 'o') != foo + 7)
+ abort ();
+ if (__builtin_strlen (foo) != 11)
+ abort ();
+ if (__builtin_strcmp (foo, "hello") <= 0)
abort ();
return 0;
@@ -80,7 +90,14 @@ int main()
static char *
rindex (const char *s, int c)
{
+ /* For systems which don't have rindex, we ensure no link failures
+ occur by always providing a backup definition. During
+ optimization this function aborts to catch errors. */
+#ifdef __OPTIMIZE__
abort ();
+#else
+ return strrchr(s, c);
+#endif
}
#ifdef __OPTIMIZE__
diff --git a/gcc/testsuite/gcc.c-torture/execute/string-opt-4.c b/gcc/testsuite/gcc.c-torture/execute/string-opt-4.c
index 77c0950..d82bb69 100644
--- a/gcc/testsuite/gcc.c-torture/execute/string-opt-4.c
+++ b/gcc/testsuite/gcc.c-torture/execute/string-opt-4.c
@@ -7,6 +7,7 @@
extern void abort (void);
extern char *strchr (const char *, int);
+extern char *index (const char *, int);
int main()
{
@@ -20,11 +21,16 @@ int main()
abort ();
if (strchr (foo, '\0') != foo + 11)
abort ();
- /* For systems which don't have index, we test the __builtin_
- version to avoid spurious link failures at -O0. We only need to
- test one case since everything is handled in the same code path
- as builtin strchr. */
- if (__builtin_index ("hello", 'z') != 0)
+ /* Test only one instance of index since the code path is the same
+ as that of strchr. */
+ if (index ("hello", 'z') != 0)
+ abort ();
+
+ /* Test at least one instance of the __builtin_ style. We do this
+ to ensure that it works and that the prototype is correct. */
+ if (__builtin_strchr (foo, 'o') != foo + 4)
+ abort ();
+ if (__builtin_index (foo, 'o') != foo + 4)
abort ();
return 0;
@@ -33,7 +39,14 @@ int main()
static char *
index (const char *s, int c)
{
+ /* For systems which don't have index, we ensure no link failures
+ occur by always providing a backup definition. During
+ optimization this function aborts to catch errors. */
+#ifdef __OPTIMIZE__
abort ();
+#else
+ return strchr(s, c);
+#endif
}
#ifdef __OPTIMIZE__
diff --git a/gcc/testsuite/gcc.c-torture/execute/string-opt-6.c b/gcc/testsuite/gcc.c-torture/execute/string-opt-6.c
index 781d96f..efd502f 100644
--- a/gcc/testsuite/gcc.c-torture/execute/string-opt-6.c
+++ b/gcc/testsuite/gcc.c-torture/execute/string-opt-6.c
@@ -31,6 +31,13 @@ int main()
if (memcpy (p + 3, "FGHI", 4) != p + 3 || memcmp (p, "A\0CFGHIj", 9))
abort ();
+ /* Test at least one instance of the __builtin_ style. We do this
+ to ensure that it works and that the prototype is correct. */
+ if (__builtin_strcpy (p, "abcde") != p || memcmp (p, "abcde", 6))
+ abort ();
+ if (__builtin_memcpy (p, "ABCDE", 6) != p || memcmp (p, "ABCDE", 6))
+ abort ();
+
return 0;
}
diff --git a/gcc/testsuite/gcc.c-torture/execute/string-opt-7.c b/gcc/testsuite/gcc.c-torture/execute/string-opt-7.c
index 105b3dc..144d9f1 100644
--- a/gcc/testsuite/gcc.c-torture/execute/string-opt-7.c
+++ b/gcc/testsuite/gcc.c-torture/execute/string-opt-7.c
@@ -56,6 +56,12 @@ int main ()
if (strncpy (dst, src, 12) != dst || strcmp (dst, src))
abort();
+ /* Test at least one instance of the __builtin_ style. We do this
+ to ensure that it works and that the prototype is correct. */
+ memset (dst, 0, sizeof (dst));
+ if (__builtin_strncpy (dst, src, 4) != dst || strncmp (dst, src, 4))
+ abort();
+
return 0;
}
diff --git a/gcc/testsuite/gcc.c-torture/execute/string-opt-8.c b/gcc/testsuite/gcc.c-torture/execute/string-opt-8.c
index 4c3c0d4..6a4edb5 100644
--- a/gcc/testsuite/gcc.c-torture/execute/string-opt-8.c
+++ b/gcc/testsuite/gcc.c-torture/execute/string-opt-8.c
@@ -142,6 +142,11 @@ int main ()
abort();
#endif
+ /* Test at least one instance of the __builtin_ style. We do this
+ to ensure that it works and that the prototype is correct. */
+ if (__builtin_strncmp ("hello", "a", 100) <= 0)
+ abort();
+
return 0;
}
diff --git a/gcc/testsuite/gcc.c-torture/execute/string-opt-9.c b/gcc/testsuite/gcc.c-torture/execute/string-opt-9.c
index c1174d9..ba248a0 100644
--- a/gcc/testsuite/gcc.c-torture/execute/string-opt-9.c
+++ b/gcc/testsuite/gcc.c-torture/execute/string-opt-9.c
@@ -33,6 +33,12 @@ int main ()
if (strcat (++d2+5, s1+11) != dst+6 || d2 != dst+1 || strcmp (dst, s1))
abort();
+ /* Test at least one instance of the __builtin_ style. We do this
+ to ensure that it works and that the prototype is correct. */
+ strcpy (dst, s1);
+ if (__builtin_strcat (dst, "") != dst || strcmp (dst, s1))
+ abort();
+
return 0;
}