Fix off-by-one error in StringLiteral::getLocationOfByte.

This fixes PR10223.

llvm-svn: 134183
This commit is contained in:
Hans Wennborg 2011-06-30 20:17:41 +00:00
parent b10a0f223a
commit 77d1abef07
2 changed files with 7 additions and 1 deletions

View 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

View 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}}
}