]> granicus.if.org Git - clang/commitdiff
Fix off-by-one error in StringLiteral::getLocationOfByte.
authorHans Wennborg <hans@hanshq.net>
Thu, 30 Jun 2011 20:17:41 +0000 (20:17 +0000)
committerHans Wennborg <hans@hanshq.net>
Thu, 30 Jun 2011 20:17:41 +0000 (20:17 +0000)
This fixes PR10223.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134183 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/Expr.cpp
test/Sema/asm.c

index fdcb77f324795173a5a7d9b1bf15383446644ca7..1d0319f60142476a71bebd3ee112252a56146828 100644 (file)
@@ -593,7 +593,7 @@ getLocationOfByte(unsigned ByteNo, const SourceManager &SM,
     
     // If the byte is in this token, return the location of the byte.
     if (ByteNo < TokNumBytes ||
-        (ByteNo == TokNumBytes && TokNo == getNumConcatenated())) {
+        (ByteNo == TokNumBytes && TokNo == getNumConcatenated() - 1)) {
       unsigned Offset = SLP.getOffsetOfStringByte(TheTok, ByteNo); 
       
       // Now that we know the offset of the token in the spelling, use the
index a3313cad2b4b42a36a710825b8cc4785e923a675..f1c24c8fb64157b5af4d0a6593975f1c2afd9137 100644 (file)
@@ -117,3 +117,9 @@ void test11(void) {
 void test12(void) {
   register int cc __asm ("cc"); // expected-error{{unknown register name 'cc' in asm}}
 }
+
+// PR10223
+void test13(void) {
+  void *esp;
+  __asm__ volatile ("mov %%esp, %o" : "=r"(esp) : : ); // expected-error {{invalid % escape in inline assembly string}}
+}