ICU-6487 Enable utf16 string literals on GCC >= 4.4 when strict is disabled.

X-SVN-Rev: 26309
This commit is contained in:
Michael Ow 2009-07-13 19:01:23 +00:00
parent 82f5cda478
commit 6aec621e32
5 changed files with 115 additions and 5 deletions

View file

@ -275,10 +275,14 @@ typedef unsigned int uint32_t;
* instead.
* @internal
*/
#ifndef U_GNUC_UTF16_STRING
#define U_GNUC_UTF16_STRING @U_CHECK_GNUC_UTF16_STRING@
#endif
#if @U_CHECK_UTF16_STRING@ || defined(U_CHECK_UTF16_STRING)
#if (defined(__xlC__) && defined(__IBM_UTF_LITERAL) && U_SIZEOF_WCHAR_T != 2) \
|| (defined(__HP_aCC) && __HP_aCC >= 035000) \
|| (defined(__HP_cc) && __HP_cc >= 111106)
|| (defined(__HP_cc) && __HP_cc >= 111106) \
|| U_GNUC_UTF16_STRING
#define U_DECLARE_UTF16(string) u ## string
#elif (defined(__SUNPRO_CC) && __SUNPRO_CC >= 0x550)
/* || (defined(__SUNPRO_C) && __SUNPRO_C >= 0x580) */

View file

@ -1,7 +1,7 @@
/*
******************************************************************************
*
* Copyright (C) 1999-2008, International Business Machines
* Copyright (C) 1999-2009, International Business Machines
* Corporation and others. All Rights Reserved.
*
******************************************************************************
@ -284,17 +284,23 @@ typedef int8_t UBool;
/**
* \var UChar
* Define UChar to be wchar_t if that is 16 bits wide; always assumed to be unsigned.
* If wchar_t is not 16 bits wide, then define UChar to be uint16_t.
* If wchar_t is not 16 bits wide, then define UChar to be uint16_t or char16_t because GCC >=4.4
* can handle UTF16 string literals.
* This makes the definition of UChar platform-dependent
* but allows direct string type compatibility with platforms with
* 16-bit wchar_t types.
*
* @stable ICU 2.0
* @draft ICU 4.4
*/
/* Define UChar to be compatible with wchar_t if possible. */
#if U_SIZEOF_WCHAR_T==2
typedef wchar_t UChar;
#elif U_GNUC_UTF16_STRING
#if defined _GCC_
typedef __CHAR16_TYPE__ char16_t;
#endif
typedef char16_t UChar;
#else
typedef uint16_t UChar;
#endif

View file

@ -655,6 +655,7 @@ LAYOUT_TRUE
ICUIO_TRUE
EXTRAS_TRUE
U_CHECK_UTF16_STRING
U_CHECK_GNUC_UTF16_STRING
U_SIZEOF_WCHAR_T
U_HAVE_WCSCPY
U_HAVE_WCHAR_H
@ -9983,6 +9984,7 @@ fi
$as_echo_n "checking for UTF-16 string literal support... " >&6; }
U_CHECK_UTF16_STRING=1
CHECK_UTF16_STRING_RESULT="unknown"
case "${host}" in
*-*-aix*|powerpc64-*-linux*)
if test "$ac_cv_c_compiler_gnu" = no; then
@ -10117,6 +10119,75 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
*)
;;
esac
# GCC >= 4.4 supports UTF16 string literals. The CFLAGS and CXXFLAGS may change in the future.
# Since we have to use a different standard, if strict is enable, don't enable UTF16 string literals.
U_CHECK_GNUC_UTF16_STRING=0
if test "$ac_use_strict_options" = no && test "$CHECK_UTF16_STRING_RESULT" = "unknown"; then
if test "$ac_cv_c_compiler_gnu" = yes; then
OLD_CFLAGS="${CFLAGS}"
OLD_CXXFLAGS="${CXXFLAGS}"
CFLAGS="${CFLAGS} -std=gnu99 -D_GCC_"
CXXFLAGS="${CXXFLAGS} -std=c++0x"
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)
int daisy;
#else
GCC IS TOO OLD!
#endif
int
main ()
{
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (ac_try="$ac_compile"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
$as_echo "$ac_try_echo") >&5
(eval "$ac_compile") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } && {
test -z "$ac_c_werror_flag" ||
test ! -s conftest.err
} && test -s conftest.$ac_objext; then
U_CHECK_UTF16_STRING=1
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
U_CHECK_UTF16_STRING=0
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
if test "$U_CHECK_UTF16_STRING" = 1; then
CHECK_UTF16_STRING_RESULT="available";
U_CHECK_GNUC_UTF16_STRING=1
else
CFLAGS="${OLD_CFLAGS}"
CXXFLAGS="${OLD_CXXFLAGS}"
fi
fi
fi
{ $as_echo "$as_me:$LINENO: result: $CHECK_UTF16_STRING_RESULT" >&5
$as_echo "$CHECK_UTF16_STRING_RESULT" >&6; }

View file

@ -868,6 +868,7 @@ AC_SUBST(U_SIZEOF_WCHAR_T)
AC_MSG_CHECKING([for UTF-16 string literal support])
U_CHECK_UTF16_STRING=1
CHECK_UTF16_STRING_RESULT="unknown"
case "${host}" in
*-*-aix*|powerpc64-*-linux*)
if test "$ac_cv_c_compiler_gnu" = no; then
@ -920,6 +921,34 @@ case "${host}" in
*)
;;
esac
# GCC >= 4.4 supports UTF16 string literals. The CFLAGS and CXXFLAGS may change in the future.
# Since we have to use a different standard, if strict is enable, don't enable UTF16 string literals.
U_CHECK_GNUC_UTF16_STRING=0
if test "$ac_use_strict_options" = no && test "$CHECK_UTF16_STRING_RESULT" = "unknown"; then
if test "$ac_cv_c_compiler_gnu" = yes; then
OLD_CFLAGS="${CFLAGS}"
OLD_CXXFLAGS="${CXXFLAGS}"
CFLAGS="${CFLAGS} -std=gnu99 -D_GCC_"
CXXFLAGS="${CXXFLAGS} -std=c++0x"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)
int daisy;
#else
GCC IS TOO OLD!
#endif
]], [[]])],[U_CHECK_UTF16_STRING=1],[U_CHECK_UTF16_STRING=0])
if test "$U_CHECK_UTF16_STRING" = 1; then
CHECK_UTF16_STRING_RESULT="available";
U_CHECK_GNUC_UTF16_STRING=1
else
CFLAGS="${OLD_CFLAGS}"
CXXFLAGS="${OLD_CXXFLAGS}"
fi
fi
fi
AC_SUBST(U_CHECK_GNUC_UTF16_STRING)
AC_MSG_RESULT($CHECK_UTF16_STRING_RESULT)
AC_SUBST(U_CHECK_UTF16_STRING)

View file

@ -1235,7 +1235,7 @@ void CalendarRegressionTest::test4108764()
void CalendarRegressionTest::test4114578()
{
UErrorCode status = U_ZERO_ERROR;
int32_t ONE_HOUR = 60*60*1000;
double ONE_HOUR = 60*60*1000;
Calendar *cal = Calendar::createInstance(status);
if(U_FAILURE(status)) {
errln("Error creating calendar %s", u_errorName(status));