This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Add a wchar effective target to the testsuite
- From: Richard Sandiford <richard at codesourcery dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Thu, 15 Mar 2007 08:44:17 +0000
- Subject: Add a wchar effective target to the testsuite
This patch adds an effective target for testing whether the runtime
has wide character support. It's usually enough to check whether
<wchar.h> exists, but on uClibc targets, you also need to check
whether __UCLIBC_HAS_WCHAR__ is defined; if it isn't, the header
will still exist but will not be usable.
Tested on m68k-uclinux, i586-wrs-vxworks (which has no wchar.h)
and x86_64-linux-gnu. OK to install?
Richard
gcc/testsuite/
* lib/target-supports.exp (check_missing_uclibc_feature)
(check_effective_target_wchar): New procedures.
* gcc.dg/wchar_t-1.c: Require target wchar.
* gcc.dg/wint_t-1.c: Likewise.
Index: gcc/testsuite/lib/target-supports.exp
===================================================================
--- gcc/testsuite/lib/target-supports.exp (revision 122923)
+++ gcc/testsuite/lib/target-supports.exp (working copy)
@@ -2065,6 +2065,21 @@ proc check_effective_target_uclibc {} {
}]
}
+# Return true if this is a uclibc target and if the uclibc feature
+# described by __$feature__ is not present.
+
+proc check_missing_uclibc_feature {feature} {
+ if {[check_no_compiler_messages $feature object "
+ #include <features.h>
+ #if defined (__UCLIBC__) && !defined (__${feature}__)
+ #error FOO
+ #endif
+ "]} {
+ return 0
+ }
+ return 1
+}
+
# Return true if this is a Newlib target.
proc check_effective_target_newlib {} {
@@ -2197,3 +2212,14 @@ proc check_effective_target_vxworks_kern
#endif
}]
}
+
+# Return 1 if the target is expected to provide wide character support.
+
+proc check_effective_target_wchar { } {
+ if {[check_missing_uclibc_feature UCLIBC_HAS_WCHAR]} {
+ return 0
+ }
+ return [check_no_compiler_messages wchar assembly {
+ #include <wchar.h>
+ }]
+}
Index: gcc/testsuite/gcc.dg/wchar_t-1.c
===================================================================
--- gcc/testsuite/gcc.dg/wchar_t-1.c (revision 122923)
+++ gcc/testsuite/gcc.dg/wchar_t-1.c (working copy)
@@ -1,4 +1,4 @@
-/* { dg-do compile } */
+/* { dg-do compile { target wchar } } */
/* { dg-options "-Wall" } */
/* Compile with -Wall to get a warning if built-in and system wchar_t don't
Index: gcc/testsuite/gcc.dg/wint_t-1.c
===================================================================
--- gcc/testsuite/gcc.dg/wint_t-1.c (revision 122923)
+++ gcc/testsuite/gcc.dg/wint_t-1.c (working copy)
@@ -1,4 +1,4 @@
-/* { dg-do compile } */
+/* { dg-do compile { target wchar } } */
/* { dg-options "-Wall" } */
/* Compile with -Wall to get a warning if built-in and system wint_t don't