From 50c6431753ab7961b4330c5f3c7e611ad81e9178 Mon Sep 17 00:00:00 2001 From: Zack Weinberg Date: Sat, 3 Jul 2004 02:16:50 +0000 Subject: [PATCH] * gcc.c-torture/execute/builtin-abs-1.c * gcc.c-torture/execute/builtin-abs-2.c * gcc.c-torture/execute/builtin-complex-1.c * gcc.c-torture/execute/builtins/string-1-lib.c * gcc.c-torture/execute/builtins/string-1.c * gcc.c-torture/execute/builtins/string-2-lib.c * gcc.c-torture/execute/builtins/string-2.c * gcc.c-torture/execute/builtins/string-3-lib.c * gcc.c-torture/execute/builtins/string-3.c * gcc.c-torture/execute/builtins/string-4-lib.c * gcc.c-torture/execute/builtins/string-4.c * gcc.c-torture/execute/builtins/string-5-lib.c * gcc.c-torture/execute/builtins/string-5.c * gcc.c-torture/execute/builtins/string-6-lib.c * gcc.c-torture/execute/builtins/string-6.c * gcc.c-torture/execute/builtins/string-7-lib.c * gcc.c-torture/execute/builtins/string-7.c * gcc.c-torture/execute/builtins/string-8-lib.c * gcc.c-torture/execute/builtins/string-8.c * gcc.c-torture/execute/builtins/string-9-lib.c * gcc.c-torture/execute/builtins/string-9.c * gcc.c-torture/execute/builtins/string-asm-1-lib.c * gcc.c-torture/execute/builtins/string-asm-1.c * gcc.c-torture/execute/builtins/string-asm-2-lib.c * gcc.c-torture/execute/builtins/string-asm-2.c * gcc.c-torture/execute/stdio-opt-1.c * gcc.c-torture/execute/stdio-opt-2.c * gcc.c-torture/execute/stdio-opt-3.c * gcc.c-torture/execute/string-opt-1.c * gcc.c-torture/execute/string-opt-10.c * gcc.c-torture/execute/string-opt-11.c * gcc.c-torture/execute/string-opt-12.c * gcc.c-torture/execute/string-opt-13.c * gcc.c-torture/execute/string-opt-14.c * gcc.c-torture/execute/string-opt-15.c * gcc.c-torture/execute/string-opt-16.c * gcc.c-torture/execute/string-opt-2.c * gcc.c-torture/execute/string-opt-6.c * gcc.c-torture/execute/string-opt-7.c * gcc.c-torture/execute/string-opt-8.c: Replace with ... * gcc.c-torture/execute/builtins/abs-2.c * gcc.c-torture/execute/builtins/abs-3.c * gcc.c-torture/execute/builtins/complex-1.c * gcc.c-torture/execute/builtins/fprintf.c * gcc.c-torture/execute/builtins/fputs.c * gcc.c-torture/execute/builtins/memcmp.c * gcc.c-torture/execute/builtins/memmove.c * gcc.c-torture/execute/builtins/memops-asm.c * gcc.c-torture/execute/builtins/mempcpy-2.c * gcc.c-torture/execute/builtins/mempcpy.c * gcc.c-torture/execute/builtins/memset.c * gcc.c-torture/execute/builtins/printf.c * gcc.c-torture/execute/builtins/sprintf.c * gcc.c-torture/execute/builtins/strcat.c * gcc.c-torture/execute/builtins/strchr.c * gcc.c-torture/execute/builtins/strcmp.c * gcc.c-torture/execute/builtins/strcpy.c * gcc.c-torture/execute/builtins/strcspn.c * gcc.c-torture/execute/builtins/strlen-2.c * gcc.c-torture/execute/builtins/strlen.c * gcc.c-torture/execute/builtins/strncat.c * gcc.c-torture/execute/builtins/strncmp-2.c * gcc.c-torture/execute/builtins/strncmp.c * gcc.c-torture/execute/builtins/strncpy.c * gcc.c-torture/execute/builtins/strpbrk.c * gcc.c-torture/execute/builtins/strpcpy-2.c * gcc.c-torture/execute/builtins/strpcpy.c * gcc.c-torture/execute/builtins/strrchr.c * gcc.c-torture/execute/builtins/strspn.c * gcc.c-torture/execute/builtins/strstr-asm.c * gcc.c-torture/execute/builtins/strstr.c: ... these new files. * gcc.c-torture/execute/builtins/abs-2-lib.c * gcc.c-torture/execute/builtins/abs-3-lib.c * gcc.c-torture/execute/builtins/complex-1-lib.c * gcc.c-torture/execute/builtins/fprintf-lib.c * gcc.c-torture/execute/builtins/fputs-lib.c * gcc.c-torture/execute/builtins/memcmp-lib.c * gcc.c-torture/execute/builtins/memmove-lib.c * gcc.c-torture/execute/builtins/memops-asm-lib.c * gcc.c-torture/execute/builtins/mempcpy-2-lib.c * gcc.c-torture/execute/builtins/mempcpy-lib.c * gcc.c-torture/execute/builtins/memset-lib.c * gcc.c-torture/execute/builtins/printf-lib.c * gcc.c-torture/execute/builtins/sprintf-lib.c * gcc.c-torture/execute/builtins/strcat-lib.c * gcc.c-torture/execute/builtins/strchr-lib.c * gcc.c-torture/execute/builtins/strcmp-lib.c * gcc.c-torture/execute/builtins/strcpy-lib.c * gcc.c-torture/execute/builtins/strcspn-lib.c * gcc.c-torture/execute/builtins/strlen-2-lib.c * gcc.c-torture/execute/builtins/strlen-lib.c * gcc.c-torture/execute/builtins/strncat-lib.c * gcc.c-torture/execute/builtins/strncmp-2-lib.c * gcc.c-torture/execute/builtins/strncmp-lib.c * gcc.c-torture/execute/builtins/strncpy-lib.c * gcc.c-torture/execute/builtins/strpbrk-lib.c * gcc.c-torture/execute/builtins/strpcpy-2-lib.c * gcc.c-torture/execute/builtins/strpcpy-lib.c * gcc.c-torture/execute/builtins/strrchr-lib.c * gcc.c-torture/execute/builtins/strspn-lib.c * gcc.c-torture/execute/builtins/strstr-asm-lib.c * gcc.c-torture/execute/builtins/strstr-lib.c * gcc.c-torture/execute/builtins/lib/abs.c * gcc.c-torture/execute/builtins/lib/fprintf.c * gcc.c-torture/execute/builtins/lib/memset.c * gcc.c-torture/execute/builtins/lib/printf.c * gcc.c-torture/execute/builtins/lib/sprintf.c * gcc.c-torture/execute/builtins/lib/strcpy.c * gcc.c-torture/execute/builtins/lib/strcspn.c * gcc.c-torture/execute/builtins/lib/strncat.c * gcc.c-torture/execute/builtins/lib/strncmp.c * gcc.c-torture/execute/builtins/lib/strncpy.c * gcc.c-torture/execute/builtins/lib/strpbrk.c * gcc.c-torture/execute/builtins/lib/strspn.c * gcc.c-torture/execute/builtins/lib/strstr.c: New files containing support routines. * gcc.c-torture/execute/builtins/abs-1.c: Remove unnecessary declaration. * gcc.c-torture/execute/builtins/lib/main.c: Define link_error when not optimizing. From-SVN: r84044 --- gcc/testsuite/ChangeLog | 128 ++++++++++++++++++ .../gcc.c-torture/execute/builtins/abs-1.c | 1 - .../execute/builtins/abs-2-lib.c | 1 + .../{builtin-abs-1.c => builtins/abs-2.c} | 89 ++++-------- .../execute/builtins/abs-3-lib.c | 1 + .../{builtin-abs-2.c => builtins/abs-3.c} | 89 ++++-------- .../execute/builtins/complex-1-lib.c | 70 ++++++++++ .../complex-1.c} | 115 +++------------- .../execute/builtins/fprintf-lib.c | 1 + .../{stdio-opt-3.c => builtins/fprintf.c} | 18 +-- .../execute/builtins/fputs-lib.c | 17 +++ .../{stdio-opt-1.c => builtins/fputs.c} | 21 +-- .../gcc.c-torture/execute/builtins/lib/abs.c | 50 +++++++ .../execute/builtins/lib/fprintf.c | 18 +++ .../gcc.c-torture/execute/builtins/lib/main.c | 12 ++ .../builtins/{string-3-lib.c => lib/memset.c} | 0 .../execute/builtins/lib/printf.c | 19 +++ .../execute/builtins/lib/sprintf.c | 20 +++ .../execute/builtins/lib/strcpy.c | 13 ++ .../execute/builtins/lib/strcspn.c | 20 +++ .../execute/builtins/lib/strncat.c | 26 ++++ .../execute/builtins/lib/strncmp.c | 25 ++++ .../execute/builtins/lib/strncpy.c | 19 +++ .../execute/builtins/lib/strpbrk.c | 19 +++ .../execute/builtins/lib/strspn.c | 23 ++++ .../execute/builtins/lib/strstr.c | 27 ++++ .../builtins/{string-6-lib.c => memcmp-lib.c} | 0 .../{string-opt-15.c => builtins/memcmp.c} | 28 ++-- .../{string-5-lib.c => memmove-lib.c} | 0 .../builtins/{string-5.c => memmove.c} | 0 .../{string-asm-2-lib.c => memops-asm-lib.c} | 0 .../builtins/{string-asm-2.c => memops-asm.c} | 0 .../{string-4-lib.c => mempcpy-2-lib.c} | 1 - .../builtins/{string-7.c => mempcpy-2.c} | 18 +-- .../{string-7-lib.c => mempcpy-lib.c} | 1 - .../builtins/{string-4.c => mempcpy.c} | 44 ++---- .../execute/builtins/memset-lib.c | 1 + .../execute/builtins/{string-3.c => memset.c} | 0 .../execute/builtins/printf-lib.c | 1 + .../{stdio-opt-2.c => builtins/printf.c} | 17 +-- .../execute/builtins/sprintf-lib.c | 1 + .../{string-opt-16.c => builtins/sprintf.c} | 18 +-- .../builtins/{string-9-lib.c => strcat-lib.c} | 0 .../execute/builtins/{string-9.c => strcat.c} | 0 .../builtins/{string-2-lib.c => strchr-lib.c} | 0 .../execute/builtins/{string-2.c => strchr.c} | 0 .../execute/builtins/strcmp-lib.c | 1 + .../gcc.c-torture/execute/builtins/strcmp.c | 48 +++++++ .../execute/builtins/strcpy-lib.c | 1 + .../{string-opt-6.c => builtins/strcpy.c} | 17 +-- .../execute/builtins/strcspn-lib.c | 1 + .../{string-opt-12.c => builtins/strcspn.c} | 19 +-- .../execute/builtins/string-1-lib.c | 3 - .../gcc.c-torture/execute/builtins/string-1.c | 87 ------------ .../gcc.c-torture/execute/builtins/string-6.c | 34 ----- .../{string-8-lib.c => strlen-2-lib.c} | 0 .../builtins/{string-8.c => strlen-2.c} | 1 - .../execute/builtins/strlen-lib.c | 1 + .../gcc.c-torture/execute/builtins/strlen.c | 64 +++++++++ .../execute/builtins/strncat-lib.c | 1 + .../{string-opt-10.c => builtins/strncat.c} | 17 +-- .../execute/builtins/strncmp-2-lib.c | 1 + .../{string-opt-8.c => builtins/strncmp-2.c} | 72 +--------- .../execute/builtins/strncmp-lib.c | 1 + .../gcc.c-torture/execute/builtins/strncmp.c | 74 ++++++++++ .../execute/builtins/strncpy-lib.c | 1 + .../{string-opt-7.c => builtins/strncpy.c} | 15 +- .../execute/builtins/strpbrk-lib.c | 1 + .../{string-opt-2.c => builtins/strpbrk.c} | 17 +-- .../execute/builtins/strpcpy-2-lib.c | 1 + .../execute/builtins/strpcpy-2.c | 45 ++++++ .../execute/builtins/strpcpy-lib.c | 1 + .../gcc.c-torture/execute/builtins/strpcpy.c | 60 ++++++++ .../execute/builtins/strrchr-lib.c | 1 + .../gcc.c-torture/execute/builtins/strrchr.c | 49 +++++++ .../execute/builtins/strspn-lib.c | 1 + .../{string-opt-11.c => builtins/strspn.c} | 17 +-- .../{string-asm-1-lib.c => strstr-asm-lib.c} | 0 .../builtins/{string-asm-1.c => strstr-asm.c} | 0 .../execute/builtins/strstr-lib.c | 1 + .../{string-opt-1.c => builtins/strstr.c} | 17 +-- .../gcc.c-torture/execute/string-opt-13.c | 59 -------- .../gcc.c-torture/execute/string-opt-14.c | 42 ------ 83 files changed, 983 insertions(+), 760 deletions(-) create mode 100644 gcc/testsuite/gcc.c-torture/execute/builtins/abs-2-lib.c rename gcc/testsuite/gcc.c-torture/execute/{builtin-abs-1.c => builtins/abs-2.c} (69%) create mode 100644 gcc/testsuite/gcc.c-torture/execute/builtins/abs-3-lib.c rename gcc/testsuite/gcc.c-torture/execute/{builtin-abs-2.c => builtins/abs-3.c} (72%) create mode 100644 gcc/testsuite/gcc.c-torture/execute/builtins/complex-1-lib.c rename gcc/testsuite/gcc.c-torture/execute/{builtin-complex-1.c => builtins/complex-1.c} (62%) create mode 100644 gcc/testsuite/gcc.c-torture/execute/builtins/fprintf-lib.c rename gcc/testsuite/gcc.c-torture/execute/{stdio-opt-3.c => builtins/fprintf.c} (79%) create mode 100644 gcc/testsuite/gcc.c-torture/execute/builtins/fputs-lib.c rename gcc/testsuite/gcc.c-torture/execute/{stdio-opt-1.c => builtins/fputs.c} (75%) create mode 100644 gcc/testsuite/gcc.c-torture/execute/builtins/lib/abs.c create mode 100644 gcc/testsuite/gcc.c-torture/execute/builtins/lib/fprintf.c rename gcc/testsuite/gcc.c-torture/execute/builtins/{string-3-lib.c => lib/memset.c} (100%) create mode 100644 gcc/testsuite/gcc.c-torture/execute/builtins/lib/printf.c create mode 100644 gcc/testsuite/gcc.c-torture/execute/builtins/lib/sprintf.c create mode 100644 gcc/testsuite/gcc.c-torture/execute/builtins/lib/strcpy.c create mode 100644 gcc/testsuite/gcc.c-torture/execute/builtins/lib/strcspn.c create mode 100644 gcc/testsuite/gcc.c-torture/execute/builtins/lib/strncat.c create mode 100644 gcc/testsuite/gcc.c-torture/execute/builtins/lib/strncmp.c create mode 100644 gcc/testsuite/gcc.c-torture/execute/builtins/lib/strncpy.c create mode 100644 gcc/testsuite/gcc.c-torture/execute/builtins/lib/strpbrk.c create mode 100644 gcc/testsuite/gcc.c-torture/execute/builtins/lib/strspn.c create mode 100644 gcc/testsuite/gcc.c-torture/execute/builtins/lib/strstr.c rename gcc/testsuite/gcc.c-torture/execute/builtins/{string-6-lib.c => memcmp-lib.c} (100%) rename gcc/testsuite/gcc.c-torture/execute/{string-opt-15.c => builtins/memcmp.c} (67%) rename gcc/testsuite/gcc.c-torture/execute/builtins/{string-5-lib.c => memmove-lib.c} (100%) rename gcc/testsuite/gcc.c-torture/execute/builtins/{string-5.c => memmove.c} (100%) rename gcc/testsuite/gcc.c-torture/execute/builtins/{string-asm-2-lib.c => memops-asm-lib.c} (100%) rename gcc/testsuite/gcc.c-torture/execute/builtins/{string-asm-2.c => memops-asm.c} (100%) rename gcc/testsuite/gcc.c-torture/execute/builtins/{string-4-lib.c => mempcpy-2-lib.c} (51%) rename gcc/testsuite/gcc.c-torture/execute/builtins/{string-7.c => mempcpy-2.c} (90%) rename gcc/testsuite/gcc.c-torture/execute/builtins/{string-7-lib.c => mempcpy-lib.c} (51%) rename gcc/testsuite/gcc.c-torture/execute/builtins/{string-4.c => mempcpy.c} (51%) create mode 100644 gcc/testsuite/gcc.c-torture/execute/builtins/memset-lib.c rename gcc/testsuite/gcc.c-torture/execute/builtins/{string-3.c => memset.c} (100%) create mode 100644 gcc/testsuite/gcc.c-torture/execute/builtins/printf-lib.c rename gcc/testsuite/gcc.c-torture/execute/{stdio-opt-2.c => builtins/printf.c} (77%) create mode 100644 gcc/testsuite/gcc.c-torture/execute/builtins/sprintf-lib.c rename gcc/testsuite/gcc.c-torture/execute/{string-opt-16.c => builtins/sprintf.c} (80%) rename gcc/testsuite/gcc.c-torture/execute/builtins/{string-9-lib.c => strcat-lib.c} (100%) rename gcc/testsuite/gcc.c-torture/execute/builtins/{string-9.c => strcat.c} (100%) rename gcc/testsuite/gcc.c-torture/execute/builtins/{string-2-lib.c => strchr-lib.c} (100%) rename gcc/testsuite/gcc.c-torture/execute/builtins/{string-2.c => strchr.c} (100%) create mode 100644 gcc/testsuite/gcc.c-torture/execute/builtins/strcmp-lib.c create mode 100644 gcc/testsuite/gcc.c-torture/execute/builtins/strcmp.c create mode 100644 gcc/testsuite/gcc.c-torture/execute/builtins/strcpy-lib.c rename gcc/testsuite/gcc.c-torture/execute/{string-opt-6.c => builtins/strcpy.c} (81%) create mode 100644 gcc/testsuite/gcc.c-torture/execute/builtins/strcspn-lib.c rename gcc/testsuite/gcc.c-torture/execute/{string-opt-12.c => builtins/strcspn.c} (78%) delete mode 100644 gcc/testsuite/gcc.c-torture/execute/builtins/string-1-lib.c delete mode 100644 gcc/testsuite/gcc.c-torture/execute/builtins/string-1.c delete mode 100644 gcc/testsuite/gcc.c-torture/execute/builtins/string-6.c rename gcc/testsuite/gcc.c-torture/execute/builtins/{string-8-lib.c => strlen-2-lib.c} (100%) rename gcc/testsuite/gcc.c-torture/execute/builtins/{string-8.c => strlen-2.c} (97%) create mode 100644 gcc/testsuite/gcc.c-torture/execute/builtins/strlen-lib.c create mode 100644 gcc/testsuite/gcc.c-torture/execute/builtins/strlen.c create mode 100644 gcc/testsuite/gcc.c-torture/execute/builtins/strncat-lib.c rename gcc/testsuite/gcc.c-torture/execute/{string-opt-10.c => builtins/strncat.c} (88%) create mode 100644 gcc/testsuite/gcc.c-torture/execute/builtins/strncmp-2-lib.c rename gcc/testsuite/gcc.c-torture/execute/{string-opt-8.c => builtins/strncmp-2.c} (71%) create mode 100644 gcc/testsuite/gcc.c-torture/execute/builtins/strncmp-lib.c create mode 100644 gcc/testsuite/gcc.c-torture/execute/builtins/strncmp.c create mode 100644 gcc/testsuite/gcc.c-torture/execute/builtins/strncpy-lib.c rename gcc/testsuite/gcc.c-torture/execute/{string-opt-7.c => builtins/strncpy.c} (87%) create mode 100644 gcc/testsuite/gcc.c-torture/execute/builtins/strpbrk-lib.c rename gcc/testsuite/gcc.c-torture/execute/{string-opt-2.c => builtins/strpbrk.c} (77%) create mode 100644 gcc/testsuite/gcc.c-torture/execute/builtins/strpcpy-2-lib.c create mode 100644 gcc/testsuite/gcc.c-torture/execute/builtins/strpcpy-2.c create mode 100644 gcc/testsuite/gcc.c-torture/execute/builtins/strpcpy-lib.c create mode 100644 gcc/testsuite/gcc.c-torture/execute/builtins/strpcpy.c create mode 100644 gcc/testsuite/gcc.c-torture/execute/builtins/strrchr-lib.c create mode 100644 gcc/testsuite/gcc.c-torture/execute/builtins/strrchr.c create mode 100644 gcc/testsuite/gcc.c-torture/execute/builtins/strspn-lib.c rename gcc/testsuite/gcc.c-torture/execute/{string-opt-11.c => builtins/strspn.c} (81%) rename gcc/testsuite/gcc.c-torture/execute/builtins/{string-asm-1-lib.c => strstr-asm-lib.c} (100%) rename gcc/testsuite/gcc.c-torture/execute/builtins/{string-asm-1.c => strstr-asm.c} (100%) create mode 100644 gcc/testsuite/gcc.c-torture/execute/builtins/strstr-lib.c rename gcc/testsuite/gcc.c-torture/execute/{string-opt-1.c => builtins/strstr.c} (72%) delete mode 100644 gcc/testsuite/gcc.c-torture/execute/string-opt-13.c delete mode 100644 gcc/testsuite/gcc.c-torture/execute/string-opt-14.c diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 8638c0ed646..2ba74a1b3dd 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,131 @@ +2004-07-02 Zack Weinberg + + * gcc.c-torture/execute/builtin-abs-1.c + * gcc.c-torture/execute/builtin-abs-2.c + * gcc.c-torture/execute/builtin-complex-1.c + * gcc.c-torture/execute/builtins/string-1-lib.c + * gcc.c-torture/execute/builtins/string-1.c + * gcc.c-torture/execute/builtins/string-2-lib.c + * gcc.c-torture/execute/builtins/string-2.c + * gcc.c-torture/execute/builtins/string-3-lib.c + * gcc.c-torture/execute/builtins/string-3.c + * gcc.c-torture/execute/builtins/string-4-lib.c + * gcc.c-torture/execute/builtins/string-4.c + * gcc.c-torture/execute/builtins/string-5-lib.c + * gcc.c-torture/execute/builtins/string-5.c + * gcc.c-torture/execute/builtins/string-6-lib.c + * gcc.c-torture/execute/builtins/string-6.c + * gcc.c-torture/execute/builtins/string-7-lib.c + * gcc.c-torture/execute/builtins/string-7.c + * gcc.c-torture/execute/builtins/string-8-lib.c + * gcc.c-torture/execute/builtins/string-8.c + * gcc.c-torture/execute/builtins/string-9-lib.c + * gcc.c-torture/execute/builtins/string-9.c + * gcc.c-torture/execute/builtins/string-asm-1-lib.c + * gcc.c-torture/execute/builtins/string-asm-1.c + * gcc.c-torture/execute/builtins/string-asm-2-lib.c + * gcc.c-torture/execute/builtins/string-asm-2.c + * gcc.c-torture/execute/stdio-opt-1.c + * gcc.c-torture/execute/stdio-opt-2.c + * gcc.c-torture/execute/stdio-opt-3.c + * gcc.c-torture/execute/string-opt-1.c + * gcc.c-torture/execute/string-opt-10.c + * gcc.c-torture/execute/string-opt-11.c + * gcc.c-torture/execute/string-opt-12.c + * gcc.c-torture/execute/string-opt-13.c + * gcc.c-torture/execute/string-opt-14.c + * gcc.c-torture/execute/string-opt-15.c + * gcc.c-torture/execute/string-opt-16.c + * gcc.c-torture/execute/string-opt-2.c + * gcc.c-torture/execute/string-opt-6.c + * gcc.c-torture/execute/string-opt-7.c + * gcc.c-torture/execute/string-opt-8.c: + Replace with ... + + * gcc.c-torture/execute/builtins/abs-2.c + * gcc.c-torture/execute/builtins/abs-3.c + * gcc.c-torture/execute/builtins/complex-1.c + * gcc.c-torture/execute/builtins/fprintf.c + * gcc.c-torture/execute/builtins/fputs.c + * gcc.c-torture/execute/builtins/memcmp.c + * gcc.c-torture/execute/builtins/memmove.c + * gcc.c-torture/execute/builtins/memops-asm.c + * gcc.c-torture/execute/builtins/mempcpy-2.c + * gcc.c-torture/execute/builtins/mempcpy.c + * gcc.c-torture/execute/builtins/memset.c + * gcc.c-torture/execute/builtins/printf.c + * gcc.c-torture/execute/builtins/sprintf.c + * gcc.c-torture/execute/builtins/strcat.c + * gcc.c-torture/execute/builtins/strchr.c + * gcc.c-torture/execute/builtins/strcmp.c + * gcc.c-torture/execute/builtins/strcpy.c + * gcc.c-torture/execute/builtins/strcspn.c + * gcc.c-torture/execute/builtins/strlen-2.c + * gcc.c-torture/execute/builtins/strlen.c + * gcc.c-torture/execute/builtins/strncat.c + * gcc.c-torture/execute/builtins/strncmp-2.c + * gcc.c-torture/execute/builtins/strncmp.c + * gcc.c-torture/execute/builtins/strncpy.c + * gcc.c-torture/execute/builtins/strpbrk.c + * gcc.c-torture/execute/builtins/strpcpy-2.c + * gcc.c-torture/execute/builtins/strpcpy.c + * gcc.c-torture/execute/builtins/strrchr.c + * gcc.c-torture/execute/builtins/strspn.c + * gcc.c-torture/execute/builtins/strstr-asm.c + * gcc.c-torture/execute/builtins/strstr.c: + ... these new files. + + * gcc.c-torture/execute/builtins/abs-2-lib.c + * gcc.c-torture/execute/builtins/abs-3-lib.c + * gcc.c-torture/execute/builtins/complex-1-lib.c + * gcc.c-torture/execute/builtins/fprintf-lib.c + * gcc.c-torture/execute/builtins/fputs-lib.c + * gcc.c-torture/execute/builtins/memcmp-lib.c + * gcc.c-torture/execute/builtins/memmove-lib.c + * gcc.c-torture/execute/builtins/memops-asm-lib.c + * gcc.c-torture/execute/builtins/mempcpy-2-lib.c + * gcc.c-torture/execute/builtins/mempcpy-lib.c + * gcc.c-torture/execute/builtins/memset-lib.c + * gcc.c-torture/execute/builtins/printf-lib.c + * gcc.c-torture/execute/builtins/sprintf-lib.c + * gcc.c-torture/execute/builtins/strcat-lib.c + * gcc.c-torture/execute/builtins/strchr-lib.c + * gcc.c-torture/execute/builtins/strcmp-lib.c + * gcc.c-torture/execute/builtins/strcpy-lib.c + * gcc.c-torture/execute/builtins/strcspn-lib.c + * gcc.c-torture/execute/builtins/strlen-2-lib.c + * gcc.c-torture/execute/builtins/strlen-lib.c + * gcc.c-torture/execute/builtins/strncat-lib.c + * gcc.c-torture/execute/builtins/strncmp-2-lib.c + * gcc.c-torture/execute/builtins/strncmp-lib.c + * gcc.c-torture/execute/builtins/strncpy-lib.c + * gcc.c-torture/execute/builtins/strpbrk-lib.c + * gcc.c-torture/execute/builtins/strpcpy-2-lib.c + * gcc.c-torture/execute/builtins/strpcpy-lib.c + * gcc.c-torture/execute/builtins/strrchr-lib.c + * gcc.c-torture/execute/builtins/strspn-lib.c + * gcc.c-torture/execute/builtins/strstr-asm-lib.c + * gcc.c-torture/execute/builtins/strstr-lib.c + * gcc.c-torture/execute/builtins/lib/abs.c + * gcc.c-torture/execute/builtins/lib/fprintf.c + * gcc.c-torture/execute/builtins/lib/memset.c + * gcc.c-torture/execute/builtins/lib/printf.c + * gcc.c-torture/execute/builtins/lib/sprintf.c + * gcc.c-torture/execute/builtins/lib/strcpy.c + * gcc.c-torture/execute/builtins/lib/strcspn.c + * gcc.c-torture/execute/builtins/lib/strncat.c + * gcc.c-torture/execute/builtins/lib/strncmp.c + * gcc.c-torture/execute/builtins/lib/strncpy.c + * gcc.c-torture/execute/builtins/lib/strpbrk.c + * gcc.c-torture/execute/builtins/lib/strspn.c + * gcc.c-torture/execute/builtins/lib/strstr.c: + New files containing support routines. + + * gcc.c-torture/execute/builtins/abs-1.c: Remove unnecessary + declaration. + * gcc.c-torture/execute/builtins/lib/main.c: Define link_error + when not optimizing. + 2004-07-02 Mark Mitchell PR c++/16240 diff --git a/gcc/testsuite/gcc.c-torture/execute/builtins/abs-1.c b/gcc/testsuite/gcc.c-torture/execute/builtins/abs-1.c index 1584515af78..6ca246d3922 100644 --- a/gcc/testsuite/gcc.c-torture/execute/builtins/abs-1.c +++ b/gcc/testsuite/gcc.c-torture/execute/builtins/abs-1.c @@ -9,7 +9,6 @@ int abs_called = 0; extern int abs (int); extern long labs (long); extern void abort (void); -extern void exit (int); void main_test (void) diff --git a/gcc/testsuite/gcc.c-torture/execute/builtins/abs-2-lib.c b/gcc/testsuite/gcc.c-torture/execute/builtins/abs-2-lib.c new file mode 100644 index 00000000000..494e5390e63 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/builtins/abs-2-lib.c @@ -0,0 +1 @@ +#include "lib/abs.c" diff --git a/gcc/testsuite/gcc.c-torture/execute/builtin-abs-1.c b/gcc/testsuite/gcc.c-torture/execute/builtins/abs-2.c similarity index 69% rename from gcc/testsuite/gcc.c-torture/execute/builtin-abs-1.c rename to gcc/testsuite/gcc.c-torture/execute/builtins/abs-2.c index 8a34353763d..025488d7dd8 100644 --- a/gcc/testsuite/gcc.c-torture/execute/builtin-abs-1.c +++ b/gcc/testsuite/gcc.c-torture/execute/builtins/abs-2.c @@ -21,12 +21,10 @@ extern long labs (long); extern long long llabs (long long); extern intmax_t imaxabs (intmax_t); extern void abort (void); -extern void exit (int); +extern void link_error (void); -extern void link_failure (void); - -int -main (void) +void +main_test (void) { /* For each type, test both runtime and compile time (constant folding) optimization. */ @@ -39,122 +37,81 @@ main (void) if (abs (i0) != 0) abort (); if (abs (0) != 0) - link_failure (); + link_error (); if (abs (i1) != 1) abort (); if (abs (1) != 1) - link_failure (); + link_error (); if (abs (im1) != 1) abort (); if (abs (-1) != 1) - link_failure (); + link_error (); if (abs (imin) != INT_MAX) abort (); if (abs (-INT_MAX) != INT_MAX) - link_failure (); + link_error (); if (abs (imax) != INT_MAX) abort (); if (abs (INT_MAX) != INT_MAX) - link_failure (); + link_error (); if (labs (l0) != 0L) abort (); if (labs (0L) != 0L) - link_failure (); + link_error (); if (labs (l1) != 1L) abort (); if (labs (1L) != 1L) - link_failure (); + link_error (); if (labs (lm1) != 1L) abort (); if (labs (-1L) != 1L) - link_failure (); + link_error (); if (labs (lmin) != LONG_MAX) abort (); if (labs (-LONG_MAX) != LONG_MAX) - link_failure (); + link_error (); if (labs (lmax) != LONG_MAX) abort (); if (labs (LONG_MAX) != LONG_MAX) - link_failure (); + link_error (); if (llabs (ll0) != 0LL) abort (); if (llabs (0LL) != 0LL) - link_failure (); + link_error (); if (llabs (ll1) != 1LL) abort (); if (llabs (1LL) != 1LL) - link_failure (); + link_error (); if (llabs (llm1) != 1LL) abort (); if (llabs (-1LL) != 1LL) - link_failure (); + link_error (); if (llabs (llmin) != __LONG_LONG_MAX__) abort (); if (llabs (-__LONG_LONG_MAX__) != __LONG_LONG_MAX__) - link_failure (); + link_error (); if (llabs (llmax) != __LONG_LONG_MAX__) abort (); if (llabs (__LONG_LONG_MAX__) != __LONG_LONG_MAX__) - link_failure (); + link_error (); if (imaxabs (imax0) != 0) abort (); if (imaxabs (0) != 0) - link_failure (); + link_error (); if (imaxabs (imax1) != 1) abort (); if (imaxabs (1) != 1) - link_failure (); + link_error (); if (imaxabs (imaxm1) != 1) abort (); if (imaxabs (-1) != 1) - link_failure (); + link_error (); if (imaxabs (imaxmin) != INTMAX_MAX) abort (); if (imaxabs (-INTMAX_MAX) != INTMAX_MAX) - link_failure (); + link_error (); if (imaxabs (imaxmax) != INTMAX_MAX) abort (); if (imaxabs (INTMAX_MAX) != INTMAX_MAX) - link_failure (); - exit (0); -} - -/* All the above cases should have been optimized to something else, - even if not optimizing (unless -fno-builtin was specified). So any - remaining calls to the original functions should abort. */ - -static int -abs (int x) -{ - abort (); + link_error (); } - -static long -labs (long x) -{ - abort (); -} - -static long long -llabs (long long x) -{ - abort (); -} - -static intmax_t -imaxabs (intmax_t x) -{ - abort (); -} - -/* When optimizing, all the constant cases should have been - constant folded, so no calls to link_failure should remain. In any case, - link_failure should not be called. */ - -#ifndef __OPTIMIZE__ -void -link_failure (void) -{ - abort (); -} -#endif diff --git a/gcc/testsuite/gcc.c-torture/execute/builtins/abs-3-lib.c b/gcc/testsuite/gcc.c-torture/execute/builtins/abs-3-lib.c new file mode 100644 index 00000000000..494e5390e63 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/builtins/abs-3-lib.c @@ -0,0 +1 @@ +#include "lib/abs.c" diff --git a/gcc/testsuite/gcc.c-torture/execute/builtin-abs-2.c b/gcc/testsuite/gcc.c-torture/execute/builtins/abs-3.c similarity index 72% rename from gcc/testsuite/gcc.c-torture/execute/builtin-abs-2.c rename to gcc/testsuite/gcc.c-torture/execute/builtins/abs-3.c index b4e18796560..8300a48a64a 100644 --- a/gcc/testsuite/gcc.c-torture/execute/builtin-abs-2.c +++ b/gcc/testsuite/gcc.c-torture/execute/builtins/abs-3.c @@ -17,12 +17,10 @@ typedef long long intmax_t; #endif extern void abort (void); -extern void exit (int); +extern void link_error (void); -extern void link_failure (void); - -int -main (void) +void +main_test (void) { /* For each type, test both runtime and compile time (constant folding) optimization. */ @@ -35,122 +33,81 @@ main (void) if (__builtin_abs (i0) != 0) abort (); if (__builtin_abs (0) != 0) - link_failure (); + link_error (); if (__builtin_abs (i1) != 1) abort (); if (__builtin_abs (1) != 1) - link_failure (); + link_error (); if (__builtin_abs (im1) != 1) abort (); if (__builtin_abs (-1) != 1) - link_failure (); + link_error (); if (__builtin_abs (imin) != INT_MAX) abort (); if (__builtin_abs (-INT_MAX) != INT_MAX) - link_failure (); + link_error (); if (__builtin_abs (imax) != INT_MAX) abort (); if (__builtin_abs (INT_MAX) != INT_MAX) - link_failure (); + link_error (); if (__builtin_labs (l0) != 0L) abort (); if (__builtin_labs (0L) != 0L) - link_failure (); + link_error (); if (__builtin_labs (l1) != 1L) abort (); if (__builtin_labs (1L) != 1L) - link_failure (); + link_error (); if (__builtin_labs (lm1) != 1L) abort (); if (__builtin_labs (-1L) != 1L) - link_failure (); + link_error (); if (__builtin_labs (lmin) != LONG_MAX) abort (); if (__builtin_labs (-LONG_MAX) != LONG_MAX) - link_failure (); + link_error (); if (__builtin_labs (lmax) != LONG_MAX) abort (); if (__builtin_labs (LONG_MAX) != LONG_MAX) - link_failure (); + link_error (); if (__builtin_llabs (ll0) != 0LL) abort (); if (__builtin_llabs (0LL) != 0LL) - link_failure (); + link_error (); if (__builtin_llabs (ll1) != 1LL) abort (); if (__builtin_llabs (1LL) != 1LL) - link_failure (); + link_error (); if (__builtin_llabs (llm1) != 1LL) abort (); if (__builtin_llabs (-1LL) != 1LL) - link_failure (); + link_error (); if (__builtin_llabs (llmin) != __LONG_LONG_MAX__) abort (); if (__builtin_llabs (-__LONG_LONG_MAX__) != __LONG_LONG_MAX__) - link_failure (); + link_error (); if (__builtin_llabs (llmax) != __LONG_LONG_MAX__) abort (); if (__builtin_llabs (__LONG_LONG_MAX__) != __LONG_LONG_MAX__) - link_failure (); + link_error (); if (__builtin_imaxabs (imax0) != 0) abort (); if (__builtin_imaxabs (0) != 0) - link_failure (); + link_error (); if (__builtin_imaxabs (imax1) != 1) abort (); if (__builtin_imaxabs (1) != 1) - link_failure (); + link_error (); if (__builtin_imaxabs (imaxm1) != 1) abort (); if (__builtin_imaxabs (-1) != 1) - link_failure (); + link_error (); if (__builtin_imaxabs (imaxmin) != INTMAX_MAX) abort (); if (__builtin_imaxabs (-INTMAX_MAX) != INTMAX_MAX) - link_failure (); + link_error (); if (__builtin_imaxabs (imaxmax) != INTMAX_MAX) abort (); if (__builtin_imaxabs (INTMAX_MAX) != INTMAX_MAX) - link_failure (); - exit (0); -} - -/* All the above cases should have been optimized to something else, - not converted to function calls. So any calls to the non-__builtin - functions should abort. */ - -static int -abs (int x) -{ - abort (); + link_error (); } - -static long -labs (long x) -{ - abort (); -} - -static long long -llabs (long long x) -{ - abort (); -} - -static intmax_t -imaxabs (intmax_t x) -{ - abort (); -} - -/* When optimizing, all the constant cases should have been - constant folded, so no calls to link_failure should remain. In any case, - link_failure should not be called. */ - -#ifndef __OPTIMIZE__ -void -link_failure (void) -{ - abort (); -} -#endif diff --git a/gcc/testsuite/gcc.c-torture/execute/builtins/complex-1-lib.c b/gcc/testsuite/gcc.c-torture/execute/builtins/complex-1-lib.c new file mode 100644 index 00000000000..22d7db18069 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/builtins/complex-1-lib.c @@ -0,0 +1,70 @@ +extern int inside_main; +extern void abort (void); +#ifdef __OPTIMIZE__ +#define ABORT_INSIDE_MAIN do { if (inside_main) abort (); } while (0) +#else +#define ABORT_INSIDE_MAIN do { } while (0) +#endif + +static float _Complex +conjf (float _Complex z) +{ + ABORT_INSIDE_MAIN; + return ~z; +} + +static double _Complex +conj (double _Complex z) +{ + ABORT_INSIDE_MAIN; + return ~z; +} + +static long double _Complex +conjl (long double _Complex z) +{ + ABORT_INSIDE_MAIN; + return ~z; +} + +static float +crealf (float _Complex z) +{ + ABORT_INSIDE_MAIN; + return __real__ z; +} + +static double +creal (double _Complex z) +{ + ABORT_INSIDE_MAIN; + return __real__ z; +} + +static long double +creall (long double _Complex z) +{ + ABORT_INSIDE_MAIN; + return __real__ z; +} + +static float +cimagf (float _Complex z) +{ + ABORT_INSIDE_MAIN; + return __imag__ z; +} + +static double +cimag (double _Complex z) +{ + ABORT_INSIDE_MAIN; + return __imag__ z; +} + +static long double +cimagl (long double _Complex z) +{ + ABORT_INSIDE_MAIN; + return __imag__ z; +} diff --git a/gcc/testsuite/gcc.c-torture/execute/builtin-complex-1.c b/gcc/testsuite/gcc.c-torture/execute/builtins/complex-1.c similarity index 62% rename from gcc/testsuite/gcc.c-torture/execute/builtin-complex-1.c rename to gcc/testsuite/gcc.c-torture/execute/builtins/complex-1.c index 46ab7c51c0f..362a0e41ea3 100644 --- a/gcc/testsuite/gcc.c-torture/execute/builtin-complex-1.c +++ b/gcc/testsuite/gcc.c-torture/execute/builtins/complex-1.c @@ -14,12 +14,10 @@ extern double cimag (double _Complex); extern long double cimagl (long double _Complex); extern void abort (void); -extern void exit (int); +extern void link_error (void); -extern void link_failure (void); - -int -main (void) +void +main_test (void) { /* For each type, test both runtime and compile time (constant folding) optimization. */ @@ -32,144 +30,73 @@ main (void) if (__builtin_conjf (fc) != 1.0F - 2.0iF) abort (); if (conjf (1.0F + 2.0iF) != 1.0F - 2.0iF) - link_failure (); + link_error (); if (__builtin_conjf (1.0F + 2.0iF) != 1.0F - 2.0iF) - link_failure (); + link_error (); if (crealf (fc) != 1.0F) abort (); if (__builtin_crealf (fc) != 1.0F) abort (); if (crealf (1.0F + 2.0iF) != 1.0F) - link_failure (); + link_error (); if (__builtin_crealf (1.0F + 2.0iF) != 1.0F) - link_failure (); + link_error (); if (cimagf (fc) != 2.0F) abort (); if (__builtin_cimagf (fc) != 2.0F) abort (); if (cimagf (1.0F + 2.0iF) != 2.0F) - link_failure (); + link_error (); if (__builtin_cimagf (1.0F + 2.0iF) != 2.0F) - link_failure (); + link_error (); /* Test doubles. */ if (conj (dc) != 1.0 - 2.0i) abort (); if (__builtin_conj (dc) != 1.0 - 2.0i) abort (); if (conj (1.0 + 2.0i) != 1.0 - 2.0i) - link_failure (); + link_error (); if (__builtin_conj (1.0 + 2.0i) != 1.0 - 2.0i) - link_failure (); + link_error (); if (creal (dc) != 1.0) abort (); if (__builtin_creal (dc) != 1.0) abort (); if (creal (1.0 + 2.0i) != 1.0) - link_failure (); + link_error (); if (__builtin_creal (1.0 + 2.0i) != 1.0) - link_failure (); + link_error (); if (cimag (dc) != 2.0) abort (); if (__builtin_cimag (dc) != 2.0) abort (); if (cimag (1.0 + 2.0i) != 2.0) - link_failure (); + link_error (); if (__builtin_cimag (1.0 + 2.0i) != 2.0) - link_failure (); + link_error (); /* Test long doubles. */ if (conjl (ldc) != 1.0L - 2.0iL) abort (); if (__builtin_conjl (ldc) != 1.0L - 2.0iL) abort (); if (conjl (1.0L + 2.0iL) != 1.0L - 2.0iL) - link_failure (); + link_error (); if (__builtin_conjl (1.0L + 2.0iL) != 1.0L - 2.0iL) - link_failure (); + link_error (); if (creall (ldc) != 1.0L) abort (); if (__builtin_creall (ldc) != 1.0L) abort (); if (creall (1.0L + 2.0iL) != 1.0L) - link_failure (); + link_error (); if (__builtin_creall (1.0L + 2.0iL) != 1.0L) - link_failure (); + link_error (); if (cimagl (ldc) != 2.0L) abort (); if (__builtin_cimagl (ldc) != 2.0L) abort (); if (cimagl (1.0L + 2.0iL) != 2.0L) - link_failure (); + link_error (); if (__builtin_cimagl (1.0L + 2.0iL) != 2.0L) - link_failure (); - exit (0); -} - -/* All the above cases should have been optimized to something else, - even if not optimizing (unless -fno-builtin was specified). So any - remaining calls to the original functions should abort. */ - -static float _Complex -conjf (float _Complex z) -{ - abort (); -} - -static double _Complex -conj (double _Complex z) -{ - abort (); -} - -static long double _Complex -conjl (long double _Complex z) -{ - abort (); -} - -static float -crealf (float _Complex z) -{ - abort (); -} - -static double -creal (double _Complex z) -{ - abort (); -} - -static long double -creall (long double _Complex z) -{ - abort (); -} - -static float -cimagf (float _Complex z) -{ - abort (); -} - -static double -cimag (double _Complex z) -{ - abort (); -} - -static long double -cimagl (long double _Complex z) -{ - abort (); -} - -/* When optimizing, all the constant cases should have been - constant folded, so no calls to link_failure should remain. In any case, - link_failure should not be called. */ - -#ifndef __OPTIMIZE__ -void -link_failure (void) -{ - abort (); + link_error (); } -#endif diff --git a/gcc/testsuite/gcc.c-torture/execute/builtins/fprintf-lib.c b/gcc/testsuite/gcc.c-torture/execute/builtins/fprintf-lib.c new file mode 100644 index 00000000000..b6a1e913da4 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/builtins/fprintf-lib.c @@ -0,0 +1 @@ +#include "lib/fprintf.c" diff --git a/gcc/testsuite/gcc.c-torture/execute/stdio-opt-3.c b/gcc/testsuite/gcc.c-torture/execute/builtins/fprintf.c similarity index 79% rename from gcc/testsuite/gcc.c-torture/execute/stdio-opt-3.c rename to gcc/testsuite/gcc.c-torture/execute/builtins/fprintf.c index afc76a21716..6b6e71b78f8 100644 --- a/gcc/testsuite/gcc.c-torture/execute/stdio-opt-3.c +++ b/gcc/testsuite/gcc.c-torture/execute/builtins/fprintf.c @@ -6,10 +6,10 @@ Written by Kaveh R. Ghazi, 1/7/2001. */ #include -extern int fprintf (FILE *, const char *, ...); extern void abort(void); -int main() +void +main_test (void) { FILE *s_array[] = {stdout, NULL}, **s_ptr = s_array; const char *const s1 = "hello world"; @@ -49,18 +49,4 @@ int main() /* Test at least one instance of the __builtin_ style. We do this to ensure that it works and that the prototype is correct. */ __builtin_fprintf (*s_ptr, "%s", "hello world\n"); - - 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. */ -__attribute__ ((noinline)) -static int -fprintf (FILE *stream, const char *string, ...) -{ - abort(); } -#endif diff --git a/gcc/testsuite/gcc.c-torture/execute/builtins/fputs-lib.c b/gcc/testsuite/gcc.c-torture/execute/builtins/fputs-lib.c new file mode 100644 index 00000000000..48a955309c1 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/builtins/fputs-lib.c @@ -0,0 +1,17 @@ +#include +#include +extern int inside_main; +extern size_t strlen(const char *); +int +fputs(const char *string, FILE *stream) +{ + size_t n = strlen(string); + size_t r; +#if defined __OPTIMIZE__ && !defined __OPTIMIZE_SIZE__ + if (inside_main) + abort(); +#endif + r = fwrite (string, 1, n, stream); + return n > r ? EOF : 0; +} + diff --git a/gcc/testsuite/gcc.c-torture/execute/stdio-opt-1.c b/gcc/testsuite/gcc.c-torture/execute/builtins/fputs.c similarity index 75% rename from gcc/testsuite/gcc.c-torture/execute/stdio-opt-1.c rename to gcc/testsuite/gcc.c-torture/execute/builtins/fputs.c index 8cfb4ebe08e..9274d5b643f 100644 --- a/gcc/testsuite/gcc.c-torture/execute/stdio-opt-1.c +++ b/gcc/testsuite/gcc.c-torture/execute/builtins/fputs.c @@ -7,14 +7,11 @@ #include extern void abort(void); -/* Declare this without args because that's what gcc does internally. - We want to make sure it works without a helpful prototype from us. - If stdio.h provides one, that is okay. */ -extern int fputs(); int i; -int main() +void +main_test(void) { FILE *s_array[] = {stdout, NULL}, **s_ptr = s_array; const char *const s1 = "hello world"; @@ -61,18 +58,4 @@ int main() fputs (--i ? "\n" : "\n", *--s_ptr); if (s_ptr != s_array || i != 0) abort(); - - return 0; -} - -#if defined (__OPTIMIZE__) && ! defined (__OPTIMIZE_SIZE__) -/* When optimizing, all the above cases should be transformed into - something else. So any remaining calls to the original function - should abort. */ -__attribute__ ((noinline)) -static int -fputs(const char *string, FILE *stream) -{ - abort(); } -#endif diff --git a/gcc/testsuite/gcc.c-torture/execute/builtins/lib/abs.c b/gcc/testsuite/gcc.c-torture/execute/builtins/lib/abs.c new file mode 100644 index 00000000000..99ca10df393 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/builtins/lib/abs.c @@ -0,0 +1,50 @@ +extern int inside_main; +extern void abort (void); +#ifdef __OPTIMIZE__ +#define ABORT_INSIDE_MAIN do { if (inside_main) abort (); } while (0) +#else +#define ABORT_INSIDE_MAIN do { } while (0) +#endif + +/* These next definitions are kludges. When GCC has a it + should be used. +*/ +#include +#if INT_MAX == __LONG_LONG_MAX__ +typedef int intmax_t; +#define INTMAX_MAX INT_MAX +#elif LONG_MAX == __LONG_LONG_MAX__ +typedef long intmax_t; +#define INTMAX_MAX LONG_MAX +#else +typedef long long intmax_t; +#define INTMAX_MAX __LONG_LONG_MAX__ +#endif + +int +abs (int x) +{ + ABORT_INSIDE_MAIN; + return x < 0 ? -x : x; +} + +long +labs (long x) +{ + ABORT_INSIDE_MAIN; + return x < 0 ? -x : x; +} + +long long +llabs (long long x) +{ + ABORT_INSIDE_MAIN; + return x < 0 ? -x : x; +} + +intmax_t +imaxabs (intmax_t x) +{ + ABORT_INSIDE_MAIN; + return x < 0 ? -x : x; +} diff --git a/gcc/testsuite/gcc.c-torture/execute/builtins/lib/fprintf.c b/gcc/testsuite/gcc.c-torture/execute/builtins/lib/fprintf.c new file mode 100644 index 00000000000..80c240cc8e7 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/builtins/lib/fprintf.c @@ -0,0 +1,18 @@ +#include +#include +extern int inside_main; + +int +fprintf (FILE *fp, const char *string, ...) +{ + va_list ap; + int r; +#ifdef __OPTIMIZE__ + if (inside_main) + abort(); +#endif + va_start (ap, string); + r = vfprintf (fp, string, ap); + va_end (ap); + return r; +} diff --git a/gcc/testsuite/gcc.c-torture/execute/builtins/lib/main.c b/gcc/testsuite/gcc.c-torture/execute/builtins/lib/main.c index cfd79baef47..6f3c3170cc1 100644 --- a/gcc/testsuite/gcc.c-torture/execute/builtins/lib/main.c +++ b/gcc/testsuite/gcc.c-torture/execute/builtins/lib/main.c @@ -9,3 +9,15 @@ main () inside_main = 0; return 0; } + +/* When optimizing, all the constant cases should have been + constant folded, so no calls to link_error should remain. + In any case, link_error should not be called. */ + +#ifndef __OPTIMIZE__ +void +link_error (void) +{ + abort (); +} +#endif diff --git a/gcc/testsuite/gcc.c-torture/execute/builtins/string-3-lib.c b/gcc/testsuite/gcc.c-torture/execute/builtins/lib/memset.c similarity index 100% rename from gcc/testsuite/gcc.c-torture/execute/builtins/string-3-lib.c rename to gcc/testsuite/gcc.c-torture/execute/builtins/lib/memset.c diff --git a/gcc/testsuite/gcc.c-torture/execute/builtins/lib/printf.c b/gcc/testsuite/gcc.c-torture/execute/builtins/lib/printf.c new file mode 100644 index 00000000000..be2a63bc61e --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/builtins/lib/printf.c @@ -0,0 +1,19 @@ +#include +#include +extern int inside_main; + +int +printf (const char *string, ...) +{ + va_list ap; + int r; +#ifdef __OPTIMIZE__ + if (inside_main) + abort(); +#endif + va_start (ap, string); + r = vprintf (string, ap); + va_end (ap); + return r; +} + diff --git a/gcc/testsuite/gcc.c-torture/execute/builtins/lib/sprintf.c b/gcc/testsuite/gcc.c-torture/execute/builtins/lib/sprintf.c new file mode 100644 index 00000000000..0c0cd5b9345 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/builtins/lib/sprintf.c @@ -0,0 +1,20 @@ +#include +#include +extern int inside_main; + +int +sprintf (char *buf, const char *fmt, ...) +{ + va_list ap; + int r; +#ifdef __OPTIMIZE__ + if (inside_main) + abort (); +#endif + va_start (ap, fmt); + r = vsprintf (buf, fmt, ap); + va_end (ap); + return r; +} + + diff --git a/gcc/testsuite/gcc.c-torture/execute/builtins/lib/strcpy.c b/gcc/testsuite/gcc.c-torture/execute/builtins/lib/strcpy.c new file mode 100644 index 00000000000..127b57733c4 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/builtins/lib/strcpy.c @@ -0,0 +1,13 @@ +extern int inside_main; + +char * +strcpy (char *d, const char *s) +{ + char *r = d; +#ifdef __OPTIMIZE__ + if (inside_main) + abort (); +#endif + while ((*d++ = *s++)); + return r; +} diff --git a/gcc/testsuite/gcc.c-torture/execute/builtins/lib/strcspn.c b/gcc/testsuite/gcc.c-torture/execute/builtins/lib/strcspn.c new file mode 100644 index 00000000000..767c89a6351 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/builtins/lib/strcspn.c @@ -0,0 +1,20 @@ +extern int inside_main; + +__SIZE_TYPE__ +strcspn (const char *s1, const char *s2) +{ + const char *p, *q; + +#ifdef __OPTIMIZE__ + if (inside_main) + abort(); +#endif + + for (p = s1; *p; p++) + for (q = s2; *q; q++) + if (*p == *q) + goto found; + + found: + return p - s1; +} diff --git a/gcc/testsuite/gcc.c-torture/execute/builtins/lib/strncat.c b/gcc/testsuite/gcc.c-torture/execute/builtins/lib/strncat.c new file mode 100644 index 00000000000..59d3cc0ae0a --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/builtins/lib/strncat.c @@ -0,0 +1,26 @@ +extern int inside_main; + +typedef __SIZE_TYPE__ size_t; + +char * +strncat (char *s1, const char *s2, size_t n) +{ + char *dest = s1; + char c; +#ifdef __OPTIMIZE__ + if (inside_main) + abort(); +#endif + while (*s1) s1++; + while (n > 0) + { + c = *s2++; + *s1++ = c; + if (c == 0) + return dest; + n--; + } + if (c != '\0') + *s1 = '\0'; + return dest; +} diff --git a/gcc/testsuite/gcc.c-torture/execute/builtins/lib/strncmp.c b/gcc/testsuite/gcc.c-torture/execute/builtins/lib/strncmp.c new file mode 100644 index 00000000000..c0b890677e5 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/builtins/lib/strncmp.c @@ -0,0 +1,25 @@ +extern int inside_main; + +typedef __SIZE_TYPE__ size_t; + +int +strncmp(const char *s1, const char *s2, size_t n) +{ + const unsigned char *u1 = (const unsigned char *)s1; + const unsigned char *u2 = (const unsigned char *)s2; + unsigned char c1, c2; + +#ifdef __OPTIMIZE__ + if (inside_main) + abort(); +#endif + + while (n > 0) + { + c1 = *u1++, c2 = *u2++; + if (c1 == '\0' || c1 != c2) + return c1 - c2; + n--; + } + return c1 - c2; +} diff --git a/gcc/testsuite/gcc.c-torture/execute/builtins/lib/strncpy.c b/gcc/testsuite/gcc.c-torture/execute/builtins/lib/strncpy.c new file mode 100644 index 00000000000..a96f7cb925f --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/builtins/lib/strncpy.c @@ -0,0 +1,19 @@ +extern int inside_main; + +typedef __SIZE_TYPE__ size_t; + +char * +strncpy(char *s1, const char *s2, size_t n) +{ + char *dest = s1; +#ifdef __OPTIMIZE__ + if (inside_main) + abort(); +#endif + for (; *s2 && n; n--) + *s1++ = *s2++; + while (n--) + *s1++ = 0; + return dest; +} + diff --git a/gcc/testsuite/gcc.c-torture/execute/builtins/lib/strpbrk.c b/gcc/testsuite/gcc.c-torture/execute/builtins/lib/strpbrk.c new file mode 100644 index 00000000000..1eb90ade5fb --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/builtins/lib/strpbrk.c @@ -0,0 +1,19 @@ +extern int inside_main; + +char * +strpbrk(const char *s1, const char *s2) +{ + char *p; +#ifdef __OPTIMIZE__ + if (inside_main) + abort (); +#endif + while (*s1) + { + for (p = s2; *p; p++) + if (*s1 == *p) + return s1; + s1++; + } + return 0; +} diff --git a/gcc/testsuite/gcc.c-torture/execute/builtins/lib/strspn.c b/gcc/testsuite/gcc.c-torture/execute/builtins/lib/strspn.c new file mode 100644 index 00000000000..29477cc764c --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/builtins/lib/strspn.c @@ -0,0 +1,23 @@ +extern int inside_main; + +__SIZE_TYPE__ +strcspn (const char *s1, const char *s2) +{ + const char *p, *q; + +#ifdef __OPTIMIZE__ + if (inside_main) + abort(); +#endif + + for (p = s1; *p; p++) + { + for (q = s2; *q; q++) + if (*p == *q) + goto proceed; + break; + + proceed:; + } + return p - s1; +} diff --git a/gcc/testsuite/gcc.c-torture/execute/builtins/lib/strstr.c b/gcc/testsuite/gcc.c-torture/execute/builtins/lib/strstr.c new file mode 100644 index 00000000000..fa43c934312 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/builtins/lib/strstr.c @@ -0,0 +1,27 @@ +extern int inside_main; + +char * +strstr(const char *s1, const char *s2) +{ + const char *p, *q; + +#ifdef __OPTIMIZE__ + if (inside_main) + abort (); +#endif + + /* deliberately dumb algorithm */ + for (; *s1; s1++) + { + p = s1, q = s2; + while (*q && *p) + { + if (*q != *p) + break; + p++, q++; + } + if (*p == *q && *p == 0) + return (char *)s1; + } + return 0; +} diff --git a/gcc/testsuite/gcc.c-torture/execute/builtins/string-6-lib.c b/gcc/testsuite/gcc.c-torture/execute/builtins/memcmp-lib.c similarity index 100% rename from gcc/testsuite/gcc.c-torture/execute/builtins/string-6-lib.c rename to gcc/testsuite/gcc.c-torture/execute/builtins/memcmp-lib.c diff --git a/gcc/testsuite/gcc.c-torture/execute/string-opt-15.c b/gcc/testsuite/gcc.c-torture/execute/builtins/memcmp.c similarity index 67% rename from gcc/testsuite/gcc.c-torture/execute/string-opt-15.c rename to gcc/testsuite/gcc.c-torture/execute/builtins/memcmp.c index e2395d4dfeb..5489048f5f9 100644 --- a/gcc/testsuite/gcc.c-torture/execute/string-opt-15.c +++ b/gcc/testsuite/gcc.c-torture/execute/builtins/memcmp.c @@ -4,15 +4,17 @@ On architectures with a cmpstrsi instruction, this test doesn't determine which optimization is being performed, but it does check for correctness. - Written by Roger Sayle, 12/02/2001. */ + Written by Roger Sayle, 12/02/2001. + Additional tests by Roger Sayle after PR 3508, 12/26/2001. */ extern void abort (void); typedef __SIZE_TYPE__ size_t; extern int memcmp (const void *, const void *, size_t); extern char *strcpy (char *, const char *); +extern void link_error (void); -int -main () +void +main_test (void) { char str[8]; @@ -30,18 +32,10 @@ main () if ( memcmp (str+2, str, 1) <= 0 ) abort (); - return 0; + if (memcmp ("abcd", "efgh", 4) >= 0) + link_error (); + if (memcmp ("abcd", "abcd", 4) != 0) + link_error (); + if (memcmp ("efgh", "abcd", 4) <= 0) + link_error (); } - -#ifdef __OPTIMIZE__ -/* When optimizing, all the above cases should be transformed into - something else. So any remaining calls to the original function - should abort. */ -__attribute__ ((noinline)) -static int -memcmp (const void *p1, const void *p2, size_t len) -{ - abort (); -} -#endif - diff --git a/gcc/testsuite/gcc.c-torture/execute/builtins/string-5-lib.c b/gcc/testsuite/gcc.c-torture/execute/builtins/memmove-lib.c similarity index 100% rename from gcc/testsuite/gcc.c-torture/execute/builtins/string-5-lib.c rename to gcc/testsuite/gcc.c-torture/execute/builtins/memmove-lib.c diff --git a/gcc/testsuite/gcc.c-torture/execute/builtins/string-5.c b/gcc/testsuite/gcc.c-torture/execute/builtins/memmove.c similarity index 100% rename from gcc/testsuite/gcc.c-torture/execute/builtins/string-5.c rename to gcc/testsuite/gcc.c-torture/execute/builtins/memmove.c diff --git a/gcc/testsuite/gcc.c-torture/execute/builtins/string-asm-2-lib.c b/gcc/testsuite/gcc.c-torture/execute/builtins/memops-asm-lib.c similarity index 100% rename from gcc/testsuite/gcc.c-torture/execute/builtins/string-asm-2-lib.c rename to gcc/testsuite/gcc.c-torture/execute/builtins/memops-asm-lib.c diff --git a/gcc/testsuite/gcc.c-torture/execute/builtins/string-asm-2.c b/gcc/testsuite/gcc.c-torture/execute/builtins/memops-asm.c similarity index 100% rename from gcc/testsuite/gcc.c-torture/execute/builtins/string-asm-2.c rename to gcc/testsuite/gcc.c-torture/execute/builtins/memops-asm.c diff --git a/gcc/testsuite/gcc.c-torture/execute/builtins/string-4-lib.c b/gcc/testsuite/gcc.c-torture/execute/builtins/mempcpy-2-lib.c similarity index 51% rename from gcc/testsuite/gcc.c-torture/execute/builtins/string-4-lib.c rename to gcc/testsuite/gcc.c-torture/execute/builtins/mempcpy-2-lib.c index 3b69c3baea8..cf3178c834a 100644 --- a/gcc/testsuite/gcc.c-torture/execute/builtins/string-4-lib.c +++ b/gcc/testsuite/gcc.c-torture/execute/builtins/mempcpy-2-lib.c @@ -1,2 +1 @@ -#include "lib/stpcpy.c" #include "lib/mempcpy.c" diff --git a/gcc/testsuite/gcc.c-torture/execute/builtins/string-7.c b/gcc/testsuite/gcc.c-torture/execute/builtins/mempcpy-2.c similarity index 90% rename from gcc/testsuite/gcc.c-torture/execute/builtins/string-7.c rename to gcc/testsuite/gcc.c-torture/execute/builtins/mempcpy-2.c index 5eb1ac4af78..dcaf07b67f1 100644 --- a/gcc/testsuite/gcc.c-torture/execute/builtins/string-7.c +++ b/gcc/testsuite/gcc.c-torture/execute/builtins/mempcpy-2.c @@ -8,7 +8,6 @@ extern void abort (void); typedef __SIZE_TYPE__ size_t; extern void *mempcpy (void *, const void *, size_t); extern int memcmp (const void *, const void *, size_t); -extern char *stpcpy (char *, const char *); extern int inside_main; long buf1[64]; @@ -16,7 +15,7 @@ char *buf2 = (char *) (buf1 + 32); long buf5[20]; char buf7[20]; -int +void __attribute__((noinline)) test (long *buf3, char *buf4, char *buf6, int n) { @@ -141,21 +140,6 @@ test (long *buf3, char *buf4, char *buf6, int n) if (mempcpy (buf4 + 14, buf6, n + 2) != buf2 + 16 || memcmp (buf2, "aBcdRSTUVWkSmnrsq\0", 19)) abort (); - - /* Now stpcpy tests. */ - if (stpcpy ((char *) buf3, "abcdefghijklmnop") != (char *) buf1 + 16 - || memcmp (buf1, "abcdefghijklmnop", 17)) - abort (); - - if (__builtin_stpcpy ((char *) buf3, "ABCDEFG") != (char *) buf1 + 7 - || memcmp (buf1, "ABCDEFG\0ijklmnop", 17)) - abort (); - - if (stpcpy ((char *) buf3 + i++, "x") != (char *) buf1 + 5 - || memcmp (buf1, "ABCDx\0G\0ijklmnop", 17)) - abort (); - - return 0; } void diff --git a/gcc/testsuite/gcc.c-torture/execute/builtins/string-7-lib.c b/gcc/testsuite/gcc.c-torture/execute/builtins/mempcpy-lib.c similarity index 51% rename from gcc/testsuite/gcc.c-torture/execute/builtins/string-7-lib.c rename to gcc/testsuite/gcc.c-torture/execute/builtins/mempcpy-lib.c index 3b69c3baea8..cf3178c834a 100644 --- a/gcc/testsuite/gcc.c-torture/execute/builtins/string-7-lib.c +++ b/gcc/testsuite/gcc.c-torture/execute/builtins/mempcpy-lib.c @@ -1,2 +1 @@ -#include "lib/stpcpy.c" #include "lib/mempcpy.c" diff --git a/gcc/testsuite/gcc.c-torture/execute/builtins/string-4.c b/gcc/testsuite/gcc.c-torture/execute/builtins/mempcpy.c similarity index 51% rename from gcc/testsuite/gcc.c-torture/execute/builtins/string-4.c rename to gcc/testsuite/gcc.c-torture/execute/builtins/mempcpy.c index 51819b1cfa9..d82e2232d7b 100644 --- a/gcc/testsuite/gcc.c-torture/execute/builtins/string-4.c +++ b/gcc/testsuite/gcc.c-torture/execute/builtins/mempcpy.c @@ -1,12 +1,10 @@ /* Copyright (C) 2003 Free Software Foundation. - Ensure builtin mempcpy and stpcpy perform correctly. + Ensure builtin mempcpy performs correctly. Written by Kaveh Ghazi, 4/11/2003. */ extern void abort (void); -extern char *strcpy (char *, const char *); -extern char *stpcpy (char *, const char *); typedef __SIZE_TYPE__ size_t; extern size_t strlen(const char *); extern void *memcpy (void *, const void *, size_t); @@ -32,55 +30,39 @@ main_test (void) inside_main = 0; #endif - if (stpcpy (p, "abcde") != p + 5 || memcmp (p, "abcde", 6)) - abort (); - if (stpcpy (p + 16, "vwxyz" + 1) != p + 16 + 4 || memcmp (p + 16, "wxyz", 5)) - abort (); - if (stpcpy (p + 1, "") != p + 1 + 0 || memcmp (p, "a\0cde", 6)) - abort (); - if (stpcpy (p + 3, "fghij") != p + 3 + 5 || memcmp (p, "a\0cfghij", 9)) - abort (); if (mempcpy (p, "ABCDE", 6) != p + 6 || memcmp (p, "ABCDE", 6)) abort (); - if (mempcpy (p + 16, "VWX" + 1, 2) != p + 16 + 2 || memcmp (p + 16, "WXyz", 5)) + if (mempcpy (p + 16, "VWX" + 1, 2) != p + 16 + 2 + || memcmp (p + 16, "WX\0\0", 5)) abort (); if (mempcpy (p + 1, "", 1) != p + 1 + 1 || memcmp (p, "A\0CDE", 6)) abort (); - if (mempcpy (p + 3, "FGHI", 4) != p + 3 + 4 || memcmp (p, "A\0CFGHIj", 9)) + if (mempcpy (p + 3, "FGHI", 4) != p + 3 + 4 || memcmp (p, "A\0CFGHI", 8)) abort (); i = 8; memcpy (p + 20, "qrstu", 6); - if (stpcpy ((i++, p + 20 + 1), "23") != (p + 20 + 1 + 2) || i != 9 || memcmp (p + 20, "q23\0u", 6)) - abort (); - memcpy (p + 25, "QRSTU", 6); - if (mempcpy (p + 25 + 1, s1, 3) != (p + 25 + 1 + 3) || memcmp (p + 25, "Q123U", 6)) + if (mempcpy (p + 25 + 1, s1, 3) != (p + 25 + 1 + 3) + || memcmp (p + 25, "Q123U", 6)) abort (); - if (stpcpy (stpcpy (p, "ABCD"), "EFG") != p + 7 || memcmp (p, "ABCDEFG", 8)) - abort(); - if (mempcpy (mempcpy (p, "abcdEFG", 4), "efg", 4) != p + 8 || memcmp (p, "abcdefg", 8)) + if (mempcpy (mempcpy (p, "abcdEFG", 4), "efg", 4) != p + 8 + || memcmp (p, "abcdefg", 8)) 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_stpcpy (p, "abcde") != p + 5 || memcmp (p, "abcde", 6)) - abort (); if (__builtin_mempcpy (p, "ABCDE", 6) != p + 6 || memcmp (p, "ABCDE", 6)) abort (); - /* If the result of stpcpy/mempcpy is ignored, gcc should use - strcpy/memcpy. This should be optimized always, so set inside_main - again. */ + /* If the result of mempcpy is ignored, gcc should use memcpy. + This should be optimized always, so set inside_main again. */ inside_main = 1; - stpcpy (p + 3, s2); - if (memcmp (p, "ABCdefg", 8)) - abort (); mempcpy (p + 5, s3, 1); - if (memcmp (p, "ABCdeFg", 8)) + if (memcmp (p, "ABCDEFg", 8)) abort (); - mempcpy (p + 6, s3 + 1, l1); - if (memcmp (p, "ABCdeFG", 8)) + mempcpy (p + 6, s1 + 1, l1); + if (memcmp (p, "ABCDEF2", 8)) abort (); } diff --git a/gcc/testsuite/gcc.c-torture/execute/builtins/memset-lib.c b/gcc/testsuite/gcc.c-torture/execute/builtins/memset-lib.c new file mode 100644 index 00000000000..2eeff38be24 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/builtins/memset-lib.c @@ -0,0 +1 @@ +#include "lib/memset.c" diff --git a/gcc/testsuite/gcc.c-torture/execute/builtins/string-3.c b/gcc/testsuite/gcc.c-torture/execute/builtins/memset.c similarity index 100% rename from gcc/testsuite/gcc.c-torture/execute/builtins/string-3.c rename to gcc/testsuite/gcc.c-torture/execute/builtins/memset.c diff --git a/gcc/testsuite/gcc.c-torture/execute/builtins/printf-lib.c b/gcc/testsuite/gcc.c-torture/execute/builtins/printf-lib.c new file mode 100644 index 00000000000..45ed7ec3738 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/builtins/printf-lib.c @@ -0,0 +1 @@ +#include "lib/printf.c" diff --git a/gcc/testsuite/gcc.c-torture/execute/stdio-opt-2.c b/gcc/testsuite/gcc.c-torture/execute/builtins/printf.c similarity index 77% rename from gcc/testsuite/gcc.c-torture/execute/stdio-opt-2.c rename to gcc/testsuite/gcc.c-torture/execute/builtins/printf.c index 833017ee547..0d01e544aa1 100644 --- a/gcc/testsuite/gcc.c-torture/execute/stdio-opt-2.c +++ b/gcc/testsuite/gcc.c-torture/execute/builtins/printf.c @@ -8,7 +8,8 @@ extern int printf (const char *, ...); extern void abort(void); -int main() +void +main_test (void) { const char *const s1 = "hello world"; const char *const s2[] = { s1, 0 }, *const*s3; @@ -37,18 +38,4 @@ int main() prototypes are set correctly too. */ __builtin_putchar ('\n'); __builtin_puts ("hello"); - - 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. */ -__attribute__ ((noinline)) -static int -printf (const char *string, ...) -{ - abort(); } -#endif diff --git a/gcc/testsuite/gcc.c-torture/execute/builtins/sprintf-lib.c b/gcc/testsuite/gcc.c-torture/execute/builtins/sprintf-lib.c new file mode 100644 index 00000000000..3a4fe34c0b1 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/builtins/sprintf-lib.c @@ -0,0 +1 @@ +#include "lib/sprintf.c" diff --git a/gcc/testsuite/gcc.c-torture/execute/string-opt-16.c b/gcc/testsuite/gcc.c-torture/execute/builtins/sprintf.c similarity index 80% rename from gcc/testsuite/gcc.c-torture/execute/string-opt-16.c rename to gcc/testsuite/gcc.c-torture/execute/builtins/sprintf.c index 8556b8f6517..b45926469f6 100644 --- a/gcc/testsuite/gcc.c-torture/execute/string-opt-16.c +++ b/gcc/testsuite/gcc.c-torture/execute/builtins/sprintf.c @@ -39,7 +39,8 @@ void test5(char *ptr) } -int main() +void +main_test (void) { memset (buffer, 'A', 32); test1 (); @@ -67,19 +68,4 @@ int main() test5 ("barf"); if (memcmp(buffer, "barf", 5) || buffer[5] != 'A') 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. */ -__attribute__ ((noinline)) -static int -sprintf (char *buf, const char *fmt, ...) -{ - abort (); -} -#endif - diff --git a/gcc/testsuite/gcc.c-torture/execute/builtins/string-9-lib.c b/gcc/testsuite/gcc.c-torture/execute/builtins/strcat-lib.c similarity index 100% rename from gcc/testsuite/gcc.c-torture/execute/builtins/string-9-lib.c rename to gcc/testsuite/gcc.c-torture/execute/builtins/strcat-lib.c diff --git a/gcc/testsuite/gcc.c-torture/execute/builtins/string-9.c b/gcc/testsuite/gcc.c-torture/execute/builtins/strcat.c similarity index 100% rename from gcc/testsuite/gcc.c-torture/execute/builtins/string-9.c rename to gcc/testsuite/gcc.c-torture/execute/builtins/strcat.c diff --git a/gcc/testsuite/gcc.c-torture/execute/builtins/string-2-lib.c b/gcc/testsuite/gcc.c-torture/execute/builtins/strchr-lib.c similarity index 100% rename from gcc/testsuite/gcc.c-torture/execute/builtins/string-2-lib.c rename to gcc/testsuite/gcc.c-torture/execute/builtins/strchr-lib.c diff --git a/gcc/testsuite/gcc.c-torture/execute/builtins/string-2.c b/gcc/testsuite/gcc.c-torture/execute/builtins/strchr.c similarity index 100% rename from gcc/testsuite/gcc.c-torture/execute/builtins/string-2.c rename to gcc/testsuite/gcc.c-torture/execute/builtins/strchr.c diff --git a/gcc/testsuite/gcc.c-torture/execute/builtins/strcmp-lib.c b/gcc/testsuite/gcc.c-torture/execute/builtins/strcmp-lib.c new file mode 100644 index 00000000000..99c421486e6 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/builtins/strcmp-lib.c @@ -0,0 +1 @@ +#include "lib/strcmp.c" diff --git a/gcc/testsuite/gcc.c-torture/execute/builtins/strcmp.c b/gcc/testsuite/gcc.c-torture/execute/builtins/strcmp.c new file mode 100644 index 00000000000..08a7658ea4e --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/builtins/strcmp.c @@ -0,0 +1,48 @@ +/* Copyright (C) 2000, 2003, 2004 Free Software Foundation. + + Ensure all expected transformations of builtin strcmp + occur and perform correctly. + + Written by Jakub Jelinek, 11/7/2000. */ + +extern void abort (void); +extern int strcmp (const char *, const char *); + +int x = 7; +char *bar = "hi world"; + +void +main_test (void) +{ + const char *const foo = "hello world"; + + if (strcmp (foo, "hello") <= 0) + abort (); + if (strcmp (foo + 2, "llo") <= 0) + abort (); + if (strcmp (foo, foo) != 0) + abort (); + if (strcmp (foo, "hello world ") >= 0) + abort (); + if (strcmp (foo + 10, "dx") >= 0) + abort (); + if (strcmp (10 + foo, "dx") >= 0) + abort (); + if (strcmp (bar, "") <= 0) + abort (); + if (strcmp ("", bar) >= 0) + abort (); + if (strcmp (bar+8, "") != 0) + abort (); + if (strcmp ("", bar+8) != 0) + abort (); + if (strcmp (bar+(--x), "") <= 0 || x != 6) + abort (); + if (strcmp ("", bar+(++x)) >= 0 || x != 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_strcmp (foo, "hello") <= 0) + abort (); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/builtins/strcpy-lib.c b/gcc/testsuite/gcc.c-torture/execute/builtins/strcpy-lib.c new file mode 100644 index 00000000000..b10dfcb0d79 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/builtins/strcpy-lib.c @@ -0,0 +1 @@ +#include "lib/strcpy.c" diff --git a/gcc/testsuite/gcc.c-torture/execute/string-opt-6.c b/gcc/testsuite/gcc.c-torture/execute/builtins/strcpy.c similarity index 81% rename from gcc/testsuite/gcc.c-torture/execute/string-opt-6.c rename to gcc/testsuite/gcc.c-torture/execute/builtins/strcpy.c index c684dbd4f13..0ca62b3a2d9 100644 --- a/gcc/testsuite/gcc.c-torture/execute/string-opt-6.c +++ b/gcc/testsuite/gcc.c-torture/execute/builtins/strcpy.c @@ -12,7 +12,8 @@ extern int memcmp (const void *, const void *, size_t); char p[32] = ""; -int main() +void +main_test (void) { if (strcpy (p, "abcde") != p || memcmp (p, "abcde", 6)) abort (); @@ -37,18 +38,4 @@ int main() abort (); if (__builtin_memcpy (p, "ABCDE", 6) != p || memcmp (p, "ABCDE", 6)) 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. */ -__attribute__ ((noinline)) -static char * -strcpy (char *d, const char *s) -{ - abort (); } -#endif diff --git a/gcc/testsuite/gcc.c-torture/execute/builtins/strcspn-lib.c b/gcc/testsuite/gcc.c-torture/execute/builtins/strcspn-lib.c new file mode 100644 index 00000000000..8b1cfea01e8 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/builtins/strcspn-lib.c @@ -0,0 +1 @@ +#include "lib/strcspn.c" diff --git a/gcc/testsuite/gcc.c-torture/execute/string-opt-12.c b/gcc/testsuite/gcc.c-torture/execute/builtins/strcspn.c similarity index 78% rename from gcc/testsuite/gcc.c-torture/execute/string-opt-12.c rename to gcc/testsuite/gcc.c-torture/execute/builtins/strcspn.c index 1d20f1e6708..be392546a54 100644 --- a/gcc/testsuite/gcc.c-torture/execute/string-opt-12.c +++ b/gcc/testsuite/gcc.c-torture/execute/builtins/strcspn.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 Free Software Foundation. +/* Copyright (C) 2000, 2004 Free Software Foundation. Ensure all expected transformations of builtin strcspn occur and perform correctly. @@ -10,7 +10,8 @@ typedef __SIZE_TYPE__ size_t; extern size_t strcspn (const char *, const char *); extern char *strcpy (char *, const char *); -int main () +void +main_test (void) { const char *const s1 = "hello world"; char dst[64], *d2; @@ -50,18 +51,4 @@ int main () to ensure that it works and that the prototype is correct. */ if (__builtin_strcspn (s1, "z") != 11) 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. */ -__attribute__ ((noinline)) -static size_t -strcspn (const char *s1, const char *s2) -{ - abort(); } -#endif diff --git a/gcc/testsuite/gcc.c-torture/execute/builtins/string-1-lib.c b/gcc/testsuite/gcc.c-torture/execute/builtins/string-1-lib.c deleted file mode 100644 index c9d8b8da7b9..00000000000 --- a/gcc/testsuite/gcc.c-torture/execute/builtins/string-1-lib.c +++ /dev/null @@ -1,3 +0,0 @@ -#include "lib/strrchr.c" -#include "lib/strlen.c" -#include "lib/strcmp.c" diff --git a/gcc/testsuite/gcc.c-torture/execute/builtins/string-1.c b/gcc/testsuite/gcc.c-torture/execute/builtins/string-1.c deleted file mode 100644 index 8a60e7e80ae..00000000000 --- a/gcc/testsuite/gcc.c-torture/execute/builtins/string-1.c +++ /dev/null @@ -1,87 +0,0 @@ -/* Copyright (C) 2000, 2003 Free Software Foundation. - - Ensure all expected transformations of builtin strlen, strcmp, - strrchr and rindex occur and perform correctly. - - Written by Jakub Jelinek, 11/7/2000. */ - -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"; - -void -main_test (void) -{ - const char *const foo = "hello world"; - - if (strlen (foo) != 11) - abort (); - if (strlen (foo + 4) != 7) - abort (); - if (strlen (foo + (x++ & 7)) != 5) - abort (); - if (x != 7) - abort (); - if (strcmp (foo, "hello") <= 0) - abort (); - if (strcmp (foo + 2, "llo") <= 0) - abort (); - if (strcmp (foo, foo) != 0) - abort (); - if (strcmp (foo, "hello world ") >= 0) - abort (); - if (strcmp (foo + 10, "dx") >= 0) - abort (); - if (strcmp (10 + foo, "dx") >= 0) - abort (); - if (strcmp (bar, "") <= 0) - abort (); - if (strcmp ("", bar) >= 0) - abort (); - if (strcmp (bar+8, "") != 0) - abort (); - if (strcmp ("", bar+8) != 0) - abort (); - if (strcmp (bar+(--x), "") <= 0 || x != 6) - abort (); - if (strcmp ("", bar+(++x)) >= 0 || x != 7) - abort (); - if (strrchr (foo, 'x')) - abort (); - if (strrchr (foo, 'o') != foo + 7) - abort (); - if (strrchr (foo, 'e') != foo + 1) - abort (); - if (strrchr (foo + 3, 'e')) - abort (); - if (strrchr (foo, '\0') != foo + 11) - abort (); - if (strrchr (bar, '\0') != bar + 8) - abort (); - if (strrchr (bar + 4, '\0') != bar + 8) - abort (); - if (strrchr (bar + (x++ & 3), '\0') != bar + 8) - abort (); - if (x != 8) - abort (); - /* 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 (); -} diff --git a/gcc/testsuite/gcc.c-torture/execute/builtins/string-6.c b/gcc/testsuite/gcc.c-torture/execute/builtins/string-6.c deleted file mode 100644 index 869dba17baa..00000000000 --- a/gcc/testsuite/gcc.c-torture/execute/builtins/string-6.c +++ /dev/null @@ -1,34 +0,0 @@ -/* Copyright (C) 2001 Free Software Foundation. - - Ensure that builtin memcmp operations when all three arguments - are constant is optimized and performs correctly. Taken from - PR optimize/3508. - - Written by Roger Sayle, 12/26/2001. */ - -extern void abort (void); -extern void link_error (void); - -typedef __SIZE_TYPE__ size_t; -extern int memcmp (const void *, const void *, size_t); - -void -main_test (void) -{ - if (memcmp ("abcd", "efgh", 4) >= 0) - link_error (); - if (memcmp ("abcd", "abcd", 4) != 0) - link_error (); - if (memcmp ("efgh", "abcd", 4) <= 0) - link_error (); -} - -#ifndef __OPTIMIZE__ -/* When not optimizing, the above tests may generate references to - the function link_error, but should never actually call it. */ -void -link_error () -{ - abort (); -} -#endif diff --git a/gcc/testsuite/gcc.c-torture/execute/builtins/string-8-lib.c b/gcc/testsuite/gcc.c-torture/execute/builtins/strlen-2-lib.c similarity index 100% rename from gcc/testsuite/gcc.c-torture/execute/builtins/string-8-lib.c rename to gcc/testsuite/gcc.c-torture/execute/builtins/strlen-2-lib.c diff --git a/gcc/testsuite/gcc.c-torture/execute/builtins/string-8.c b/gcc/testsuite/gcc.c-torture/execute/builtins/strlen-2.c similarity index 97% rename from gcc/testsuite/gcc.c-torture/execute/builtins/string-8.c rename to gcc/testsuite/gcc.c-torture/execute/builtins/strlen-2.c index 220b6ed8e2e..29569b769a9 100644 --- a/gcc/testsuite/gcc.c-torture/execute/builtins/string-8.c +++ b/gcc/testsuite/gcc.c-torture/execute/builtins/strlen-2.c @@ -8,7 +8,6 @@ typedef __SIZE_TYPE__ size_t; extern char *strcpy (char *, const char *); extern int memcmp (const void *, const void *, size_t); extern void abort (void); -extern void exit (int); extern int inside_main; size_t g, h, i, j, k, l; diff --git a/gcc/testsuite/gcc.c-torture/execute/builtins/strlen-lib.c b/gcc/testsuite/gcc.c-torture/execute/builtins/strlen-lib.c new file mode 100644 index 00000000000..9753c2498f1 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/builtins/strlen-lib.c @@ -0,0 +1 @@ +#include "lib/strlen.c" diff --git a/gcc/testsuite/gcc.c-torture/execute/builtins/strlen.c b/gcc/testsuite/gcc.c-torture/execute/builtins/strlen.c new file mode 100644 index 00000000000..cf77294713a --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/builtins/strlen.c @@ -0,0 +1,64 @@ +/* Copyright (C) 2000, 2001, 2003, 2004 Free Software Foundation. + + Ensure all expected transformations of builtin strlen + occur and perform correctly. + + Written by Jakub Jelinek, 11/7/2000. + + Additional tests written by Roger Sayle, 11/02/2001: + Ensure all builtin strlen comparisons against zero are optimized + and perform correctly. The multiple calls to strcpy are to prevent + the potentially "pure" strlen calls from being removed by CSE. */ + +extern void abort (void); +extern __SIZE_TYPE__ strlen (const char *); +extern char *strcpy (char *, const char *); + +int x = 6; + +void +main_test(void) +{ + const char *const foo = "hello world"; + char str[8]; + char *ptr; + + if (strlen (foo) != 11) + abort (); + if (strlen (foo + 4) != 7) + abort (); + if (strlen (foo + (x++ & 7)) != 5) + abort (); + if (x != 7) + abort (); + + ptr = str; + strcpy (ptr, "nts"); + if (strlen (ptr) == 0) + abort (); + + strcpy (ptr, "nts"); + if (strlen (ptr) < 1) + abort (); + + strcpy (ptr, "nts"); + if (strlen (ptr) <= 0) + abort (); + + strcpy (ptr, "nts"); + if (strlen (ptr+3) != 0) + abort (); + + strcpy (ptr, "nts"); + if (strlen (ptr+3) > 0) + abort (); + + strcpy (ptr, "nts"); + if (strlen (str+3) >= 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_strlen (foo) != 11) + abort (); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/builtins/strncat-lib.c b/gcc/testsuite/gcc.c-torture/execute/builtins/strncat-lib.c new file mode 100644 index 00000000000..1405a48f4bc --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/builtins/strncat-lib.c @@ -0,0 +1 @@ +#include "lib/strncat.c" diff --git a/gcc/testsuite/gcc.c-torture/execute/string-opt-10.c b/gcc/testsuite/gcc.c-torture/execute/builtins/strncat.c similarity index 88% rename from gcc/testsuite/gcc.c-torture/execute/string-opt-10.c rename to gcc/testsuite/gcc.c-torture/execute/builtins/strncat.c index b883dd61e01..2ef0e01aebc 100644 --- a/gcc/testsuite/gcc.c-torture/execute/string-opt-10.c +++ b/gcc/testsuite/gcc.c-torture/execute/builtins/strncat.c @@ -12,7 +12,8 @@ extern char *strcpy (char *, const char *); extern int strcmp (const char *, const char *); int x = 123; -int main () +void +main_test (void) { const char *const s1 = "hello world"; const char *const s2 = ""; @@ -68,18 +69,4 @@ int main () strcpy (dst, s1); if (__builtin_strncat (dst, "", 100) != dst || strcmp (dst, s1)) 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. */ -__attribute__ ((noinline)) -static char * -strncat (char *s1, const char *s2, size_t n) -{ - abort(); } -#endif diff --git a/gcc/testsuite/gcc.c-torture/execute/builtins/strncmp-2-lib.c b/gcc/testsuite/gcc.c-torture/execute/builtins/strncmp-2-lib.c new file mode 100644 index 00000000000..266c4a49b4f --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/builtins/strncmp-2-lib.c @@ -0,0 +1 @@ +#include "lib/strncmp.c" diff --git a/gcc/testsuite/gcc.c-torture/execute/string-opt-8.c b/gcc/testsuite/gcc.c-torture/execute/builtins/strncmp-2.c similarity index 71% rename from gcc/testsuite/gcc.c-torture/execute/string-opt-8.c rename to gcc/testsuite/gcc.c-torture/execute/builtins/strncmp-2.c index 2316fce87ca..c9d78783391 100644 --- a/gcc/testsuite/gcc.c-torture/execute/string-opt-8.c +++ b/gcc/testsuite/gcc.c-torture/execute/builtins/strncmp-2.c @@ -9,62 +9,13 @@ extern void abort (void); typedef __SIZE_TYPE__ size_t; extern int strncmp (const char *, const char *, size_t); -int main () +void +main_test (void) { const char *const s1 = "hello world"; const char *s2, *s3; int n = 6, x; - if (strncmp (s1, "hello world", 12) != 0) - abort(); - if (strncmp ("hello world", s1, 12) != 0) - abort(); - if (strncmp ("hello", "hello", 6) != 0) - abort(); - if (strncmp ("hello", "hello", 2) != 0) - abort(); - if (strncmp ("hello", "hello", 100) != 0) - abort(); - if (strncmp (s1+10, "d", 100) != 0) - abort(); - if (strncmp (10+s1, "d", 100) != 0) - abort(); - if (strncmp ("d", s1+10, 1) != 0) - abort(); - if (strncmp ("d", 10+s1, 1) != 0) - abort(); - if (strncmp ("hello", "aaaaa", 100) <= 0) - abort(); - if (strncmp ("aaaaa", "hello", 100) >= 0) - abort(); - if (strncmp ("hello", "aaaaa", 1) <= 0) - abort(); - if (strncmp ("aaaaa", "hello", 1) >= 0) - abort(); - - s2 = s1; s3 = s1+4; - if (strncmp (++s2, ++s3, 0) != 0 || s2 != s1+1 || s3 != s1+5) - abort(); - s2 = s1; - if (strncmp (++s2, "", 1) <= 0 || s2 != s1+1) - abort(); - if (strncmp ("", ++s2, 1) >= 0 || s2 != s1+2) - abort(); - if (strncmp (++s2, "", 100) <= 0 || s2 != s1+3) - abort(); - if (strncmp ("", ++s2, 100) >= 0 || s2 != s1+4) - abort(); - if (strncmp (++s2+6, "", 100) != 0 || s2 != s1+5) - abort(); - if (strncmp ("", ++s2+5, 100) != 0 || s2 != s1+6) - abort(); - if (strncmp ("ozz", ++s2, 1) != 0 || s2 != s1+7) - abort(); - if (strncmp (++s2, "rzz", 1) != 0 || s2 != s1+8) - abort(); - s2 = s1; s3 = s1+4; - if (strncmp (++s2, ++s3+2, 1) >= 0 || s2 != s1+1 || s3 != s1+5) - abort(); #if !defined(__OPTIMIZE__) || (defined(__i386__) && !defined(__OPTIMIZE_SIZE__)) /* These tests work on platforms which support cmpstrsi. We test it at -O0 on all platforms to ensure the strncmp logic is correct. */ @@ -219,23 +170,4 @@ 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; -} - -#ifdef __OPTIMIZE__ -/* When optimizing, all the above cases should be transformed into - something else. So any remaining calls to the original function - should abort. */ -__attribute__ ((noinline)) -static int -strncmp(const char *s1, const char *s2, size_t n) -{ - abort(); } -#endif diff --git a/gcc/testsuite/gcc.c-torture/execute/builtins/strncmp-lib.c b/gcc/testsuite/gcc.c-torture/execute/builtins/strncmp-lib.c new file mode 100644 index 00000000000..266c4a49b4f --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/builtins/strncmp-lib.c @@ -0,0 +1 @@ +#include "lib/strncmp.c" diff --git a/gcc/testsuite/gcc.c-torture/execute/builtins/strncmp.c b/gcc/testsuite/gcc.c-torture/execute/builtins/strncmp.c new file mode 100644 index 00000000000..888faf569e7 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/builtins/strncmp.c @@ -0,0 +1,74 @@ +/* Copyright (C) 2000, 2001, 2003 Free Software Foundation. + + Ensure all expected transformations of builtin strncmp occur and + perform correctly. + + Written by Kaveh R. Ghazi, 11/26/2000. */ + +extern void abort (void); +typedef __SIZE_TYPE__ size_t; +extern int strncmp (const char *, const char *, size_t); + +void +main_test (void) +{ + const char *const s1 = "hello world"; + const char *s2, *s3; + int n = 6, x; + + if (strncmp (s1, "hello world", 12) != 0) + abort(); + if (strncmp ("hello world", s1, 12) != 0) + abort(); + if (strncmp ("hello", "hello", 6) != 0) + abort(); + if (strncmp ("hello", "hello", 2) != 0) + abort(); + if (strncmp ("hello", "hello", 100) != 0) + abort(); + if (strncmp (s1+10, "d", 100) != 0) + abort(); + if (strncmp (10+s1, "d", 100) != 0) + abort(); + if (strncmp ("d", s1+10, 1) != 0) + abort(); + if (strncmp ("d", 10+s1, 1) != 0) + abort(); + if (strncmp ("hello", "aaaaa", 100) <= 0) + abort(); + if (strncmp ("aaaaa", "hello", 100) >= 0) + abort(); + if (strncmp ("hello", "aaaaa", 1) <= 0) + abort(); + if (strncmp ("aaaaa", "hello", 1) >= 0) + abort(); + + s2 = s1; s3 = s1+4; + if (strncmp (++s2, ++s3, 0) != 0 || s2 != s1+1 || s3 != s1+5) + abort(); + s2 = s1; + if (strncmp (++s2, "", 1) <= 0 || s2 != s1+1) + abort(); + if (strncmp ("", ++s2, 1) >= 0 || s2 != s1+2) + abort(); + if (strncmp (++s2, "", 100) <= 0 || s2 != s1+3) + abort(); + if (strncmp ("", ++s2, 100) >= 0 || s2 != s1+4) + abort(); + if (strncmp (++s2+6, "", 100) != 0 || s2 != s1+5) + abort(); + if (strncmp ("", ++s2+5, 100) != 0 || s2 != s1+6) + abort(); + if (strncmp ("ozz", ++s2, 1) != 0 || s2 != s1+7) + abort(); + if (strncmp (++s2, "rzz", 1) != 0 || s2 != s1+8) + abort(); + s2 = s1; s3 = s1+4; + if (strncmp (++s2, ++s3+2, 1) >= 0 || s2 != s1+1 || s3 != s1+5) + 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_strncmp ("hello", "a", 100) <= 0) + abort(); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/builtins/strncpy-lib.c b/gcc/testsuite/gcc.c-torture/execute/builtins/strncpy-lib.c new file mode 100644 index 00000000000..784f72d0335 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/builtins/strncpy-lib.c @@ -0,0 +1 @@ +#include "lib/strncpy.c" diff --git a/gcc/testsuite/gcc.c-torture/execute/string-opt-7.c b/gcc/testsuite/gcc.c-torture/execute/builtins/strncpy.c similarity index 87% rename from gcc/testsuite/gcc.c-torture/execute/string-opt-7.c rename to gcc/testsuite/gcc.c-torture/execute/builtins/strncpy.c index 5b915d7a7d3..c0a815701e6 100644 --- a/gcc/testsuite/gcc.c-torture/execute/string-opt-7.c +++ b/gcc/testsuite/gcc.c-torture/execute/builtins/strncpy.c @@ -14,7 +14,8 @@ extern void *memset (void *, int, size_t); int i; -int main () +void +main_test (void) { const char *const src = "hello world"; const char *src2; @@ -72,15 +73,3 @@ int main () 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. */ -__attribute__ ((noinline)) -static char * -strncpy(char *s1, const char *s2, size_t n) -{ - abort(); -} -#endif diff --git a/gcc/testsuite/gcc.c-torture/execute/builtins/strpbrk-lib.c b/gcc/testsuite/gcc.c-torture/execute/builtins/strpbrk-lib.c new file mode 100644 index 00000000000..66bf8be7c84 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/builtins/strpbrk-lib.c @@ -0,0 +1 @@ +#include "lib/strpbrk.c" diff --git a/gcc/testsuite/gcc.c-torture/execute/string-opt-2.c b/gcc/testsuite/gcc.c-torture/execute/builtins/strpbrk.c similarity index 77% rename from gcc/testsuite/gcc.c-torture/execute/string-opt-2.c rename to gcc/testsuite/gcc.c-torture/execute/builtins/strpbrk.c index d8ebb77be51..cc963a9af5e 100644 --- a/gcc/testsuite/gcc.c-torture/execute/string-opt-2.c +++ b/gcc/testsuite/gcc.c-torture/execute/builtins/strpbrk.c @@ -34,22 +34,9 @@ void fn (const char *foo, const char *const *bar) abort(); } -int main() +void +main_test (void) { const char *const foo[] = { "hello world", "bye bye world" }; fn (foo[0], foo + 1); - 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. */ -__attribute__ ((noinline)) -static char * -strpbrk(const char *s1, const char *s2) -{ - abort(); -} -#endif diff --git a/gcc/testsuite/gcc.c-torture/execute/builtins/strpcpy-2-lib.c b/gcc/testsuite/gcc.c-torture/execute/builtins/strpcpy-2-lib.c new file mode 100644 index 00000000000..b31cdf4f594 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/builtins/strpcpy-2-lib.c @@ -0,0 +1 @@ +#include "lib/stpcpy.c" diff --git a/gcc/testsuite/gcc.c-torture/execute/builtins/strpcpy-2.c b/gcc/testsuite/gcc.c-torture/execute/builtins/strpcpy-2.c new file mode 100644 index 00000000000..eb275c422c2 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/builtins/strpcpy-2.c @@ -0,0 +1,45 @@ +/* Copyright (C) 2003 Free Software Foundation. + + Ensure that builtin stpcpy performs correctly. + + Written by Jakub Jelinek, 21/05/2003. */ + +extern void abort (void); +typedef __SIZE_TYPE__ size_t; +extern int memcmp (const void *, const void *, size_t); +extern char *stpcpy (char *, const char *); +extern int inside_main; + +long buf1[64]; +char *buf2 = (char *) (buf1 + 32); +long buf5[20]; +char buf7[20]; + +void +__attribute__((noinline)) +test (long *buf3, char *buf4, char *buf6, int n) +{ + int i = 4; + + if (stpcpy ((char *) buf3, "abcdefghijklmnop") != (char *) buf1 + 16 + || memcmp (buf1, "abcdefghijklmnop", 17)) + abort (); + + if (__builtin_stpcpy ((char *) buf3, "ABCDEFG") != (char *) buf1 + 7 + || memcmp (buf1, "ABCDEFG\0ijklmnop", 17)) + abort (); + + if (stpcpy ((char *) buf3 + i++, "x") != (char *) buf1 + 5 + || memcmp (buf1, "ABCDx\0G\0ijklmnop", 17)) + abort (); +} + +void +main_test (void) +{ + /* All these tests are allowed to call mempcpy/stpcpy. */ + inside_main = 0; + __builtin_memcpy (buf5, "RSTUVWXYZ0123456789", 20); + __builtin_memcpy (buf7, "RSTUVWXYZ0123456789", 20); + test (buf1, buf2, "rstuvwxyz", 0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/builtins/strpcpy-lib.c b/gcc/testsuite/gcc.c-torture/execute/builtins/strpcpy-lib.c new file mode 100644 index 00000000000..b31cdf4f594 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/builtins/strpcpy-lib.c @@ -0,0 +1 @@ +#include "lib/stpcpy.c" diff --git a/gcc/testsuite/gcc.c-torture/execute/builtins/strpcpy.c b/gcc/testsuite/gcc.c-torture/execute/builtins/strpcpy.c new file mode 100644 index 00000000000..737bfaa805a --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/builtins/strpcpy.c @@ -0,0 +1,60 @@ +/* Copyright (C) 2003, 2004 Free Software Foundation. + + Ensure builtin stpcpy performs correctly. + + Written by Kaveh Ghazi, 4/11/2003. */ + +typedef __SIZE_TYPE__ size_t; + +extern void abort (void); +extern char *strcpy (char *, const char *); +extern char *stpcpy (char *, const char *); +extern int memcmp (const void *, const void *, size_t); + +extern int inside_main; + +const char s1[] = "123"; +char p[32] = ""; +char *s2 = "defg"; +char *s3 = "FGH"; +size_t l1 = 1; + +void +main_test (void) +{ + int i = 8; + +#if !defined __i386__ && !defined __x86_64__ + /* The functions below might not be optimized into direct stores on all + arches. It depends on how many instructions would be generated and + what limits the architecture chooses in STORE_BY_PIECES_P. */ + inside_main = 0; +#endif + if (stpcpy (p, "abcde") != p + 5 || memcmp (p, "abcde", 6)) + abort (); + if (stpcpy (p + 16, "vwxyz" + 1) != p + 16 + 4 || memcmp (p + 16, "wxyz", 5)) + abort (); + if (stpcpy (p + 1, "") != p + 1 + 0 || memcmp (p, "a\0cde", 6)) + abort (); + if (stpcpy (p + 3, "fghij") != p + 3 + 5 || memcmp (p, "a\0cfghij", 9)) + abort (); + + if (stpcpy ((i++, p + 20 + 1), "23") != (p + 20 + 1 + 2) + || i != 9 || memcmp (p + 19, "z\0""23\0", 5)) + abort (); + + if (stpcpy (stpcpy (p, "ABCD"), "EFG") != p + 7 || memcmp (p, "ABCDEFG", 8)) + 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_stpcpy (p, "abcde") != p + 5 || memcmp (p, "abcde", 6)) + abort (); + + /* If the result of stpcpy is ignored, gcc should use strcpy. + This should be optimized always, so set inside_main again. */ + inside_main = 1; + stpcpy (p + 3, s3); + if (memcmp (p, "abcFGH", 6)) + abort (); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/builtins/strrchr-lib.c b/gcc/testsuite/gcc.c-torture/execute/builtins/strrchr-lib.c new file mode 100644 index 00000000000..90475eca33d --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/builtins/strrchr-lib.c @@ -0,0 +1 @@ +#include "lib/strrchr.c" diff --git a/gcc/testsuite/gcc.c-torture/execute/builtins/strrchr.c b/gcc/testsuite/gcc.c-torture/execute/builtins/strrchr.c new file mode 100644 index 00000000000..3cc8faa2e23 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/builtins/strrchr.c @@ -0,0 +1,49 @@ +/* Copyright (C) 2000, 2003, 2004 Free Software Foundation. + + Ensure all expected transformations of builtin strrchr and rindex + occur and perform correctly. + + Written by Jakub Jelinek, 11/7/2000. */ + +extern void abort (void); +extern char *strrchr (const char *, int); +extern char *rindex (const char *, int); + +char *bar = "hi world"; +int x = 7; + +void +main_test (void) +{ + const char *const foo = "hello world"; + + if (strrchr (foo, 'x')) + abort (); + if (strrchr (foo, 'o') != foo + 7) + abort (); + if (strrchr (foo, 'e') != foo + 1) + abort (); + if (strrchr (foo + 3, 'e')) + abort (); + if (strrchr (foo, '\0') != foo + 11) + abort (); + if (strrchr (bar, '\0') != bar + 8) + abort (); + if (strrchr (bar + 4, '\0') != bar + 8) + abort (); + if (strrchr (bar + (x++ & 3), '\0') != bar + 8) + abort (); + if (x != 8) + abort (); + /* 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_strrchr (foo, 'o') != foo + 7) + abort (); + if (__builtin_rindex (foo, 'o') != foo + 7) + abort (); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/builtins/strspn-lib.c b/gcc/testsuite/gcc.c-torture/execute/builtins/strspn-lib.c new file mode 100644 index 00000000000..9e044d793e1 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/builtins/strspn-lib.c @@ -0,0 +1 @@ +#include "lib/strspn.c" diff --git a/gcc/testsuite/gcc.c-torture/execute/string-opt-11.c b/gcc/testsuite/gcc.c-torture/execute/builtins/strspn.c similarity index 81% rename from gcc/testsuite/gcc.c-torture/execute/string-opt-11.c rename to gcc/testsuite/gcc.c-torture/execute/builtins/strspn.c index 0aa186299df..4f2782a58b6 100644 --- a/gcc/testsuite/gcc.c-torture/execute/string-opt-11.c +++ b/gcc/testsuite/gcc.c-torture/execute/builtins/strspn.c @@ -10,7 +10,8 @@ typedef __SIZE_TYPE__ size_t; extern size_t strspn (const char *, const char *); extern char *strcpy (char *, const char *); -int main () +void +main_test (void) { const char *const s1 = "hello world"; char dst[64], *d2; @@ -50,18 +51,4 @@ int main () to ensure that it works and that the prototype is correct. */ if (__builtin_strspn (s1, "hello") != 5) 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. */ -__attribute__ ((noinline)) -static size_t -strspn (const char *s1, const char *s2) -{ - abort(); } -#endif diff --git a/gcc/testsuite/gcc.c-torture/execute/builtins/string-asm-1-lib.c b/gcc/testsuite/gcc.c-torture/execute/builtins/strstr-asm-lib.c similarity index 100% rename from gcc/testsuite/gcc.c-torture/execute/builtins/string-asm-1-lib.c rename to gcc/testsuite/gcc.c-torture/execute/builtins/strstr-asm-lib.c diff --git a/gcc/testsuite/gcc.c-torture/execute/builtins/string-asm-1.c b/gcc/testsuite/gcc.c-torture/execute/builtins/strstr-asm.c similarity index 100% rename from gcc/testsuite/gcc.c-torture/execute/builtins/string-asm-1.c rename to gcc/testsuite/gcc.c-torture/execute/builtins/strstr-asm.c diff --git a/gcc/testsuite/gcc.c-torture/execute/builtins/strstr-lib.c b/gcc/testsuite/gcc.c-torture/execute/builtins/strstr-lib.c new file mode 100644 index 00000000000..591058de499 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/builtins/strstr-lib.c @@ -0,0 +1 @@ +#include "lib/strstr.c" diff --git a/gcc/testsuite/gcc.c-torture/execute/string-opt-1.c b/gcc/testsuite/gcc.c-torture/execute/builtins/strstr.c similarity index 72% rename from gcc/testsuite/gcc.c-torture/execute/string-opt-1.c rename to gcc/testsuite/gcc.c-torture/execute/builtins/strstr.c index 6b59c10f29b..ae503aa43e0 100644 --- a/gcc/testsuite/gcc.c-torture/execute/string-opt-1.c +++ b/gcc/testsuite/gcc.c-torture/execute/builtins/strstr.c @@ -8,7 +8,8 @@ extern void abort(void); extern char *strstr (const char *, const char *); -int main() +void +main_test (void) { const char *const foo = "hello world"; @@ -29,18 +30,4 @@ int main() to ensure that it works and that the prototype is correct. */ if (__builtin_strstr (foo + 1, "world") != foo + 6) 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. */ -__attribute__ ((noinline)) -static char * -strstr(const char *s1, const char *s2) -{ - abort(); } -#endif diff --git a/gcc/testsuite/gcc.c-torture/execute/string-opt-13.c b/gcc/testsuite/gcc.c-torture/execute/string-opt-13.c deleted file mode 100644 index 9d79ef0d817..00000000000 --- a/gcc/testsuite/gcc.c-torture/execute/string-opt-13.c +++ /dev/null @@ -1,59 +0,0 @@ -/* Copyright (C) 2001 Free Software Foundation. - - Ensure all builtin strlen comparisons against zero are optimized - and perform correctly. The multiple calls to strcpy are to prevent - the potentially "pure" strlen calls from being removed by CSE. - - Written by Roger Sayle, 11/02/2001. */ - -extern void abort (void); -typedef __SIZE_TYPE__ size_t; -extern size_t strlen (const char *); -extern char *strcpy (char *, const char *); - -int -main () -{ - char str[8]; - char *ptr; - - ptr = str; - strcpy (ptr, "nts"); - if (strlen (ptr) == 0) - abort (); - - strcpy (ptr, "nts"); - if (strlen (ptr) < 1) - abort (); - - strcpy (ptr, "nts"); - if (strlen (ptr) <= 0) - abort (); - - strcpy (ptr, "nts"); - if (strlen (ptr+3) != 0) - abort (); - - strcpy (ptr, "nts"); - if (strlen (ptr+3) > 0) - abort (); - - strcpy (ptr, "nts"); - if (strlen (str+3) >= 1) - 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. */ -__attribute__ ((noinline)) -static size_t -strlen (const char *s) -{ - abort (); -} -#endif - diff --git a/gcc/testsuite/gcc.c-torture/execute/string-opt-14.c b/gcc/testsuite/gcc.c-torture/execute/string-opt-14.c deleted file mode 100644 index cb0bfcb9dff..00000000000 --- a/gcc/testsuite/gcc.c-torture/execute/string-opt-14.c +++ /dev/null @@ -1,42 +0,0 @@ -/* Copyright (C) 2001 Free Software Foundation. - - Ensure builtin memset and memcpy are optimized away correctly. - - Written by Roger Sayle, 11/23/2001. */ - -extern void abort (void); -typedef __SIZE_TYPE__ size_t; -extern void *memset (void *s, int c, size_t n); -extern void *memcpy (void *dest, const void *src, size_t n); - -char dst[32]; -char src[32]; - -int -main () -{ - memset (src, 0, 0); - memcpy (dst, src, 0); - 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. */ - -__attribute__ ((noinline)) -static void * -memset (void *s, int c, size_t n) -{ - abort (); -} - -__attribute__ ((noinline)) -static void * -memcpy (void *dest, const void *src, size_t n) -{ - abort (); -} -#endif - -- 2.30.2