This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[patch, rfa] charset testsuite patches, take 2
- From: Eric Christopher <echristo at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Tue, 24 Feb 2004 19:14:57 -0800
- Subject: [patch, rfa] charset testsuite patches, take 2
OK. Here are the testsuite patches with dg-require-iconv.
I haven't modified libstdc++ and I'll do that in a follow-up patch
unless someone wants it in this one :)
I specifically didn't modify gcc.c-torture/execute/wchar_t-1.c since the
exec-charset and the source charset are the same.
Any last thoughts?
-eric
--
Eric Christopher <echristo@redhat.com>
2004-02-24 Eric Christopher <echristo@redhat.com>
* lib/target-supports.exp (check-iconv-available): New function.
* lib/gcc-dg.exp (dg-require-iconv): New function.
Use above.
* gcc.dg/charset: New directory.
* gcc.dg/charset/charset.exp: New file.
* gcc.dg/charset/asm1.c: Ditto.
* gcc.dg/charset/asm2.c: Ditto.
* gcc.dg/charset/asm3.c: Ditto.
* gcc.dg/charset/asm4.c: Ditto.
* gcc.dg/charset/asm5.c: Ditto.
* gcc.dg/charset/attribute1.c: Ditto.
* gcc.dg/charset/attribute2.c: Ditto.
* gcc.dg/charset/string1.c: Ditto.
* g++.dg/charset: New directory.
* g++.dg/dg.exp: Add here. Special options.
* g++.dg/charset/charset.exp: New file.
* g++.dg/charset/asm1.c: Ditto.
* g++.dg/charset/asm2.c: Ditto.
* g++.dg/charset/asm3.c: Ditto.
* g++.dg/charset/asm4.c: Ditto.
* g++.dg/charset/attribute1.c: Ditto.
* g++.dg/charset/attribute2.c: Ditto.
* g++.dg/charset/extern1.cc: Ditto.
* g++.dg/charset/extern2.cc: Ditto.
* g++.dg/charset/string1.c: Ditto.
Index: g++.dg/dg.exp
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/g++.dg/dg.exp,v
retrieving revision 1.9
diff -u -p -w -r1.9 dg.exp
--- g++.dg/dg.exp 10 Jan 2003 02:22:28 -0000 1.9
+++ g++.dg/dg.exp 25 Feb 2004 03:01:54 -0000
@@ -32,6 +32,7 @@ dg-init
# that are handled specially.
set tests [lsort [find $srcdir/$subdir *.C]]
set tests [prune $tests $srcdir/$subdir/bprob/*]
+set tests [prune $tests $srcdir/$subdir/charset/*]
set tests [prune $tests $srcdir/$subdir/compat/*]
set tests [prune $tests $srcdir/$subdir/debug/*]
set tests [prune $tests $srcdir/$subdir/gcov/*]
Index: g++.dg/charset/asm1.c
===================================================================
RCS file: g++.dg/charset/asm1.c
diff -N g++.dg/charset/asm1.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ g++.dg/charset/asm1.c 25 Feb 2004 03:01:54 -0000
@@ -0,0 +1,14 @@
+/* { dg-do compile { target *-*-* } }
+ { dg-require-iconv "IBM-1047" }
+ { 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;
+}
Index: g++.dg/charset/asm2.c
===================================================================
RCS file: g++.dg/charset/asm2.c
diff -N g++.dg/charset/asm2.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ g++.dg/charset/asm2.c 25 Feb 2004 03:01:54 -0000
@@ -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 }
+ { dg-require-iconv "IBM-1047" }
+ { 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;
+}
Index: g++.dg/charset/asm3.c
===================================================================
RCS file: g++.dg/charset/asm3.c
diff -N g++.dg/charset/asm3.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ g++.dg/charset/asm3.c 25 Feb 2004 03:01:54 -0000
@@ -0,0 +1,10 @@
+/* Simple asm test. */
+/* { dg-do compile }
+ { dg-require-iconv "IBM-1047" }
+ { dg-final { scan-assembler "foo" } } */
+extern int bar;
+
+int main (void)
+{
+ asm ("foo %0" : "=r" (bar));
+}
Index: g++.dg/charset/asm4.c
===================================================================
RCS file: g++.dg/charset/asm4.c
diff -N g++.dg/charset/asm4.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ g++.dg/charset/asm4.c 25 Feb 2004 03:01:54 -0000
@@ -0,0 +1,8 @@
+/* Test for string translation. */
+/* { dg-do compile }
+ { dg-require-iconv "IBM-1047" }
+ { dg-final { scan-assembler-not "translate" } } */
+void foo (void)
+{
+ asm ("xx" : : "r"("translate") : "cc");
+}
Index: g++.dg/charset/attribute1.c
===================================================================
RCS file: g++.dg/charset/attribute1.c
diff -N g++.dg/charset/attribute1.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ g++.dg/charset/attribute1.c 25 Feb 2004 03:01:54 -0000
@@ -0,0 +1,10 @@
+/* Test for attribute non-translation. */
+/* { dg-do compile }
+ { dg-require-iconv "IBM-1047" }
+ { dg-final { scan-assembler "foo" } } */
+int walrus __attribute__ ((section (".foo")));
+
+int main (void)
+{
+ return 0;
+}
Index: g++.dg/charset/attribute2.c
===================================================================
RCS file: g++.dg/charset/attribute2.c
diff -N g++.dg/charset/attribute2.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ g++.dg/charset/attribute2.c 25 Feb 2004 03:01:54 -0000
@@ -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 "IBM-1047" }
+*/
+int foo __attribute__ ((walrus)); /* { dg-error "walrus" "ignored" } */
+char x[] = "foobar";
Index: g++.dg/charset/charset.exp
===================================================================
RCS file: g++.dg/charset/charset.exp
diff -N g++.dg/charset/charset.exp
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ g++.dg/charset/charset.exp 25 Feb 2004 03:01:54 -0000
@@ -0,0 +1,44 @@
+# Copyright (C) 2004 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 2 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 this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+# 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 g++-dg.exp
+load_lib target-supports.exp
+
+# If a testcase doesn't have special options, use these.
+global DEFAULT_CFLAGS
+if ![info exists DEFAULT_CFLAGS] then {
+ set DEFAULT_CFLAGS "-fexec-charset=IBM-1047"
+}
+
+# Initialize `dg'.
+dg-init
+
+# Main loop.
+dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.{c,S} ]] \
+ "" $DEFAULT_CFLAGS
+
+# All done.
+dg-finish
Index: g++.dg/charset/extern1.cc
===================================================================
RCS file: g++.dg/charset/extern1.cc
diff -N g++.dg/charset/extern1.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ g++.dg/charset/extern1.cc 25 Feb 2004 03:01:54 -0000
@@ -0,0 +1,15 @@
+/* Test extern statments not being translated. */
+/* { dg-do compile }
+ { dg-require-iconv "IBM-1047" }
+*/
+
+extern "C" {
+
+
+int testbug (void) {
+
+ return 0;
+
+}
+
+} //extern block
Index: g++.dg/charset/extern2.cc
===================================================================
RCS file: g++.dg/charset/extern2.cc
diff -N g++.dg/charset/extern2.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ g++.dg/charset/extern2.cc 25 Feb 2004 03:01:54 -0000
@@ -0,0 +1,5 @@
+/* Check that we push the declaration and then continue translation. */
+/* { dg-do compile }
+ { dg-require-iconv "IBM-1047" }
+ { dg-final { scan-assembler-not "foobar" } } */
+extern "C" { char *foo = "foobar"; }
Index: g++.dg/charset/string.c
===================================================================
RCS file: g++.dg/charset/string.c
diff -N g++.dg/charset/string.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ g++.dg/charset/string.c 25 Feb 2004 03:01:54 -0000
@@ -0,0 +1,5 @@
+/* Simple character translation test. */
+/* { dg-do compile }
+ { dg-require-iconv "IBM-1047" }
+ { dg-final { scan-assembler-not "string foobar" } } */
+char *foo = "string foobar";
Index: gcc.dg/charset/asm1.c
===================================================================
RCS file: gcc.dg/charset/asm1.c
diff -N gcc.dg/charset/asm1.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gcc.dg/charset/asm1.c 25 Feb 2004 03:01:56 -0000
@@ -0,0 +1,14 @@
+/* { dg-do compile }
+ { dg-require-iconv "IBM-1047" }
+ { 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;
+}
Index: gcc.dg/charset/asm2.c
===================================================================
RCS file: gcc.dg/charset/asm2.c
diff -N gcc.dg/charset/asm2.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gcc.dg/charset/asm2.c 25 Feb 2004 03:01:56 -0000
@@ -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 "IBM-1047" } */
+asm (not_a_string); /* { dg-error "syntax error before" "not_a_string" } */
+char x[] = "foobar";
+
+void foo (void)
+{
+ char *y;
+ asm (not_a_string2); /* { dg-error "syntax error before" "not_a_string" } */
+
+#define FOO "walrus"
+ y = FOO;
+}
Index: gcc.dg/charset/asm3.c
===================================================================
RCS file: gcc.dg/charset/asm3.c
diff -N gcc.dg/charset/asm3.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gcc.dg/charset/asm3.c 25 Feb 2004 03:01:56 -0000
@@ -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 }
+ { dg-require-iconv "IBM-1047" }
+ { 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;
+}
Index: gcc.dg/charset/asm4.c
===================================================================
RCS file: gcc.dg/charset/asm4.c
diff -N gcc.dg/charset/asm4.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gcc.dg/charset/asm4.c 25 Feb 2004 03:01:56 -0000
@@ -0,0 +1,10 @@
+/* Simple asm test. */
+/* { dg-do compile }
+ { dg-require-iconv "IBM-1047" }
+ { dg-final { scan-assembler "foo" } } */
+extern int bar;
+
+int main (void)
+{
+ asm ("foo %0" : "=r" (bar));
+}
Index: gcc.dg/charset/asm5.c
===================================================================
RCS file: gcc.dg/charset/asm5.c
diff -N gcc.dg/charset/asm5.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gcc.dg/charset/asm5.c 25 Feb 2004 03:01:56 -0000
@@ -0,0 +1,8 @@
+/* Test for string translation. */
+/* { dg-do compile }
+ { dg-require-iconv "IBM-1047" }
+ { dg-final { scan-assembler-not "translate" } } */
+void foo (void)
+{
+ asm ("xx" : : "r"("translate") : "cc");
+}
Index: gcc.dg/charset/attribute1.c
===================================================================
RCS file: gcc.dg/charset/attribute1.c
diff -N gcc.dg/charset/attribute1.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gcc.dg/charset/attribute1.c 25 Feb 2004 03:01:56 -0000
@@ -0,0 +1,10 @@
+/* Test for attribute non-translation. */
+/* { dg-do compile }
+ { dg-require-iconv "IBM-1047" }
+ { dg-final { scan-assembler "foo" } } */
+int walrus __attribute__ ((section (".foo")));
+
+int main (void)
+{
+ return 0;
+}
Index: gcc.dg/charset/attribute2.c
===================================================================
RCS file: gcc.dg/charset/attribute2.c
diff -N gcc.dg/charset/attribute2.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gcc.dg/charset/attribute2.c 25 Feb 2004 03:01:56 -0000
@@ -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 "IBM-1047" }
+ */
+int foo __attribute__ ((walrus)); /* { dg-error "walrus" "ignored" } */
+char x[] = "foobar";
Index: gcc.dg/charset/charset.exp
===================================================================
RCS file: gcc.dg/charset/charset.exp
diff -N gcc.dg/charset/charset.exp
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gcc.dg/charset/charset.exp 25 Feb 2004 03:01:56 -0000
@@ -0,0 +1,44 @@
+# Copyright (C) 2004 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 2 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 this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+# 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_CFLAGS
+if ![info exists DEFAULT_CFLAGS] then {
+ set DEFAULT_CFLAGS "-fexec-charset=IBM-1047"
+}
+
+# Initialize `dg'.
+dg-init
+
+# Main loop.
+dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.{c,S} ]] \
+ "" $DEFAULT_CFLAGS
+
+# All done.
+dg-finish
Index: gcc.dg/charset/string.c
===================================================================
RCS file: gcc.dg/charset/string.c
diff -N gcc.dg/charset/string.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gcc.dg/charset/string.c 25 Feb 2004 03:01:56 -0000
@@ -0,0 +1,5 @@
+/* Simple character translation test. */
+/* { dg-do compile }
+ { dg-require-iconv "IBM-1047" }
+ { dg-final { scan-assembler-not "string foobar" } } */
+char *foo = "string foobar";
Index: lib/gcc-dg.exp
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/lib/gcc-dg.exp,v
retrieving revision 1.29
diff -u -p -w -r1.29 gcc-dg.exp
--- lib/gcc-dg.exp 21 Feb 2004 02:58:23 -0000 1.29
+++ lib/gcc-dg.exp 25 Feb 2004 03:01:56 -0000
@@ -346,6 +346,15 @@ proc dg-require-dll { args } {
upvar dg-do-what dg-do-what
set dg-do-what [list [lindex ${dg-do-what} 0] "N" "P"]
+}
+
+proc dg-require-iconv { args } {
+ if { ![ check_iconv_available ${args} ] } {
+ upvar dg-do-what dg-do-what
+ set dg-do-what [list [lindex ${dg-do-what} 0] "N" "P"]
+ return
+ }
+ return
}
# Prune any messages matching ARGS[1] (a regexp) from test output.
Index: lib/target-supports.exp
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/lib/target-supports.exp,v
retrieving revision 1.12
diff -u -p -w -r1.12 target-supports.exp
--- lib/target-supports.exp 21 Feb 2004 03:02:32 -0000 1.12
+++ lib/target-supports.exp 25 Feb 2004 03:01:56 -0000
@@ -210,4 +210,35 @@ proc check_profiling_available { test_wh
}
return $profiling_available_saved
+}
+
+# Return true if iconv is supported on the target. In particular IBM-1047.
+
+proc check_iconv_available { test_what } {
+ global tool
+
+ set result ""
+
+ verbose "check_iconv_available compiling testfile" 1
+ set f [open "tmp.c" "w"]
+ # Compile a small test program.
+ puts $f "#include <iconv.h>\n"
+ puts $f "int main (void)\n {\n iconv_t cd; \n"
+ puts $f "cd = iconv_open (\"[lindex $test_what 1]\", \"UTF-8\");\n"
+ puts $f "if (cd == (iconv_t) -1)\n return 1;\n"
+ puts $f "return 0;\n}"
+ close $f
+
+ set lines [${tool}_target_compile "tmp.c" "tmp.x" executable ""]
+
+ set result [${tool}_load "./tmp.x" "" ""]
+ set status [lindex $result 0];
+
+ verbose "status is <$status>"
+
+ if { $status == "pass" } then {
+ return 1
+ }
+
+ return 0
}