OSDN Git Service

PR c/37772
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 1 Apr 2009 13:32:22 +0000 (13:32 +0000)
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 1 Apr 2009 13:32:22 +0000 (13:32 +0000)
* c-parser.c (c_parser_asm_statement): Skip until close paren and
return if c_parser_asm_string_literal returned NULL.

* gcc.dg/pr37772.c: New test.
* g++.dg/ext/asm11.C: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@145401 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/c-parser.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/ext/asm11.C [new file with mode: 0644]
gcc/testsuite/gcc.dg/pr37772.c [new file with mode: 0644]

index 327d33d..54cad4c 100644 (file)
@@ -1,3 +1,9 @@
+2009-04-01  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c/37772
+       * c-parser.c (c_parser_asm_statement): Skip until close paren and
+       return if c_parser_asm_string_literal returned NULL.
+
 2009-04-01  Nick Clifton  <nickc@redhat.com>
 
        * config/m32c/m32c.h (LIBGCC2_UNITS_PER_WORD): Define if not
 2009-04-01  Nick Clifton  <nickc@redhat.com>
 
        * config/m32c/m32c.h (LIBGCC2_UNITS_PER_WORD): Define if not
index 03a7194..1be2ae5 100644 (file)
@@ -4193,6 +4193,12 @@ c_parser_asm_statement (c_parser *parser)
       return NULL_TREE;
     }
   str = c_parser_asm_string_literal (parser);
       return NULL_TREE;
     }
   str = c_parser_asm_string_literal (parser);
+  if (str == NULL_TREE)
+    {
+      parser->lex_untranslated_string = false;
+      c_parser_skip_until_found (parser, CPP_CLOSE_PAREN, NULL);
+      return NULL_TREE;
+    }
   if (c_parser_next_token_is (parser, CPP_CLOSE_PAREN))
     {
       simple = true;
   if (c_parser_next_token_is (parser, CPP_CLOSE_PAREN))
     {
       simple = true;
index ee6dbb5..5aef381 100644 (file)
@@ -1,7 +1,14 @@
+2009-04-01  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c/37772
+       * gcc.dg/pr37772.c: New test.
+       * g++.dg/ext/asm11.C: New test.
+
 2009-04-01  H.J. Lu  <hongjiu.lu@intel.com>
 
 2009-04-01  H.J. Lu  <hongjiu.lu@intel.com>
 
-       (restore_ld_library_path_env_vars): Always restore GCC_EXEC_PREFIX
-       to its original value, or unset if it was not defined.
+       * lib/target-libpath.exp (restore_ld_library_path_env_vars): Always
+       restore GCC_EXEC_PREFIX to its original value, or unset if it was not
+       defined.
 
 2009-03-31  Jason Merrill  <jason@redhat.com>
 
 
 2009-03-31  Jason Merrill  <jason@redhat.com>
 
diff --git a/gcc/testsuite/g++.dg/ext/asm11.C b/gcc/testsuite/g++.dg/ext/asm11.C
new file mode 100644 (file)
index 0000000..7939aac
--- /dev/null
@@ -0,0 +1,20 @@
+// PR c/37772
+// { dg-do compile }
+// { dg-options "" }
+
+void
+foo ()
+{
+  int i;
+  asm ();                // { dg-error "expected string-literal before" }
+  asm (1);               // { dg-error "expected string-literal before" }
+  asm (int);             // { dg-error "expected string-literal before" }
+  asm (: "=r" (i));      // { dg-error "expected string-literal before" }
+  asm (1 : "=r" (i));    // { dg-error "expected string-literal before" }
+  asm (int : "=r" (i));          // { dg-error "expected string-literal before" }
+  asm (: : "r" (i));     // { dg-error "expected string-literal before" }
+  asm (1 : : "r" (i));   // { dg-error "expected string-literal before" }
+  asm (int : : "r" (i));  // { dg-error "expected string-literal before" }
+  asm (: : : "memory");          // { dg-error "expected string-literal before" }
+  asm (1 : : : "memory"); // { dg-error "expected string-literal before" }
+}
diff --git a/gcc/testsuite/gcc.dg/pr37772.c b/gcc/testsuite/gcc.dg/pr37772.c
new file mode 100644 (file)
index 0000000..26051c7
--- /dev/null
@@ -0,0 +1,20 @@
+/* PR c/37772 */
+/* { dg-do compile } */
+/* { dg-options "" } */
+
+void
+foo ()
+{
+  int i;
+  asm ();                /* { dg-error "expected string literal before" } */
+  asm (1);               /* { dg-error "expected string literal before" } */
+  asm (int);             /* { dg-error "expected string literal before" } */
+  asm (: "=r" (i));      /* { dg-error "expected string literal before" } */
+  asm (1 : "=r" (i));    /* { dg-error "expected string literal before" } */
+  asm (int : "=r" (i));          /* { dg-error "expected string literal before" } */
+  asm (: : "r" (i));     /* { dg-error "expected string literal before" } */
+  asm (1 : : "r" (i));   /* { dg-error "expected string literal before" } */
+  asm (int : : "r" (i));  /* { dg-error "expected string literal before" } */
+  asm (: : : "memory");          /* { dg-error "expected string literal before" } */
+  asm (1 : : : "memory"); /* { dg-error "expected string literal before" } */
+}