diff options
author | Hans Wennborg <hans@hanshq.net> | 2011-06-30 20:17:41 +0000 |
---|---|---|
committer | Hans Wennborg <hans@hanshq.net> | 2011-06-30 20:17:41 +0000 |
commit | 935a70c1e76d78985f20d422940280161b941299 (patch) | |
tree | 87b1b4e0c92c1ac7e6a3027f569f21336a25c468 | |
parent | 150fee8b2ba3ea6faa12e68cb58adc5e2fc73825 (diff) |
Fix off-by-one error in StringLiteral::getLocationOfByte.
This fixes PR10223.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134183 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/AST/Expr.cpp | 2 | ||||
-rw-r--r-- | test/Sema/asm.c | 6 |
2 files changed, 7 insertions, 1 deletions
diff --git a/lib/AST/Expr.cpp b/lib/AST/Expr.cpp index fdcb77f324..1d0319f601 100644 --- a/lib/AST/Expr.cpp +++ b/lib/AST/Expr.cpp @@ -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 diff --git a/test/Sema/asm.c b/test/Sema/asm.c index a3313cad2b..f1c24c8fb6 100644 --- a/test/Sema/asm.c +++ b/test/Sema/asm.c @@ -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}} +} |