stdio-opt-1.c: Test __builtin_ style too.
authorKaveh R. Ghazi <ghazi@caip.rutgers.edu>
Wed, 27 Dec 2000 15:29:52 +0000 (15:29 +0000)
committerKaveh Ghazi <ghazi@gcc.gnu.org>
Wed, 27 Dec 2000 15:29:52 +0000 (15:29 +0000)
* 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

14 files changed:
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/execute/stdio-opt-1.c
gcc/testsuite/gcc.c-torture/execute/stdio-opt-2.c
gcc/testsuite/gcc.c-torture/execute/string-opt-1.c
gcc/testsuite/gcc.c-torture/execute/string-opt-10.c
gcc/testsuite/gcc.c-torture/execute/string-opt-11.c
gcc/testsuite/gcc.c-torture/execute/string-opt-12.c
gcc/testsuite/gcc.c-torture/execute/string-opt-2.c
gcc/testsuite/gcc.c-torture/execute/string-opt-3.c
gcc/testsuite/gcc.c-torture/execute/string-opt-4.c
gcc/testsuite/gcc.c-torture/execute/string-opt-6.c
gcc/testsuite/gcc.c-torture/execute/string-opt-7.c
gcc/testsuite/gcc.c-torture/execute/string-opt-8.c
gcc/testsuite/gcc.c-torture/execute/string-opt-9.c

index af375824f46c6aa43b72846baf6fa3239ff9a2a9..524b5b1571166ba0d5387eed7dea1408ef4446eb 100644 (file)
@@ -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.
index 620078648a494680ce2814b5fe5edd20c60a485d..061946fd2af684b43099c49c7b866e866d81f4d7 100644 (file)
@@ -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;
 }
 
index b7bfd33b05dbb7a7b6c3cd02e702186fff6eab7c..1e303361a116e109fca33943878b3faae9012067 100644 (file)
@@ -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;
 }
 
index 058d5943f584e15418ea97f443e29464143e236a..2210a04e29704b7df6576f531a3b1e5c7870b3b3 100644 (file)
@@ -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;
 }
 
index 3949bb8ae03e63944db93cc7e931c54291770a5b..e1a271d0aeb8c84d6cc79471cfde00354734aed5 100644 (file)
@@ -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;
 }
 
index b17e4c1027f1896d8292f698dc50cbb387dc1233..cad19c945b29ea23f6d6dc0b690eeaf660adc86f 100644 (file)
@@ -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;
 }
 
index ebe47e5b0e3a72c811eb0e69d49ab514bd05d418..b9df9c2d1cb36ad233b77a5d1aebef7bc84f8375 100644 (file)
@@ -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;
 }
 
index 29e9af07d917b005a8238630614bc0e5a3aab003..7b9bcbf873dfeb5d62b09050543160842ea92d78 100644 (file)
@@ -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()
index 5f273996d9bab0eebd780973d0404ad50e548b3f..61718f2900f6ffa5e73bd4c4aba45c016528ecc6 100644 (file)
@@ -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__
index 77c0950ff7e251fa22d42b67249bc8ed40d83755..d82bb69a2abac98e8e0f39af50f26fea47c5e054 100644 (file)
@@ -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__
index 781d96f1dcf6a59032495f36851efefe386efd81..efd502f7b8311187bbb50af298dce547e274f646 100644 (file)
@@ -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;
 }
 
index 105b3dc95ba14db3286adff724b930c69ea4916d..144d9f110729cebd3fdff41dabad1e5444385039 100644 (file)
@@ -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;
 }
 
index 4c3c0d44eed3d0e2e48d9f95f681cc5a1aefabb5..6a4edb5d6411873721b6da5df8bae6857d19f782 100644 (file)
@@ -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;
 }
 
index c1174d90f2c1fc7a060cae5d5558fd4b84ebe8f5..ba248a06ad745ff2db2a1012bd66a743472eb45e 100644 (file)
@@ -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;
 }