teak-llvm/clang/test/Preprocessor/wchar_t.c
Rainer Orth abccb1ad89 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
2019-06-17 20:21:25 +00:00

119 lines
7.8 KiB
C

// 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__ 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
// CHECK-AVR-NOT: #define __WCHAR_UNSIGNED__ 0
// RUN: %clang_cc1 -triple arm-unknown-none-gnu -fsigned-wchar -dM -E %s -o - | FileCheck %s -check-prefix CHECK-ARM-APCS
// CHECK-ARM-APCS-DAG: #define __WCHAR_MAX__ 2147483647
// CHECK-ARM-APCS-DAG: #define __WCHAR_TYPE__ int
// CHECK-ARM-APCS-NOT: #define __WCHAR_UNSIGNED__ 0
// RUN: %clang_cc1 -triple arm-unknown-netbsd-gnu -fsigned-wchar -dM -E %s -o - | FileCheck %s -check-prefix CHECK-ARM-NETBSD-AAPCS
// CHECK-ARM-NETBSD-AAPCS-DAG: #define __WCHAR_MAX__ 2147483647
// CHECK-ARM-NETBSD-AAPCS-DAG: #define __WCHAR_TYPE__ int
// CHECK-ARM-NETBSD-AAPCS-NOT: #define __WCHAR_UNSIGNED__ 0
// RUN: %clang_cc1 -triple arm-unknown-openbsd -fsigned-wchar -dM -E %s -o - | FileCheck %s -check-prefix CHECK-ARM-OPENBSD
// CHECK-ARM-OPENBSD-DAG: #define __WCHAR_MAX__ 2147483647
// CHECK-ARM-OPENBSD-DAG: #define __WCHAR_TYPE__ int
// CHECK-ARM-OPENBSD-NOT: #define __WCHAR_UNSIGNED__ 0
// RUN: %clang_cc1 -triple arm64-apple-ios -fsigned-wchar -dM -E %s -o - | FileCheck %s -check-prefix CHECK-ARM64-DARWIN
// CHECK-ARM64-DARWIN-DAG: #define __WCHAR_MAX__ 2147483647
// CHECK-ARM64-DARWIN-DAG: #define __WCHAR_TYPE__ int
// CHECK-ARM64-DARWIN-NOT: #define __WCHAR_UNSIGNED__ 0
// RUN: %clang_cc1 -triple aarch64-unknown-netbsd -fsigned-wchar -dM -E %s -o - | FileCheck %s -check-prefix CHECK-ARM64-NETBSD
// CHECK-ARM64-NETBSD-DAG: #define __WCHAR_MAX__ 2147483647
// CHECK-ARM64-NETBSD-DAG: #define __WCHAR_TYPE__ int
// CHECK-ARM64-NETBSD-NOT: #define __WCHAR_UNSIGNED__ 0
// RUN: %clang_cc1 -triple aarch64-unknown-openbsd -fsigned-wchar -dM -E %s -o - | FileCheck %s -check-prefix CHECK-ARM64-OPENBSD
// CHECK-ARM64-OPENBSD-DAG: #define __WCHAR_MAX__ 2147483647
// CHECK-ARM64-OPENBSD-DAG: #define __WCHAR_TYPE__ int
// CHECK-ARM64-OPENBSD-NOT: #define __WCHAR_UNSIGNED__ 0
// RUN: %clang_cc1 -triple aarch64-unknown-none -fwchar-type=int -fno-signed-wchar -dM -E %s -o - | FileCheck %s -check-prefix CHECK-ARM64-AAPCS64
// CHECK-ARM64-AAPCS64-DAG: #define __WCHAR_MAX__ 4294967295U
// CHECK-ARM64-AAPCS64-DAG: #define __WCHAR_TYPE__ unsigned int
// CHECK-ARM64-AAPCS64-DAG: #define __WCHAR_UNSIGNED__ 1
// RUN: %clang_cc1 -triple xcore-unknown-unknown -fwchar-type=char -fno-signed-wchar -dM -E %s -o - | FileCheck %s -check-prefix CHECK-XCORE
// CHECK-XCORE-DAG: #define __WCHAR_MAX__ 255
// CHECK-XCORE-DAG: #define __WCHAR_TYPE__ unsigned char
// CHECK-XCORE-DAG: #define __WCHAR_UNSIGNED__ 1
// RUN: %clang_cc1 -triple x86_64-unknown-windows-cygnus -fwchar-type=short -fno-signed-wchar -dM -E %s -o - | FileCheck %s -check-prefix CHECK-CYGWIN-X64
// CHECK-CYGWIN-X64-DAG: #define __WCHAR_MAX__ 65535
// CHECK-CYGWIN-X64-DAG: #define __WCHAR_TYPE__ unsigned short
// CHECK-CYGWIN-X64-DAG: #define __WCHAR_UNSIGNED__ 1
// RUN: %clang_cc1 -triple x86_64-unknown-windows-msvc -fwchar-type=short -fno-signed-wchar -dM -E %s -o - | FileCheck %s -check-prefix CHECK-MSVC-X64
// CHECK-MSVC-X64-DAG: #define __WCHAR_MAX__ 65535
// CHECK-MSVC-X64-DAG: #define __WCHAR_TYPE__ unsigned short
// CHECK-MSVC-X64-DAG: #define __WCHAR_UNSIGNED__ 1
// RUN: %clang_cc1 -triple i686-unknown-windows-cygnus -fwchar-type=short -fno-signed-wchar -dM -E %s -o - | FileCheck %s -check-prefix CHECK-CYGWIN-X86
// CHECK-CYGWIN-X86-DAG: #define __WCHAR_MAX__ 65535
// CHECK-CYGWIN-X86-DAG: #define __WCHAR_TYPE__ unsigned short
// CHECK-CYGWIN-X86-DAG: #define __WCHAR_UNSIGNED__ 1
// RUN: %clang_cc1 -triple i686-unknown-windows-msvc -fwchar-type=short -fno-signed-wchar -dM -E %s -o - | FileCheck %s -check-prefix CHECK-MSVC-X86
// CHECK-MSVC-X86-DAG: #define __WCHAR_MAX__ 65535
// CHECK-MSVC-X86-DAG: #define __WCHAR_TYPE__ unsigned short
// CHECK-MSVC-X86-DAG: #define __WCHAR_UNSIGNED__ 1
// RUN: %clang_cc1 -triple x86_64-scei-ps4 -fwchar-type=short -fno-signed-wchar -dM -E %s -o - | FileCheck %s -check-prefix CHECK-PS4
// CHECK-PS4-DAG: #define __WCHAR_MAX__ 65535
// CHECK-PS4-DAG: #define __WCHAR_TYPE__ unsigned short
// CHECK-PS4-DAG: #define __WCHAR_UNSIGNED__ 1
// RUN: %clang_cc1 -triple thumbv7-unknown-windows-cygnus -fwchar-type=short -fno-signed-wchar -dM -E %s -o - | FileCheck %s -check-prefix CHECK-CYGWIN-ARM
// CHECK-CYGWIN-ARM-DAG: #define __WCHAR_MAX__ 65535
// CHECK-CYGWIN-ARM-DAG: #define __WCHAR_TYPE__ unsigned short
// CHECK-CYGWIN-ARM-DAG: #define __WCHAR_UNSIGNED__ 1
// RUN: %clang_cc1 -triple thumbv7-unknown-windows-msvc -fwchar-type=short -fno-signed-wchar -dM -E %s -o - | FileCheck %s -check-prefix CHECK-MSVC-ARM
// CHECK-MSVC-ARM-DAG: #define __WCHAR_MAX__ 65535
// CHECK-MSVC-ARM-DAG: #define __WCHAR_TYPE__ unsigned short
// CHECK-MSVC-ARM-DAG: #define __WCHAR_UNSIGNED__ 1
// RUN: %clang_cc1 -triple aarch64-unknown-windows-msvc -fwchar-type=short -fno-signed-wchar -dM -E %s -o - | FileCheck %s -check-prefix CHECK-MSVC-ARM64
// CHECK-MSVC-ARM64-DAG: #define __WCHAR_MAX__ 65535
// CHECK-MSVC-ARM64-DAG: #define __WCHAR_TYPE__ unsigned short
// CHECK-MSVC-ARM64-DAG: #define __WCHAR_UNSIGNED__ 1
// RUN: %clang_cc1 -triple i386-apple-macosx -dM -E %s -o - | FileCheck %s -check-prefix CHECK-DARWIN
// RUN: %clang_cc1 -triple x86_64-apple-macosx -dM -E %s -o - | FileCheck %s -check-prefix CHECK-DARWIN
// RUN: %clang_cc1 -triple ppc64-apple-macosx -dM -E %s -o - | FileCheck %s -check-prefix CHECK-DARWIN
// RUN: %clang_cc1 -triple i386-apple-ios -dM -E %s -o - | FileCheck %s -check-prefix CHECK-DARWIN
// RUN: %clang_cc1 -triple x86_64-apple-ios -dM -E %s -o - | FileCheck %s -check-prefix CHECK-DARWIN
// RUN: %clang_cc1 -triple armv7-apple-ios -dM -E %s -o - | FileCheck %s -check-prefix CHECK-DARWIN
// RUN: %clang_cc1 -triple aarch64-apple-ios -dM -E %s -o - | FileCheck %s -check-prefix CHECK-DARWIN
// RUN: %clang_cc1 -triple i386-apple-tvos -dM -E %s -o - | FileCheck %s -check-prefix CHECK-DARWIN
// RUN: %clang_cc1 -triple x86_64-apple-tvos -dM -E %s -o - | FileCheck %s -check-prefix CHECK-DARWIN
// RUN: %clang_cc1 -triple armv7-apple-tvos -dM -E %s -o - | FileCheck %s -check-prefix CHECK-DARWIN
// RUN: %clang_cc1 -triple aarch64-apple-tvos -dM -E %s -o - | FileCheck %s -check-prefix CHECK-DARWIN
// RUN: %clang_cc1 -triple i386-apple-watchos -dM -E %s -o - | FileCheck %s -check-prefix CHECK-DARWIN
// RUN: %clang_cc1 -triple x86_64-apple-watchos -dM -E %s -o - | FileCheck %s -check-prefix CHECK-DARWIN
// RUN: %clang_cc1 -triple armv7-apple-watchos -dM -E %s -o - | FileCheck %s -check-prefix CHECK-DARWIN
// RUN: %clang_cc1 -triple aarch64-apple-watchos -dM -E %s -o - | FileCheck %s -check-prefix CHECK-DARWIN
// CHECK-DARWIN: #define __WCHAR_TYPE__ int
// RUN: %clang_cc1 -triple i686-unknown-windows-msvc -fwchar-type=int -fsigned-wchar -dM -E %s -o - | FileCheck %s -check-prefix CHECK-WINDOWS-ISO10646
// RUN: %clang_cc1 -triple x86_64-unknown-windows-msvc -fwchar-type=int -fsigned-wchar -dM -E %s -o - | FileCheck %s -check-prefix CHECK-WINDOWS-ISO10646
// RUN: %clang_cc1 -triple thumbv7-unknown-windows-msvc -fwchar-type=int -fsigned-wchar -dM -E %s -o - | FileCheck %s -check-prefix CHECK-WINDOWS-ISO10646
// RUN: %clang_cc1 -triple aarch64-unknown-windows-msvc -fwchar-type=int -fsigned-wchar -dM -E %s -o - | FileCheck %s -check-prefix CHECK-WINDOWS-ISO10646
// CHECK-WINDOWS-ISO10646: #define __WCHAR_TYPE__ int