]> granicus.if.org Git - clang/commitdiff
Get the type right for wide string literals; it's wchar_t, not char.
authorEli Friedman <eli.friedman@gmail.com>
Tue, 27 May 2008 07:57:14 +0000 (07:57 +0000)
committerEli Friedman <eli.friedman@gmail.com>
Tue, 27 May 2008 07:57:14 +0000 (07:57 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@51586 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaExpr.cpp
test/Sema/wchar_size.c [new file with mode: 0644]

index e85ad03694aa54d55387fdd3c486668353e6d395..7dda9b141d404a5bfd8634c2e6d713477e0d0d6f 100644 (file)
@@ -51,7 +51,7 @@ Sema::ActOnStringLiteral(const Token *StringToks, unsigned NumStringToks) {
                             StringToks[NumStringToks-1].getLocation()));
   
   QualType StrTy = Context.CharTy;
-  // FIXME: handle wchar_t
+  if (Literal.AnyWide) StrTy = Context.getWcharType();
   if (Literal.Pascal) StrTy = Context.UnsignedCharTy;
   
   // Get an array type for the string, according to C99 6.4.5.  This includes
diff --git a/test/Sema/wchar_size.c b/test/Sema/wchar_size.c
new file mode 100644 (file)
index 0000000..a4041b9
--- /dev/null
@@ -0,0 +1,3 @@
+// RUN: clang %s -fsyntax-only -verify -triple=i686-apple-darwin9
+
+int check_wchar_size[sizeof(*L"") == 4 ? 1 : -1];