[cfe-commits] r134183 - in /cfe/trunk: lib/AST/Expr.cpp test/Sema/asm.c

Hans Wennborg hans at hanshq.net
Thu Jun 30 13:17:41 PDT 2011


Author: hans
Date: Thu Jun 30 15:17:41 2011
New Revision: 134183

URL: http://llvm.org/viewvc/llvm-project?rev=134183&view=rev
Log:
Fix off-by-one error in StringLiteral::getLocationOfByte.

This fixes PR10223.

Modified:
    cfe/trunk/lib/AST/Expr.cpp
    cfe/trunk/test/Sema/asm.c

Modified: cfe/trunk/lib/AST/Expr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Expr.cpp?rev=134183&r1=134182&r2=134183&view=diff
==============================================================================
--- cfe/trunk/lib/AST/Expr.cpp (original)
+++ cfe/trunk/lib/AST/Expr.cpp Thu Jun 30 15:17:41 2011
@@ -593,7 +593,7 @@
     
     // 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

Modified: cfe/trunk/test/Sema/asm.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/asm.c?rev=134183&r1=134182&r2=134183&view=diff
==============================================================================
--- cfe/trunk/test/Sema/asm.c (original)
+++ cfe/trunk/test/Sema/asm.c Thu Jun 30 15:17:41 2011
@@ -117,3 +117,9 @@
 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}}
+}





More information about the cfe-commits mailing list