diff --git a/gcc/final.c b/gcc/final.c
index 718caf1..2393c0f 100644
--- a/gcc/final.c
+++ b/gcc/final.c
@@ -3444,6 +3444,12 @@ output_asm_insn (const char *templ, rtx *operands)
 	  output_operand_lossage ("invalid %%-code");
 	break;
 
+      /* Escaped braces. Print them as is. */
+      case '\\':
+        if (*p == '{' || *p == '}')
+          c = *p++;
+        /* FALLTHROUGH */
+
       default:
 	putc (c, asm_out_file);
       }
@@ -3955,6 +3961,12 @@ asm_fprintf (FILE *file, const char *p, ...)
 	  }
 	break;
 
+      /* Escaped braces. Print them as is. */
+      case '\\':
+        if (*p == '{' || *p == '}')
+          c = *p++;
+        /* FALLTHROUGH */
+
       default:
 	putc (c, file);
       }
diff --git a/gcc/testsuite/gcc.dg/asm-braces.c b/gcc/testsuite/gcc.dg/asm-braces.c
new file mode 100644
index 0000000..4f428c8
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/asm-braces.c
@@ -0,0 +1,9 @@
+/* { dg-do compile } */
+/* { dg-options "" } */
+
+void f()
+{
+  asm ( ".pushsection \".foo\"; .asciz \"div \\{ width : 50%% | height = 10px \\} \"; .long %c0; .popsection" : : "i"(42) );
+}
+
+/* { dg-final { scan-assembler "div { width : 50%% | height = 10px }" } } */
-- 
1.7.7.6

