diff options
Diffstat (limited to 'gcc/testsuite/gcc.dg/charset')
-rw-r--r-- | gcc/testsuite/gcc.dg/charset/asm1.c | 14 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/charset/asm2.c | 16 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/charset/asm3.c | 33 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/charset/asm4.c | 10 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/charset/asm5.c | 8 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/charset/asm6.c | 13 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/charset/attribute1.c | 10 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/charset/attribute2.c | 8 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/charset/builtin1.c | 26 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/charset/builtin2.c | 32 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/charset/charset.exp | 44 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/charset/extern.c | 11 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/charset/function.c | 10 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/charset/string.c | 5 |
14 files changed, 240 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/charset/asm1.c b/gcc/testsuite/gcc.dg/charset/asm1.c new file mode 100644 index 000000000..dfd140186 --- /dev/null +++ b/gcc/testsuite/gcc.dg/charset/asm1.c @@ -0,0 +1,14 @@ +/* { dg-do compile } + { dg-require-iconv "IBM1047" } + { dg-final { scan-assembler ".ascii bar" } } + { dg-final { scan-assembler ".ascii foo" } } + */ +extern int x, y; + +asm (".ascii bar"); + +int foo (void) +{ + __asm__ (".ascii foo"); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/charset/asm2.c b/gcc/testsuite/gcc.dg/charset/asm2.c new file mode 100644 index 000000000..a9a9c011b --- /dev/null +++ b/gcc/testsuite/gcc.dg/charset/asm2.c @@ -0,0 +1,16 @@ +/* Test for execution character set encoding errors. + If we ever get a good way to test error recovery + the string "foobar" should be translated. */ +/* { dg-do compile } */ +/* { dg-require-iconv "IBM1047" } */ +asm (not_a_string); /* { dg-error "(parse error|syntax error|expected string literal) before" "not_a_string" } */ +char x[] = "foobar"; + +void foo (void) +{ + char *y; + asm (not_a_string2); /* { dg-error "(parse error|syntax error|expected string literal) before" "not_a_string" } */ + +#define FOO "walrus" + y = FOO; +} diff --git a/gcc/testsuite/gcc.dg/charset/asm3.c b/gcc/testsuite/gcc.dg/charset/asm3.c new file mode 100644 index 000000000..842bd5cfc --- /dev/null +++ b/gcc/testsuite/gcc.dg/charset/asm3.c @@ -0,0 +1,33 @@ +/* Test for complex asm statements. Make sure it compiles + then test for some of the asm statements not being translated. */ +/* { dg-do compile { target { { i?86-*-* x86_64-*-* } && ilp32 } } } + { dg-require-iconv "IBM1047" } + { dg-final { scan-assembler "std" } } + { dg-final { scan-assembler "cld" } } + { dg-final { scan-assembler "rep" } } + { dg-final { scan-assembler "movsb" } } */ +#define size_t int +void * +memmove (void *__dest, __const void *__src, size_t __n) +{ + register unsigned long int __d0, __d1, __d2; + if (__dest < __src) + __asm__ __volatile__ + ("cld\n\t" + "rep\n\t" + "movsb" + : "=&c" (__d0), "=&S" (__d1), "=&D" (__d2) + : "0" (__n), "1" (__src), "2" (__dest) + : "memory"); + else + __asm__ __volatile__ + ("std\n\t" + "rep\n\t" + "movsb\n\t" + "cld" + : "=&c" (__d0), "=&S" (__d1), "=&D" (__d2) + : "0" (__n), "1" (__n - 1 + (const char *) __src), + "2" (__n - 1 + (char *) __dest) + : "memory"); + return __dest; +} diff --git a/gcc/testsuite/gcc.dg/charset/asm4.c b/gcc/testsuite/gcc.dg/charset/asm4.c new file mode 100644 index 000000000..59c8d59ff --- /dev/null +++ b/gcc/testsuite/gcc.dg/charset/asm4.c @@ -0,0 +1,10 @@ +/* Simple asm test. */ +/* { dg-do compile } + { dg-require-iconv "IBM1047" } + { dg-final { scan-assembler "foo" } } */ +extern int bar; + +int main (void) +{ + asm ("foo %0" : "=r" (bar)); +} diff --git a/gcc/testsuite/gcc.dg/charset/asm5.c b/gcc/testsuite/gcc.dg/charset/asm5.c new file mode 100644 index 000000000..a4bb01401 --- /dev/null +++ b/gcc/testsuite/gcc.dg/charset/asm5.c @@ -0,0 +1,8 @@ +/* Test for string translation. */ +/* { dg-do compile } + { dg-require-iconv "IBM1047" } + { dg-final { scan-assembler-not "translate" } } */ +void foo (void) +{ + asm ("xx" : : "r"("translate") : "cc"); +} diff --git a/gcc/testsuite/gcc.dg/charset/asm6.c b/gcc/testsuite/gcc.dg/charset/asm6.c new file mode 100644 index 000000000..ae2ec485d --- /dev/null +++ b/gcc/testsuite/gcc.dg/charset/asm6.c @@ -0,0 +1,13 @@ +/* Test for string translation. */ +/* { dg-do compile } + { dg-require-iconv "IBM1047" } + { dg-final { scan-assembler "foo" } } */ +int main() +{ + unsigned long int *ptr; + ptr = ((unsigned long int *) + ( { void *stack_ptr; + __asm__ __volatile__ ( "foo %0" : "=r" (stack_ptr) ); + (stack_ptr); } ) ); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/charset/attribute1.c b/gcc/testsuite/gcc.dg/charset/attribute1.c new file mode 100644 index 000000000..799630030 --- /dev/null +++ b/gcc/testsuite/gcc.dg/charset/attribute1.c @@ -0,0 +1,10 @@ +/* Test for attribute non-translation. */ +/* { dg-do compile } + { dg-require-iconv "IBM1047" } + { dg-final { scan-assembler "foo" } } */ +int walrus __attribute__ ((section (".foo"))); + +int main (void) +{ + return 0; +} diff --git a/gcc/testsuite/gcc.dg/charset/attribute2.c b/gcc/testsuite/gcc.dg/charset/attribute2.c new file mode 100644 index 000000000..427e94979 --- /dev/null +++ b/gcc/testsuite/gcc.dg/charset/attribute2.c @@ -0,0 +1,8 @@ +/* Test to make sure that invalid attributes aren't translated. + If error recovery is ever testable then "foobar" should be + translated. */ +/* { dg-do compile } + { dg-require-iconv "IBM1047" } + */ +int foo __attribute__ ((walrus)); /* { dg-warning "walrus" "ignored" } */ +char x[] = "foobar"; diff --git a/gcc/testsuite/gcc.dg/charset/builtin1.c b/gcc/testsuite/gcc.dg/charset/builtin1.c new file mode 100644 index 000000000..753049c96 --- /dev/null +++ b/gcc/testsuite/gcc.dg/charset/builtin1.c @@ -0,0 +1,26 @@ +/* isdigit(c) can be optimized to ((unsigned)c) - '0' <= 9, but only if + we know the correct value of '0'. PR 18785. */ + +/* { dg-do run } */ +/* { dg-require-iconv "IBM1047" } */ +/* { dg-options "-O2 -fno-inline -fexec-charset=IBM1047" } */ + +extern int isdigit(int); +extern void abort(void); + +static int str1(void) { return '1'; } +static int strA(void) { return 'A'; } + +int +main(void) +{ + if (!isdigit('1')) + abort(); + if (isdigit('A')) + abort(); + if (!isdigit(str1())) + abort(); + if (isdigit(strA())) + abort(); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/charset/builtin2.c b/gcc/testsuite/gcc.dg/charset/builtin2.c new file mode 100644 index 000000000..bfe9a20e2 --- /dev/null +++ b/gcc/testsuite/gcc.dg/charset/builtin2.c @@ -0,0 +1,32 @@ +/* Ensure that transformations of *printf are performed correctly + regardless of -fexec-charset. See PR 25120. */ + +/* { dg-do compile } */ +/* { dg-require-iconv "IBM1047" } */ +/* { dg-options "-O2 -fexec-charset=IBM1047" } */ +/* { dg-final { scan-assembler-not "printf" } } */ +/* { dg-final { scan-assembler-not "fprintf" } } */ +/* { dg-final { scan-assembler-not "sprintf" } } */ + +#include <stdio.h> + +void foo (char *dst, const char *src) +{ + printf ("\n"); + printf ("hello world\n"); + printf ("%s", "\n"); + printf ("%s", "hello world\n"); + printf ("%c", '\n'); + printf ("%s\n", "hello world"); + printf ("%s\n", src); + + fprintf (stdout, "\n"); + fprintf (stdout, "hello world\n"); + fprintf (stdout, "%s", "\n"); + fprintf (stdout, "%s", "hello world\n"); + fprintf (stdout, "%c", '\n'); + fprintf (stdout, "%s", src); + + sprintf (dst, "hello world\n"); + sprintf (dst, "%s", src); +} diff --git a/gcc/testsuite/gcc.dg/charset/charset.exp b/gcc/testsuite/gcc.dg/charset/charset.exp new file mode 100644 index 000000000..7e3a1348e --- /dev/null +++ b/gcc/testsuite/gcc.dg/charset/charset.exp @@ -0,0 +1,44 @@ +# Copyright (C) 2004, 2007 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GCC; see the file COPYING3. If not see +# <http://www.gnu.org/licenses/>. + +# GCC testsuite that uses the 'dg.exp' driver. + +# There's a bunch of headers we need. +if [is_remote host] { + foreach header [glob -nocomplain $srcdir/$subdir/*.{h,def} ] { + remote_download host $header + } +} + +# Load support procs. +load_lib gcc-dg.exp +load_lib target-supports.exp + +# If a testcase doesn't have special options, use these. +global DEFAULT_CHARSETCFLAGS +if ![info exists DEFAULT_CHARSETCFLAGS] then { + set DEFAULT_CHARSETCFLAGS "-fexec-charset=IBM1047" +} + +# Initialize `dg'. +dg-init + +# Main loop. +dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.{c,S} ]] \ + "" $DEFAULT_CHARSETCFLAGS + +# All done. +dg-finish diff --git a/gcc/testsuite/gcc.dg/charset/extern.c b/gcc/testsuite/gcc.dg/charset/extern.c new file mode 100644 index 000000000..05a0c3e42 --- /dev/null +++ b/gcc/testsuite/gcc.dg/charset/extern.c @@ -0,0 +1,11 @@ +/* { dg-do compile } + { dg-require-iconv "IBM1047" } + { dg-final { scan-assembler-not "abcdefghijklmnopqrstuvwxyz" } } */ + +extern char *bar; + +extern void foo (void) +{ + char str[]="abcdefghijklmnopqrstuvwxyz"; + bar = str; +} diff --git a/gcc/testsuite/gcc.dg/charset/function.c b/gcc/testsuite/gcc.dg/charset/function.c new file mode 100644 index 000000000..5aba6511b --- /dev/null +++ b/gcc/testsuite/gcc.dg/charset/function.c @@ -0,0 +1,10 @@ +/* { dg-do compile } + { dg-require-iconv "IBM1047" } + { dg-final { scan-assembler-not "\"foobar\"" } } */ + +const char *str; + +void foobar (void) +{ + str = __FUNCTION__; +} diff --git a/gcc/testsuite/gcc.dg/charset/string.c b/gcc/testsuite/gcc.dg/charset/string.c new file mode 100644 index 000000000..f720773dd --- /dev/null +++ b/gcc/testsuite/gcc.dg/charset/string.c @@ -0,0 +1,5 @@ +/* Simple character translation test. */ +/* { dg-do compile } + { dg-require-iconv "IBM1047" } + { dg-final { scan-assembler-not "string foobar" } } */ +char *foo = "string foobar"; |