Commit ce94d12f by Kaveh R. Ghazi Committed by Kaveh Ghazi

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
parent 0a1bb917
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> 2000-12-26 Geoffrey Keating <geoffk@redhat.com>
* gcc.c-torture/compile/20001226-1.c: New test. * gcc.c-torture/compile/20001226-1.c: New test.
......
...@@ -42,6 +42,11 @@ int main() ...@@ -42,6 +42,11 @@ int main()
if (s_ptr != s_array+1 || *s_ptr != 0) if (s_ptr != s_array+1 || *s_ptr != 0)
abort(); 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; return 0;
} }
......
...@@ -30,6 +30,10 @@ int main() ...@@ -30,6 +30,10 @@ int main()
printf ("\n"); printf ("\n");
printf ("hello world\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; return 0;
} }
......
...@@ -25,6 +25,11 @@ int main() ...@@ -25,6 +25,11 @@ int main()
if (strstr (foo + 1, "world") != foo + 6) if (strstr (foo + 1, "world") != foo + 6)
abort(); 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; return 0;
} }
......
...@@ -63,6 +63,12 @@ int main () ...@@ -63,6 +63,12 @@ int main ()
|| strcmp (dst, "hello world world")) || strcmp (dst, "hello world world"))
abort(); 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; return 0;
} }
......
...@@ -46,6 +46,11 @@ int main () ...@@ -46,6 +46,11 @@ int main ()
if (strspn ("", ++d2+5) != 0 || d2 != dst+1) if (strspn ("", ++d2+5) != 0 || d2 != dst+1)
abort(); 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; return 0;
} }
......
...@@ -46,6 +46,11 @@ int main () ...@@ -46,6 +46,11 @@ int main ()
if (strcspn ("", ++d2+5) != 0 || d2 != dst+1) if (strcspn ("", ++d2+5) != 0 || d2 != dst+1)
abort(); 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; return 0;
} }
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
extern void abort(void); extern void abort(void);
extern char *strpbrk (const char *, const char *); extern char *strpbrk (const char *, const char *);
extern int strcmp (const char *, const char *);
void fn (const char *foo, const char *const *bar) void fn (const char *foo, const char *const *bar)
{ {
...@@ -26,6 +27,11 @@ void fn (const char *foo, const char *const *bar) ...@@ -26,6 +27,11 @@ void fn (const char *foo, const char *const *bar)
abort(); abort();
if (strpbrk (foo + 6, "o") != foo + 7) if (strpbrk (foo + 6, "o") != foo + 7)
abort(); 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() int main()
......
...@@ -9,6 +9,7 @@ extern void abort (void); ...@@ -9,6 +9,7 @@ extern void abort (void);
extern __SIZE_TYPE__ strlen (const char *); extern __SIZE_TYPE__ strlen (const char *);
extern int strcmp (const char *, const char *); extern int strcmp (const char *, const char *);
extern char *strrchr (const char *, int); extern char *strrchr (const char *, int);
extern char *rindex (const char *, int);
int x = 6; int x = 6;
char *bar = "hi world"; char *bar = "hi world";
...@@ -67,11 +68,20 @@ int main() ...@@ -67,11 +68,20 @@ int main()
abort (); abort ();
if (x != 8) if (x != 8)
abort (); abort ();
/* For systems which don't have rindex, we test the __builtin_ /* Test only one instance of rindex since the code path is the same
version to avoid spurious link failures at -O0. We only need to as that of strrchr. */
test one case since everything is handled in the same code path if (rindex ("hello", 'z') != 0)
as builtin strrchr. */ abort ();
if (__builtin_rindex ("hello", 'z') != 0)
/* 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 (); abort ();
return 0; return 0;
...@@ -80,7 +90,14 @@ int main() ...@@ -80,7 +90,14 @@ int main()
static char * static char *
rindex (const char *s, int c) 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 (); abort ();
#else
return strrchr(s, c);
#endif
} }
#ifdef __OPTIMIZE__ #ifdef __OPTIMIZE__
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
extern void abort (void); extern void abort (void);
extern char *strchr (const char *, int); extern char *strchr (const char *, int);
extern char *index (const char *, int);
int main() int main()
{ {
...@@ -20,11 +21,16 @@ int main() ...@@ -20,11 +21,16 @@ int main()
abort (); abort ();
if (strchr (foo, '\0') != foo + 11) if (strchr (foo, '\0') != foo + 11)
abort (); abort ();
/* For systems which don't have index, we test the __builtin_ /* Test only one instance of index since the code path is the same
version to avoid spurious link failures at -O0. We only need to as that of strchr. */
test one case since everything is handled in the same code path if (index ("hello", 'z') != 0)
as builtin strchr. */ abort ();
if (__builtin_index ("hello", 'z') != 0)
/* 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 (); abort ();
return 0; return 0;
...@@ -33,7 +39,14 @@ int main() ...@@ -33,7 +39,14 @@ int main()
static char * static char *
index (const char *s, int c) 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 (); abort ();
#else
return strchr(s, c);
#endif
} }
#ifdef __OPTIMIZE__ #ifdef __OPTIMIZE__
......
...@@ -31,6 +31,13 @@ int main() ...@@ -31,6 +31,13 @@ int main()
if (memcpy (p + 3, "FGHI", 4) != p + 3 || memcmp (p, "A\0CFGHIj", 9)) if (memcpy (p + 3, "FGHI", 4) != p + 3 || memcmp (p, "A\0CFGHIj", 9))
abort (); 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; return 0;
} }
......
...@@ -56,6 +56,12 @@ int main () ...@@ -56,6 +56,12 @@ int main ()
if (strncpy (dst, src, 12) != dst || strcmp (dst, src)) if (strncpy (dst, src, 12) != dst || strcmp (dst, src))
abort(); 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; return 0;
} }
......
...@@ -142,6 +142,11 @@ int main () ...@@ -142,6 +142,11 @@ int main ()
abort(); abort();
#endif #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; return 0;
} }
......
...@@ -33,6 +33,12 @@ int main () ...@@ -33,6 +33,12 @@ int main ()
if (strcat (++d2+5, s1+11) != dst+6 || d2 != dst+1 || strcmp (dst, s1)) if (strcat (++d2+5, s1+11) != dst+6 || d2 != dst+1 || strcmp (dst, s1))
abort(); 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; return 0;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment