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
This commit is contained in:
parent
0a1bb917fc
commit
ce94d12f67
14 changed files with 119 additions and 10 deletions
|
@ -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.
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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__
|
||||
|
|
|
@ -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__
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue