initialization of wchar_t arrays with wide strings, and generalizes
wchar_size.c to work on all targets.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65586
91177308-0d34-0410-b5e6-
96231b3b80d8
if (LangOpts.CPlusPlus)
return WCharTy;
- // FIXME: In C, shouldn't WCharTy just be a typedef of the target's
- // wide-character type?
return getFromTargetType(Target.getWCharType());
}
// wchar_t array can be initialized with a wide string: C99 6.7.8p15:
// "An array with element type compatible with wchar_t may be initialized by a
// wide string literal, optionally enclosed in braces."
- if (Context.typesAreCompatible(Context.WCharTy, AT->getElementType()))
+ if (Context.typesAreCompatible(Context.getWCharType(), AT->getElementType()))
// Only allow wchar_t x[] = L"foo"; not wchar_t x[] = "foo";
return Init;
-// RUN: clang %s -fsyntax-only -verify -triple=i686-apple-darwin9
+// RUN: clang %s -fsyntax-only -verify
+#include <wchar.h>
-int check_wchar_size[sizeof(*L"") == 4 ? 1 : -1];
+int check_wchar_size[sizeof(*L"") == sizeof(wchar_t) ? 1 : -1];
+
+void foo() {
+ int t1[] = L"x";
+ wchar_t tab[] = L"x";
+
+ int t2[] = "x"; // expected-error {{initialization}}
+ char t3[] = L"x"; // expected-error {{initialization}}
+}