]> granicus.if.org Git - clang/commitdiff
Fix pascal string support; testcase from mailing list message.
authorEli Friedman <eli.friedman@gmail.com>
Wed, 1 Apr 2009 03:17:08 +0000 (03:17 +0000)
committerEli Friedman <eli.friedman@gmail.com>
Wed, 1 Apr 2009 03:17:08 +0000 (03:17 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68181 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Lex/LiteralSupport.cpp
test/CodeGen/pascal-string.c [new file with mode: 0644]

index 11bb1f25ad2dde5aca79020a2ee7cfedcaa1589d..345291382da600d78d34002db41ae461b9cdadf7 100644 (file)
@@ -863,12 +863,13 @@ StringLiteralParser(const Token *StringToks, unsigned NumStringToks,
     ResultBuf[0] = ResultPtr-&ResultBuf[0]-1;
 
     // Verify that pascal strings aren't too large.
-    if (GetStringLength() > 256)
+    if (GetStringLength() > 256) {
       PP.Diag(StringToks[0].getLocation(), diag::err_pascal_string_too_long)
         << SourceRange(StringToks[0].getLocation(),
                        StringToks[NumStringToks-1].getLocation());
-    hadError = 1;
-    return;
+      hadError = 1;
+      return;
+    }
   }
 }
 
diff --git a/test/CodeGen/pascal-string.c b/test/CodeGen/pascal-string.c
new file mode 100644 (file)
index 0000000..fcd807c
--- /dev/null
@@ -0,0 +1,8 @@
+// RUN: clang-cc -emit-llvm -o - %s -fpascal-strings | grep "05Hello"
+
+unsigned char * Foo( void )
+{
+  static unsigned char s[256] = "\pHello";
+  return s;
+}
+