aboutsummaryrefslogtreecommitdiff
path: root/clang/test
diff options
context:
space:
mode:
authorRainer Orth <ro@gcc.gnu.org>2019-06-17 20:21:25 +0000
committerRainer Orth <ro@gcc.gnu.org>2019-06-17 20:21:25 +0000
commitabccb1ad896f27f82cfad160ccd582171575fefb (patch)
tree6ba5e26f582d2ee188eabed0508ebbdfdfc0df92 /clang/test
parent2d26cf37d777c9e6c4f89144b506a153b010d495 (diff)
downloadllvm-abccb1ad896f27f82cfad160ccd582171575fefb.zip
llvm-abccb1ad896f27f82cfad160ccd582171575fefb.tar.gz
llvm-abccb1ad896f27f82cfad160ccd582171575fefb.tar.bz2
Clang :: Sema/wchar.c has long been failing on Solaris:
error: 'error' diagnostics expected but not seen: File /vol/llvm/src/clang/local/test/Sema/wchar.c Line 22: initializing wide char array with non-wide string literal error: 'error' diagnostics seen but not expected: File /vol/llvm/src/clang/local/test/Sema/wchar.c Line 20: array initializer must be an initializer list File /vol/llvm/src/clang/local/test/Sema/wchar.c Line 22: array initializer must be an initializer list It turns out the definition is wrong, as can be seen in GCC's gcc/config/sol2.h: /* wchar_t is called differently in <wchar.h> for 32 and 64-bit compilations. This is called for by SCD 2.4.1, p. 6-83, Figure 6-65 (32-bit) and p. 6P-10, Figure 6.38 (64-bit). */ #undef WCHAR_TYPE #define WCHAR_TYPE (TARGET_64BIT ? "int" : "long int") The following patch implements this, and at the same time corrects the wint_t definition which is the same: /* Same for wint_t. See SCD 2.4.1, p. 6-83, Figure 6-66 (32-bit). There's no corresponding 64-bit definition, but this is what Solaris 8 <iso/wchar_iso.h> uses. */ #undef WINT_TYPE #define WINT_TYPE (TARGET_64BIT ? "int" : "long int") Clang :: Preprocessor/wchar_t.c and Clang :: Sema/format-strings.c need to be adjusted to account for that. Tested on i386-pc-solaris2.11, x86_64-pc-solaris2.11, and x86_64-pc-linux-gnu. Differential Revision: https://reviews.llvm.org/D62944 llvm-svn: 363612
Diffstat (limited to 'clang/test')
-rw-r--r--clang/test/Preprocessor/wchar_t.c7
-rw-r--r--clang/test/Sema/format-strings.c6
-rw-r--r--clang/test/Sema/wchar.c6
3 files changed, 16 insertions, 3 deletions
diff --git a/clang/test/Preprocessor/wchar_t.c b/clang/test/Preprocessor/wchar_t.c
index 6c47a2b..9a7cade 100644
--- a/clang/test/Preprocessor/wchar_t.c
+++ b/clang/test/Preprocessor/wchar_t.c
@@ -1,8 +1,13 @@
// RUN: %clang_cc1 -triple i386-pc-solaris -dM -E %s -o - | FileCheck %s -check-prefix CHECK-SOLARIS
// CHECK-SOLARIS-DAG: #define __WCHAR_MAX__ 2147483647
-// CHECK-SOLARIS-DAG: #define __WCHAR_TYPE__ int
+// CHECK-SOLARIS-DAG: #define __WCHAR_TYPE__ long int
// CHECK-SOLARIS-NOT: #define __WCHAR_UNSIGNED__ 0
+// RUN: %clang_cc1 -triple x86_64-pc-solaris -dM -E %s -o - | FileCheck %s -check-prefix CHECK-SOLARIS64
+// CHECK-SOLARIS64-DAG: #define __WCHAR_MAX__ 2147483647
+// CHECK-SOLARIS64-DAG: #define __WCHAR_TYPE__ int
+// CHECK-SOLARIS64-NOT: #define __WCHAR_UNSIGNED__ 0
+
// RUN: %clang_cc1 -triple avr-unknown-unknown -fwchar-type=int -fsigned-wchar -dM -E %s -o - | FileCheck %s -check-prefix CHECK-AVR
// CHECK-AVR-DAG: #define __WCHAR_MAX__ 32767
// CHECK-AVR-DAG: #define __WCHAR_TYPE__ int
diff --git a/clang/test/Sema/format-strings.c b/clang/test/Sema/format-strings.c
index e8acd40..45bf2605 100644
--- a/clang/test/Sema/format-strings.c
+++ b/clang/test/Sema/format-strings.c
@@ -329,7 +329,11 @@ void test_unicode_conversions(wchar_t *s) {
printf("%S", s); // no-warning
printf("%s", s); // expected-warning{{format specifies type 'char *' but the argument has type 'wchar_t *'}}
printf("%C", s[0]); // no-warning
+#if defined(__sun) && !defined(__LP64__)
+ printf("%c", s[0]); // expected-warning{{format specifies type 'int' but the argument has type 'wchar_t' (aka 'long')}}
+#else
printf("%c", s[0]);
+#endif
// FIXME: This test reports inconsistent results. On Windows, '%C' expects
// 'unsigned short'.
// printf("%C", 10);
@@ -401,7 +405,7 @@ void bug7377_bad_length_mod_usage() {
void pr7981(wint_t c, wchar_t c2) {
printf("%lc", c); // no-warning
printf("%lc", 1.0); // expected-warning{{the argument has type 'double'}}
-#if __WINT_WIDTH__ == 32
+#if __WINT_WIDTH__ == 32 && !(defined(__sun) && !defined(__LP64__))
printf("%lc", (char) 1); // no-warning
#else
printf("%lc", (char) 1); // expected-warning{{the argument has type 'char'}}
diff --git a/clang/test/Sema/wchar.c b/clang/test/Sema/wchar.c
index e84fe3e..6a4b75b 100644
--- a/clang/test/Sema/wchar.c
+++ b/clang/test/Sema/wchar.c
@@ -9,7 +9,11 @@ typedef __WCHAR_TYPE__ wchar_t;
#elif defined(__arm) || defined(__aarch64__)
#define WCHAR_T_TYPE unsigned int
#elif defined(__sun)
- #define WCHAR_T_TYPE long
+ #if defined(__LP64__)
+ #define WCHAR_T_TYPE int
+ #else
+ #define WCHAR_T_TYPE long
+ #endif
#else /* Solaris. */
#define WCHAR_T_TYPE int
#endif