]> granicus.if.org Git - clang/commitdiff
Wide Pascal strings should be of type wchar_t[] and not unsigned char[].
authorAnders Carlsson <andersca@mac.com>
Wed, 6 Apr 2011 18:42:48 +0000 (18:42 +0000)
committerAnders Carlsson <andersca@mac.com>
Wed, 6 Apr 2011 18:42:48 +0000 (18:42 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@129017 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaExpr.cpp
test/SemaCXX/pascal-wchar-strings.cpp [new file with mode: 0644]

index 55155efa696290772d3df7cbad93bb746786e42f..13ac32dcb13cf2ebcaccc73468a439be81e376cb 100644 (file)
@@ -744,8 +744,10 @@ Sema::ActOnStringLiteral(const Token *StringToks, unsigned NumStringToks) {
     StringTokLocs.push_back(StringToks[i].getLocation());
 
   QualType StrTy = Context.CharTy;
-  if (Literal.AnyWide) StrTy = Context.getWCharType();
-  if (Literal.Pascal) StrTy = Context.UnsignedCharTy;
+  if (Literal.AnyWide) 
+    StrTy = Context.getWCharType();
+  else if (Literal.Pascal)
+    StrTy = Context.UnsignedCharTy;
 
   // A C++ string literal has a const-qualified element type (C++ 2.13.4p1).
   if (getLangOptions().CPlusPlus || getLangOptions().ConstStrings)
diff --git a/test/SemaCXX/pascal-wchar-strings.cpp b/test/SemaCXX/pascal-wchar-strings.cpp
new file mode 100644 (file)
index 0000000..db80b68
--- /dev/null
@@ -0,0 +1,2 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s -fpascal-strings
+const wchar_t *pascalString = L"\pThis is a Pascal string";