ro updated this revision to Diff 205012. ro added a comment. Herald added a subscriber: krytarowski.
Adapt `Sema/format-strings.c`. Repository: rC Clang CHANGES SINCE LAST ACTION https://reviews.llvm.org/D62944/new/ https://reviews.llvm.org/D62944 Files: lib/Basic/Targets/OSTargets.h test/Preprocessor/wchar_t.c test/Sema/format-strings.c test/Sema/wchar.c Index: test/Sema/wchar.c =================================================================== --- test/Sema/wchar.c +++ test/Sema/wchar.c @@ -9,7 +9,11 @@ #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 Index: test/Sema/format-strings.c =================================================================== --- test/Sema/format-strings.c +++ test/Sema/format-strings.c @@ -329,7 +329,11 @@ 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 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'}} Index: test/Preprocessor/wchar_t.c =================================================================== --- test/Preprocessor/wchar_t.c +++ 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 Index: lib/Basic/Targets/OSTargets.h =================================================================== --- lib/Basic/Targets/OSTargets.h +++ lib/Basic/Targets/OSTargets.h @@ -632,7 +632,11 @@ public: SolarisTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts) : OSTargetInfo<Target>(Triple, Opts) { - // FIXME: WIntType should be SignedLong + if (this->PointerWidth == 64) { + this->WCharType = this->WIntType = this->SignedInt; + } else { + this->WCharType = this->WIntType = this->SignedLong; + } switch (Triple.getArch()) { default: break;
Index: test/Sema/wchar.c =================================================================== --- test/Sema/wchar.c +++ test/Sema/wchar.c @@ -9,7 +9,11 @@ #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 Index: test/Sema/format-strings.c =================================================================== --- test/Sema/format-strings.c +++ test/Sema/format-strings.c @@ -329,7 +329,11 @@ 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 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'}} Index: test/Preprocessor/wchar_t.c =================================================================== --- test/Preprocessor/wchar_t.c +++ 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 Index: lib/Basic/Targets/OSTargets.h =================================================================== --- lib/Basic/Targets/OSTargets.h +++ lib/Basic/Targets/OSTargets.h @@ -632,7 +632,11 @@ public: SolarisTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts) : OSTargetInfo<Target>(Triple, Opts) { - // FIXME: WIntType should be SignedLong + if (this->PointerWidth == 64) { + this->WCharType = this->WIntType = this->SignedInt; + } else { + this->WCharType = this->WIntType = this->SignedLong; + } switch (Triple.getArch()) { default: break;
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits