]> granicus.if.org Git - clang/commitdiff
Fix a bug in ConvertAsmString function.
authorLauro Ramos Venancio <lauro.venancio@gmail.com>
Tue, 26 Feb 2008 19:19:58 +0000 (19:19 +0000)
committerLauro Ramos Venancio <lauro.venancio@gmail.com>
Tue, 26 Feb 2008 19:19:58 +0000 (19:19 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@47618 91177308-0d34-0410-b5e6-96231b3b80d8

CodeGen/CGStmt.cpp
test/CodeGen/2008-02-26-inline-asm-bug.c [new file with mode: 0644]

index 0da91dabe63af3a39e8534f4b5400a47b6ddc154..5fdc61b46f8894dc105df68470e74a3ca2baefd8 100644 (file)
@@ -569,7 +569,7 @@ static inline std::string ConvertAsmString(const char *Start,
         }
         
         Result += '$' + llvm::utostr(n);
-        Start = End;
+        Start = End - 1;
       } else if (isalpha(EscapedChar)) {
         char *End;
         
@@ -583,7 +583,7 @@ static inline std::string ConvertAsmString(const char *Start,
         }
         
         Result += "${" + llvm::utostr(n) + ':' + EscapedChar + '}';
-        Start = End;
+        Start = End - 1;
       } else {
         assert(0 && "Unhandled asm escaped character!");
       }
diff --git a/test/CodeGen/2008-02-26-inline-asm-bug.c b/test/CodeGen/2008-02-26-inline-asm-bug.c
new file mode 100644 (file)
index 0000000..668b06c
--- /dev/null
@@ -0,0 +1,6 @@
+// RUN: clang -emit-llvm < %s | grep "\$0,\$1"
+
+void f() {
+  int d1, d2;
+  asm("%0,%1": "=r" (d1) : "r" (d2));
+}