From 8ef1f26775cae95d202d8d90d92d39add685af3e Mon Sep 17 00:00:00 2001 From: Eli Friedman Date: Tue, 27 May 2008 07:57:14 +0000 Subject: [PATCH] Get the type right for wide string literals; it's wchar_t, not char. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@51586 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Sema/SemaExpr.cpp | 2 +- test/Sema/wchar_size.c | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 test/Sema/wchar_size.c diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index e85ad03694..7dda9b141d 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -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 index 0000000000..a4041b976d --- /dev/null +++ b/test/Sema/wchar_size.c @@ -0,0 +1,3 @@ +// RUN: clang %s -fsyntax-only -verify -triple=i686-apple-darwin9 + +int check_wchar_size[sizeof(*L"") == 4 ? 1 : -1]; -- 2.50.1