annotate clang/test/Sema/wchar.c @ 221:79ff65ed7e25

LLVM12 Original
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Tue, 15 Jun 2021 19:15:29 +0900
parents 1d019706d866
children c4bab56944e8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
150
anatofuz
parents:
diff changeset
1 // RUN: %clang_cc1 %s -fsyntax-only -verify
anatofuz
parents:
diff changeset
2 // RUN: %clang_cc1 %s -fsyntax-only -fwchar-type=short -fno-signed-wchar -verify -DSHORT_WCHAR
anatofuz
parents:
diff changeset
3
anatofuz
parents:
diff changeset
4 typedef __WCHAR_TYPE__ wchar_t;
anatofuz
parents:
diff changeset
5
anatofuz
parents:
diff changeset
6 #if defined(_WIN32) || defined(_M_IX86) || defined(__CYGWIN__) \
anatofuz
parents:
diff changeset
7 || defined(_M_X64) || defined(__ORBIS__) || defined(SHORT_WCHAR)
anatofuz
parents:
diff changeset
8 #define WCHAR_T_TYPE unsigned short
221
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
9 #elif defined(__aarch64__)
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
10 // See AArch64TargetInfo constructor -- unsigned on non-darwin non-OpenBSD non-NetBSD.
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
11 #if defined(__OpenBSD__) || defined(__APPLE__) || defined(__NetBSD__)
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
12 #define WCHAR_T_TYPE int
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
13 #else
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
14 #define WCHAR_T_TYPE unsigned int
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
15 #endif
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
16 #elif defined(__arm) || defined(__MVS__)
150
anatofuz
parents:
diff changeset
17 #define WCHAR_T_TYPE unsigned int
anatofuz
parents:
diff changeset
18 #elif defined(__sun)
anatofuz
parents:
diff changeset
19 #if defined(__LP64__)
anatofuz
parents:
diff changeset
20 #define WCHAR_T_TYPE int
anatofuz
parents:
diff changeset
21 #else
anatofuz
parents:
diff changeset
22 #define WCHAR_T_TYPE long
anatofuz
parents:
diff changeset
23 #endif
221
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
24 #else /* Solaris, Linux, non-arm64 macOS, ... */
150
anatofuz
parents:
diff changeset
25 #define WCHAR_T_TYPE int
anatofuz
parents:
diff changeset
26 #endif
anatofuz
parents:
diff changeset
27
anatofuz
parents:
diff changeset
28 int check_wchar_size[sizeof(*L"") == sizeof(wchar_t) ? 1 : -1];
anatofuz
parents:
diff changeset
29
anatofuz
parents:
diff changeset
30 void foo() {
anatofuz
parents:
diff changeset
31 WCHAR_T_TYPE t1[] = L"x";
anatofuz
parents:
diff changeset
32 wchar_t tab[] = L"x";
anatofuz
parents:
diff changeset
33 WCHAR_T_TYPE t2[] = "x"; // expected-error {{initializing wide char array with non-wide string literal}}
anatofuz
parents:
diff changeset
34 char t3[] = L"x"; // expected-error {{initializing char array with wide string literal}}
anatofuz
parents:
diff changeset
35 }